web-dev-qa-db-ja.com

maven buildnumberプラグインを使用して、scmチェックなしでビルド番号を生成することは可能ですか?

Mavenビルド番号プラグインの使用中に次の例外を取得します。ビルド番号プラグインの使用中にSCMチェックを無効にすることは可能ですか?このプラグインを使用して、非SCMビルドでビルド番号を生成できますか?

ビルド中の例外:

[ERROR] Failed to execute goal org.codehaus.mojo:buildnumber-maven-plugin:1.0:create (default) on project projectname: Execution default of goal org.codehaus.mojo:buildnumber-maven-plugin:1.0:create failed: The scm url cannot be null. -> [Help 1]
org.Apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:buildnumber-maven-plugin:1.0:create (default) on project projectname: Execution default of goal org.codehaus.mojo:buildnumber-maven-plugin:1.0:create failed: The scm url cannot be null.
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:225)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:153)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:145)
    at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:84)
    at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:59)
    at org.Apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.Java:183)
    at org.Apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.Java:161)
    at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:319)
    at org.Apache.maven.DefaultMaven.execute(DefaultMaven.Java:156)
    at org.Apache.maven.cli.MavenCli.execute(MavenCli.Java:534)
    at org.Apache.maven.cli.MavenCli.doMain(MavenCli.Java:196)
    at org.Apache.maven.cli.MavenCli.main(MavenCli.Java:141)
    at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:39)
    at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:25)
    at Java.lang.reflect.Method.invoke(Method.Java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.Java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.Java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.Java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.Java:352)
Caused by: org.Apache.maven.plugin.PluginExecutionException: Execution default of goal org.codehaus.mojo:buildnumber-maven-plugin:1.0:create failed: The scm url cannot be null.
    at org.Apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.Java:116)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:209)
    ... 19 more
Caused by: Java.lang.NullPointerException: The scm url cannot be null.
    at org.Apache.maven.scm.manager.AbstractScmManager.makeScmRepository(AbstractScmManager.Java:183)
    at org.codehaus.mojo.build.CreateMojo.getScmRepository(CreateMojo.Java:768)
    at org.codehaus.mojo.build.CreateMojo.getRevision(CreateMojo.Java:692)
    at org.codehaus.mojo.build.CreateMojo.execute(CreateMojo.Java:443)
    at org.Apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.Java:107)
    ... 20 more

POM設定:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>buildnumber-maven-plugin</artifactId>
    <version>1.0</version>
    <executions>
    <execution>
      <phase>validate</phase>
      <goals>
    <goal>create</goal>
    <goal>create-timestamp</goal>
      </goals>
    </execution>
    </executions>
    <configuration>
    <buildNumberPropertyName>build.number</buildNumberPropertyName>
    <timestampFormat>yyyy-MM-dd HH:mm:ss.SSS z</timestampFormat>
    <timestampPropertyName>build.time</timestampPropertyName>
    <doCheck>false</doCheck>
    <doUpdate>false</doUpdate>
    </configuration>
</plugin>

<plugin>
    <groupId>org.Apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
    <source>1.6</source>
    <target>1.6</target>
    </configuration>
</plugin>
<plugin>
    <groupId>org.Apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1.1</version>
    <configuration>
    <warname>foodwalaweb</warname>
    <!--webResources>
        <resource>
        <filtering>false</filtering>
        <directory>${basedir}/src/main/Java</directory>
        <includes>
        <include>META-INF/persistence.xml</include>
        </includes>
        </resource>
    </webResources-->
    <archive>
    <manifest>
        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
        <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
    </manifest>
    <manifestEntries>
        <Build-Number>${buildNumber}</Build-Number>
        <Built-Time>${build.time}</Built-Time>
    </manifestEntries>
    </archive>
    </configuration>
</plugin>
27
Joshan George

ダミーのSCMを定義してから、 buildNumber item を使用して、revisionOnScmFailureプロパティで定義された値の代わりにシーケンシャルビルド番号を取得します。

pom.xml:

<project ...>

    <scm>
        <connection>scm:svn:http://127.0.0.1/dummy</connection>
        <developerConnection>scm:svn:https://127.0.0.1/dummy</developerConnection>
        <tag>HEAD</tag>
        <url>http://127.0.0.1/dummy</url>
    </scm>

    <build>
      <plugins>

        ...

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.1</version>
            <executions>
            <execution>
                <id>buildnumber</id>
                <phase>validate</phase>
                <goals>
                <goal>create</goal>
                </goals>
            </execution>
            </executions>
            <configuration>
                <format>{0,number}</format>
                <items>
                <item>buildNumber</item>
                </items>                    
                <doCheck>false</doCheck>
                <doUpdate>false</doUpdate>
                <revisionOnScmFailure>unknownbuild</revisionOnScmFailure>   
            </configuration>
        </plugin>


      </plugins>
    </build>
</project>
28
Wade

バージョン1.4では、以下が機能します。

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>buildnumber-maven-plugin</artifactId>
    <version>1.4</version>
    <configuration>
        <revisionOnScmFailure>no.scm.config.in.pom</revisionOnScmFailure>
    </configuration>
    <executions>
        <execution>
            <id>create-timestamp-id</id>
            <phase>validate</phase>
            <goals>
                <goal>create-timestamp</goal>
            </goals>
            <configuration>
                <timestampFormat>yyyy-MM-dd HH:mm:ss.S</timestampFormat>
                <timestampPropertyName>myBuildNumberVariable</timestampPropertyName>
                <!-- formats the timestamp all together like 2016-04-04 14:17:05.123 and puts 
                    it in the ${myBuildNumberVariable} buildProperty -->
            </configuration>
        </execution>
    </executions>
</plugin>
8
Alan MacK

あなたがする必要があるのは、pluginManagementタグ内にプラグインを囲むことです

<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <doCheck>true</doCheck>
                <doUpdate>true</doUpdate>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>
3
Bikram

GITのcommitIdとタイムスタンプを同時にプロパティに入れたいというケースがありました。これも同様にできますか?
もちろん:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>buildnumber-maven-plugin</artifactId>
    <version>1.4</version>
    <inherited>false</inherited>
    <executions>
        <execution>
            <id>commitId</id>
            <phase>validate</phase>
            <goals>
                <goal>create</goal>
            </goals>
            <configuration>
                <buildNumberPropertyName>commitId</buildNumberPropertyName>
                <shortRevisionLength>7</shortRevisionLength>
            </configuration>
        </execution>
        <execution>
            <id>buildTimestamp</id>
            <phase>validate</phase>
            <goals>
                <goal>create-timestamp</goal>
            </goals>
            <configuration>
                <timestampPropertyName>buildTimestamp</timestampPropertyName>
            </configuration>
        </execution>
    </executions>
</plugin>
1
pai

私が間違っていなければ、次は機能していました:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>buildnumber-maven-plugin</artifactId>
    <version>1.0-beta-3</version>
    <configuration>
      <buildNumberPropertyName>buildNumber.value</buildNumberPropertyName>
      <timestampPropertyName>buildNumber.timestamp</timestampPropertyName>
      <format>{0,date,yyyyMMdd-HHmm}</format>
      <items>
        <item>timestamp</item>
      </items>
    </configuration>
    <executions>
      <execution>
        <phase>validate</phase>
        <goals>
          <goal>create</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>
0
maximdim