Hot to disable buildnumber-maven-plugin through cmd
Asked Answered
L

4

5

I have question about maven. How can I disable buildnumber-maven-plugin through command line option. I want to run "mvn test" command on our continuous integration server, but this cmd failed because it trying to build a version and haven't access permission to our vcs (which is configured in tag). So it is possible disable it through cmd option or run only the tests without building new release version? Thanks for any help.

Lebron answered 24/3, 2012 at 11:47 Comment(0)
P
10

Use a profile to control which plug-ins are enabled during the build:

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.me.test</groupId>
    <artifactId>demo</artifactId>
    <version>1.0</version>
    ..
    ..
    <profiles>
        <profile>
            <id>with-scm</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>buildnumber-maven-plugin</artifactId>
                        <version>1.0</version>
                        <executions>
                            <execution>
                                <phase>validate</phase>
                                <goals>
                                    <goal>create</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <doCheck>true</doCheck>
                            <doUpdate>true</doUpdate>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

The profile can be enabled by running Maven as follows:

mvn -Pwith-scm package
Para answered 24/3, 2012 at 13:12 Comment(2)
But I have only option to add cmd parameter to maven build on CI. I cannot manipulate with pom.xml and settings.xmlLebron
If you can't change the POM, then you are stuck with a Maven build life-cycle that includes SCM operations. Using a profile is a mechanism for implementing optional life-cycle actionsPrelate
D
4

One approach would be to use a property in your pom to specify the execution phase of the build number plugin, as shown below.

<project>
  ..
  <properties>
    <buildnumber.plugin.phase>validate</buildnumber.plugin.phase>
    ..
  </properties>
  ..
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>buildnumber-maven-plugin</artifactId>
      <version>1.2</version>
      <executions>
        <execution>
          <phase>${buildnumber.plugin.phase}</phase>
          <goals>
            <goal>create</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        ..
      </configuration>
    </plugin>
  </plugins>
  ..
</project>

Then provide the property on the command line to disable the plugin, as shown in the following example.

mvn install -Dbuildnumber.plugin.phase=none
Diminished answered 8/4, 2013 at 13:17 Comment(0)
D
0

You may skip failure without change pom.xml in project. Please look at my answer at Disable maven build number plugin

Deckle answered 7/5, 2019 at 21:4 Comment(0)
S
-1
mvn clean install deploy -Dbuildnumber.phase=none
Shulins answered 22/10, 2016 at 3:31 Comment(1)
This answer does not provide any explanation or any new information not contained in already existing answers.Tayler

© 2022 - 2024 — McMap. All rights reserved.