简体   繁体   中英

Maven - Profile Depending on Property?

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>

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM