在准备命令期间覆盖 Maven 依赖项解析的默认值
Override defaults for Maven's dependancy resolution during prepare command
我希望能够 运行 maven 准备 w/out 需要用户输入。
目前,我必须手动输入 'yes' 和 '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[=11=]-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>
'no' 和“1”默认值是硬编码的
这里是 maven-release-manager 的代码"CheckDependencySnapshotsPhase"
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
我希望能够 运行 maven 准备 w/out 需要用户输入。
目前,我必须手动输入 'yes' 和 '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[=11=]-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>
'no' 和“1”默认值是硬编码的
这里是 maven-release-manager 的代码"CheckDependencySnapshotsPhase"
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