0

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>
David S
  • 195
  • 5
  • 19
  • Can you explain why you are using a profile for what purpose? The full pom file and a description what you like to achieve would be helpful. – khmarbaise Jan 23 '22 at 09:20
  • It's quite long and business related so I can't share it straight off, but I have updated it to include as much of my pom as possible. What I want to accomplish is to control if a dependency is included in the build by switching a property in the pom. This current setup somewhat work by switching the value for activeByDefault. But from what I could find you can't define boolean values through properties so I need a workaround to either do that or approach the issue from a different angle. – David S Jan 23 '22 at 09:48
  • Controlling dependencies via properties is simply wrong. The question is why ? – khmarbaise Jan 23 '22 at 10:07
  • Yeah, I know it's frowned upon in that sense. But profile specific dependencies should be ok from what I've read. Can't answer why I need this setup, sorry! – David S Jan 23 '22 at 10:18
  • The why is the crucial part. Because I suppose your assumptions for using such setup is wrong. (That several people writing such things does not mean it's a good idea)... – khmarbaise Jan 23 '22 at 10:34

1 Answers1

0

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>
David S
  • 195
  • 5
  • 19