Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hot to disable buildnumber-maven-plugin through cmd

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.

like image 602
user1289877 Avatar asked Mar 24 '12 11:03

user1289877


2 Answers

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
like image 51
Mark O'Connor Avatar answered Sep 21 '22 17:09

Mark O'Connor


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
like image 30
matt_smith Avatar answered Sep 22 '22 17:09

matt_smith