Maven - Profile Depending on Property?

522 Views Asked by At

I have the following profile below, instead of using activeByDefault I would like to active it through a property instead. I saw this comment (https://stackoverflow.com/a/18890159/1959534) in passing about being able to do so through maven assembly plugin but I couldn't figure out how to specify that. Any input on how to accomplish this?

<project ...>
   ...
   <profiles>
      <profile>
         <id>myProfile</id>
         <activation>
            <activeByDefault>true</activeByDefault>
         </activation>
         <dependencies>
            <dependency>
               <!-- Extra dependency just for this profile -->
            </dependency>
         </dependencies>
      </profile>
   </profiles>
</project>
1

There are 1 best solutions below

0
David S On BEST ANSWER

Figured it out! Defined a system variable in the project's /.mvn/jvm.config and then changed the activation step to be through property instead of activeByDefault. Then used this tips to throw config out to my .properties file: https://stackoverflow.com/a/14386303/1959534

jvm.config

-Dmy.property=true

pom.xml

<profiles>
   <profile>
      ...
      <activation>
         <property>
            <name>my.property</name>
            <value>true</value>
         </property>
      </activation>
   </profile>
</profiles>