在准备命令

时间:2016-03-16 21:37:48

标签: maven maven-release-plugin

我希望能够在不需要用户输入的情况下运行maven准备。
目前,我必须手动输入“是”'和' 0'为了正确解决每个项目的依赖关系。

更新:由于' no'和' 1'是默认设置,我不能使用' -B'以批处理模式运行它。

Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T16:58:10-04:00)
Maven home: C:\apps\apache-maven\bin\..
Java version: 1.6.0_45, vendor: Sun Microsystems Inc.
Java home: C:\Program Files (x86)\Java\jdk1.6.0_45\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

插件:maven-release-plugin
目标:准备

手动输入示例:

There are still some remaining snapshot dependencies.
: Do you want to resolve them now? (yes/no) no: : yes
Dependency type to resolve,: specify the selection number ( 0:All 1:Project Dependencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 0
Dependency 'gov.xxxx.abc.api:Abc2_Common_Model' is a snapshot (8.0.0.8-SNAPSHOT)
: Which release version should it be set to? 8.0.0.8: :
What version should the dependency be reset to for development? 8.0.0.8: :

完整示例:

[INFO] ------------------------------------------------------------------------
[INFO] Building Abc2_Master 8.0.0.8-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.3.2:clean (default-cli) @ abc-2-root ---
[INFO] Cleaning up after release...
[INFO]
[INFO] --- maven-release-plugin:2.3.2:prepare (default-cli) @ abc-2-root ---
[INFO] Verifying that there are no local modifications...
[INFO]   ignoring changes on: **\release.properties, **\pom.xml.next, **\pom.xml.releaseBackup, **\pom.xml.backup, **\pom.xml.branch, **\pom.xml.tag
[INFO] Executing: cmd.exe /X /C "svn --non-interactive status"
[INFO] Working directory: C:\Users\joshua.nell\Documents\00-CBA-Main\workspaces\clean_checkout\CreateJar\R8.0\PROD_Release_8_0
[INFO] Checking dependencies and plugins for snapshots ...
There are still some remaining snapshot dependencies.
: Do you want to resolve them now? (yes/no) no: : yes
Dependency type to resolve,: specify the selection number ( 0:All 1:Project Dependencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 0
Dependency 'gov.xxxx.abc.api:Abc2_Common_Model' is a snapshot (8.0.0.8-SNAPSHOT)
: Which release version should it be set to? 8.0.0.8: :
What version should the dependency be reset to for development? 8.0.0.8: :
There are still some remaining snapshot dependencies.
: Do you want to resolve them now? (yes/no) no: : yes
Dependency type to resolve,: specify the selection number ( 0:All 1:Project Dependencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 0
Dependency 'gov.xxxx.abc.api:Abc2_Common_Model' is a snapshot (8.0.0.8-SNAPSHOT)
: Which release version should it be set to? 8.0.0.8: :
What version should the dependency be reset to for development? 8.0.0.8: :
There are still some remaining snapshot dependencies.
: Do you want to resolve them now? (yes/no) no: : yes
Dependency type to resolve,: specify the selection number ( 0:All 1:Project Dependencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 0
Dependency 'gov.xxxx.abc.api:Abc2_Common_Model' is a snapshot (8.0.0.8-SNAPSHOT)
: Which release version should it be set to? 8.0.0.8: :
What version should the dependency be reset to for development? 8.0.0.8: :
There are still some remaining snapshot dependencies.
: Do you want to resolve them now? (yes/no) no: : yes
Dependency type to resolve,: specify the selection number ( 0:All 1:Project Dependencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 0
Dependency 'gov.xxxx.abc.api:Abc2_Common_Model' is a snapshot (8.0.0.8-SNAPSHOT)
: Which release version should it be set to? 8.0.0.8: :
What version should the dependency be reset to for development? 8.0.0.8: :
What is the release version for "Abc2_Master"? (com.xxxx.abc2:abc-2-root) 8.0.0.8: :
....

更新

由于人们似乎卡在快照上,我也使用了versions-maven-plugin来处理将其设置为发布版本并递增。

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>versions-maven-plugin</artifactId>
    <version>${maven-version-plugin.ver}</version>
    <configuration>
      <includes>
        <include>gov.xxxx.abc.api:Pts2_Common_Model</include>
      </includes>
      <allowMinorUpdates>true</allowMinorUpdates>
    </configuration>
  </plugin>

更新 作为参考,pom.xml中有一个主要的奇怪之处(不允许更改当前版本),这可能是导致需要手动输入的怪异的原因。

  <plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <version>${maven-jar-plugin.ver}</version>
    <executions>
      <execution>
        <goals>
          <goal>jar</goal>
        </goals>
        <configuration>
          <includes>
            <include>gov/xxxx/abc/api/common/models/**</include>
            <include>gov/xxxx/abc/api/common/cache/**</include>
            <include>gov/xxxx/abc/api/intra/models/**</include>
            <include>gov/xxxx/abc/api/models/**</include>
            <include>gov/xxxx/abc/api/webtools/**</include>
            <include>gov/xxxx/abc/api/common/Utils*</include>
            <include>gov/xxxx/abc/api/common/PTSConstants*</include>
            <include>gov/xxxx/abc/api/sms/Sms*</include>
            <include>gov/xxxx/abc/api/sms/dao/DebugLoggingStoredProc*</include>
            <include>gov/xxxx/abc/api/sms/util/**</include>
            <include>gov/xxxx/abc/api/sms/outbound/**</include>
            <include>gov/xxxx/abc/api/sms/dao/models/**</include>
            <include>com/xxxx/ent/esb/ems/sms/**</include>
            <include>com/xxxx/ent/esb/ems/sms/outbound/**</include>
            <include>com/xxxx/ent/esb/ems/sms/services/**</include>
            <include>com/xxxx/accessmgt/ems/sms/**</include>
            <include>com/xxxx/ent/esb/repository/**</include>
            <include>gov/xxxx/abc/api/monitor/**</include>
            <include>gov/xxxx/abc/api/monitor/dao/**</include>
            <include>gov/xxxx/abc/api/statistics/util/**</include>
          </includes>
          <finalName>Pts2_Common_Model-${project.version}</finalName>
        </configuration>
      </execution>
    </executions>
  </plugin>

1 个答案:

答案 0 :(得分:1)

&#39;无&#39;和&#39; 1&#39;默认值是硬编码的

这里是来自maven-release-manager&#34; CheckDependencySnapshotsPhase&#34;

的代码
private void resolveSnapshots( Set<Artifact> projectDependencies,Set<Artifact> reportDependencies, Set<Artifact> extensionDependencies, Set<Artifact> pluginDependencies, ReleaseDescriptor releaseDescriptor ) throws ReleaseExecutionException
{
    try
    {
        prompter.showMessage( RESOLVE_SNAPSHOT_MESSAGE );
        String result =
            prompter.prompt( RESOLVE_SNAPSHOT_PROMPT, Arrays.asList( "yes", "no" ), "no" );

        if ( result.toLowerCase( Locale.ENGLISH ).startsWith( "y" ) )
        {
            Map<String, Map<String, String>> resolvedSnapshots = null;
            prompter.showMessage( RESOLVE_SNAPSHOT_TYPE_MESSAGE );
            result = prompter.prompt( RESOLVE_SNAPSHOT_TYPE_PROMPT,
                                      Arrays.asList( "0", "1", "2", "3" ), "1" );

要覆盖这些值,您必须按以下方式更改代码:

Arrays.asList( "yes", "no" ), "no" ); --> Arrays.asList( "yes", "no" ), "yes" );

Arrays.asList( "0", "1", "2", "3" ), "1" ); --> Arrays.asList( "0", "1", "2", "3" ), "0" );

的svn: http://svn.apache.org/repos/asf/maven/release/tags/maven-release-2.5.3/maven-release-manager