How to activate profile by means of maven property?

前端 未结 7 1313
Happy的楠姐
Happy的楠姐 2020-12-05 10:25

I\'m trying to activate a maven profile using a property defined inside pom.xml:


  [...]
  
             


        
相关标签:
7条回答
  • 2020-12-05 10:58

    As mentioned in previous answers, profile activation only works with system properties.

    But, with a little creativity you can achieve a similar result (conditional plugin execution) using pom properties. To achieve that, use the phase tag of the plugin you want to conditionally execute:

    <project>
    
        ...
    
        <properties>
            <run.it>none</run.it>
            <!-- <run.it>compile</run.it> -->
            <!-- <run.it>package</run.it> -->
        </properties>
    
        ...
    
        <build>
    
            ...
    
            <plugins>
                <plugin>
                <artifactId>your-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>${run.it}</phase>
                    </execution>
                </executions>
    
                </plugin>
            </plugins>
    
            ...
    
        </build>
    
    </project>
    

    The only difference is that you have to use a phase name instead of true/false. But you can change the property or override it freely as a property.

    0 讨论(0)
提交回复
热议问题