Maven: Using a Plugin Based On Profile

后端 未结 2 1398
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-13 15:37

I have a file which maintains a build-number for release build. Everytime a release build is made, this number is incremented and the file is saved into svn repository.

相关标签:
2条回答
  • 2021-02-13 16:32

    I would suggest you take a look at the documentation for build profiles first. You can find that here. The first thing you want to look over is this section:

    How can a profile be triggered? How does this vary according to the type of profile being used?

    Basically, once you understand that, note that what you put in your profile section is pretty close to what you have outside your profile. That being said, if you need a profile specific build section, it should emulate what you would have outside the profile - if you take a look at the pom.xsd it is the exact same I believe.

    So, for example:

    <profiles>
        <profile>
            <id>full-build</id>
            <activation>
                <property>
                    <name>build</name>
                    <value>full</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo.webstart</groupId>
                        <artifactId>webstart-maven-plugin</artifactId>
                        <version>1.0-beta-1</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>jnlp</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <resourcesDirectory>src/main/web</resourcesDirectory>
                            ....
    

    This would be triggered by running: mvn package -Dbuild=full

    I hope this helps.

    0 讨论(0)
  • 2021-02-13 16:38

    Using pluginManagement will not cause the build plugin to run. It is used to specify plugin version and configuration information to child POMs. Also you're missing the 'profile' child element of 'profiles'. Lastly, unless you plan on activating the profile via -P, you'll need some activation criteria.

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