activeByDefault  is a bit tricky as it doesn't really when that it is
active by default all the time. It is only active if there is no other
profile ativated [1]. So I believe this is the behavior that you're seeing.

So, 'activeByDefault' is typically not good to use as you can get
unexpected behavior. E.g. when you enable some other profile.

On a general note I don't really understand the use case. In general you
shouldn't use profiles, especially to change the build behavior as you seem
to be wanting here.

[1]
https://maven.apache.org/guides/introduction/introduction-to-profiles.html

/Anders

On Wed, May 13, 2020 at 11:37 AM Adam Retter
<[email protected]> wrote:

> I have a build plugin configured like so:
>
> <plugin>
>     <groupId>org.apache.maven.plugins</groupId>
>     <artifactId>maven-assembly-plugin</artifactId>
>     <executions>
>         <execution>
>             <id>assemble-archives</id>
>             <phase>package</phase>
>             <goals>
>                 <goal>single</goal>
>             </goals>
>         </execution>
>     </executions>
>     <configuration>
>         <skipAssembly>true</skipAssembly>  <!-- Overridden by profile
> build-dist-archives -->
>     </configuration>
> </plugin>
>
>
> I am trying to override its configuration in a profile that I would
> like enabled by default:
>
> <profiles>
>     <profile>
>         <id>build-dist-archives</id>
>         <activation>
>             <activeByDefault>true</activeByDefault>
>         </activation>
>         <build>
>             <plugins>
>                 <plugin>
>                     <groupId>org.apache.maven.plugins</groupId>
>                     <artifactId>maven-assembly-plugin</artifactId>
>                     <configuration>
>                         <skipAssembly>false</skipAssembly>  <!--
> Override setting in default profile build/plugins for this module -->
>                         <attach>false</attach>
>                         <tarLongFileMode>gnu</tarLongFileMode>
>                         <descriptors>
>
> <descriptor>src/assembly/dist-assembly-unix.xml</descriptor>
>
> <descriptor>src/assembly/dist-assembly-win.xml</descriptor>
>                         </descriptors>
>                     </configuration>
>                 </plugin>
>             </plugins>
>         </build>
>     </profile>
>
>
> I would expect that when I run `mvn package`, the
> `build-dist-archives` profile is active and therefore the
> maven-assembly-plugin SHOULD have skipAssembly=false. In the output
> from Maven I see:
>
> [INFO] --- maven-assembly-plugin:3.3.0:single (assemble-archives) @
> exist-distribution ---
> [INFO] Assemblies have been skipped per configuration of the
> skipAssembly parameter.
>
> This implies that skipAssembly was true.
>
>
> However... if I manually enable the profile by running `mvn package -P
> build-dist-archives`, then the maven-assembly-plugin does indeed have
> skipAssembly=false, and the assembly is correctly built.
>
> Can anyone tell me why the ` <activeByDefault>true</activeByDefault>`
> on the profile is being ignored?
>
>
> --
> Adam Retter
>
> skype: adam.retter
> tweet: adamretter
> http://www.adamretter.org.uk
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to