2016-03-16 55 views
1

我希望能夠運行Maven準備無需用戶輸入。
目前,我必須手動鍵入'yes'和'0'才能正確解決每個項目的依賴關係。在準備命令期間覆蓋Maven的依賴性解析的默認值



更新:由於「不」和「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" 

插件:行家離型插件
目標:準備所述手動輸入的

實施例:

 
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: : 
.... 

更新:

由於人似乎被卡住的快照,我也是用的版本,Maven的插件來處理這個設置爲一個發佈版本並遞增。

<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

所以,你希望做一個非交互的釋放,但與哈克偏差。這裏有類似的問題:http://stackoverflow.com/q/8449579/4807777看看它的答案給出的一些風險。否則,目標版本的版本Maven插件:use-latest-releases可能會有所幫助。 –

+0

這不是關於發行版本。那些不需要從默認值改變。這是關於'你現在想解決它們嗎? (是/否)'和'指定需要不同默認值的選擇號(0:所有1:項目依賴2:插件3:報告4:擴展):(0/1/2/3)'輸入。 – ScrappyDev

+0

我從來沒有測試過這個,但是你可以用release.properties配置release插件:https://maven.apache.org/maven-release/maven-release-plugin/examples/non-interactive-release.html。我不確定是否有一個存儲「選擇編號」的字段,我將在稍後測試,但這可能是一種方法。 – Tunaki

回答

1

「不」和「1」的默認值是硬編碼

這裏從行家釋放經理代碼「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

+0

我_am_使用versions-maven-plugin。但正如我所說,這不是關於快照版本。版本控制工作正常。我試圖覆蓋這個問題_BEFORE_它詢問版本控制。 – ScrappyDev

+0

那麼你是否說要解決這個問題的唯一方法是創建我自己的maven插件的自定義版本? – ScrappyDev

+0

正如你可以看到字符串的默認答案是「硬編碼」,所以我沒有看到任何其他方式。 –