2016-02-08 55 views
2

我目前正在使用Maven 3.3.3,其中mvn.bat文件已被刪除。運行Maven的建議和唯一方法是通過mvn.cmd文件。指定Maven Archetype插件的依賴版本

我正在使用調用maven-invoker插件進行某些操作的自定義原型。 Note that the invoker plugin is a dependency of the Maven archetype plugin

archetype:generate,調用被調用,並拋出一個錯誤:

Error configuring command-line. Reason: Maven executable not found at: <MAVEN_PATH>\bin\mvn.bat

這個問題似乎已得到修復與調用者的2.2版,但maven-archetype-plugin的最後一個版本仍然使用它的舊版本。

如何在我的原型的POM中指定要使用的調用者插件的版本?

現在,我試圖通過將此代碼添加到原型的POM文件中來配置插件,但它沒有效果,並且沒有修復錯誤。

<plugin> 
    <groupId>org.apache.maven.archetype</groupId> 
    <artifactId>maven-archetype</artifactId> 
    <version>2.4</version> 
    <dependencies> 
     <dependency> 
      <groupId>org.apache.maven.shared</groupId> 
      <artifactId>maven-invoker</artifactId> 
      <version>2.2</version> 
     </dependency> 
    </dependencies> 
</plugin> 

編輯1: 這裏的過濾堆棧跟蹤。

[INFO] Invoking post-archetype-generation goals: com.company.my-custom-maven-plugin:uuid-generator 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 2.777 s 
[INFO] Finished at: 2016-02-08T15:09:19+01:00 
[INFO] Final Memory: 18M/210M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate (default-cli) on project standalone-pom: Cannot run additions goals. Error configuring command-line. Reason: Maven executable not found at: <MAVEN_PATH>\bin\mvn.bat -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate (default-cli) on project standalone-pom: Cannot run additions goals. 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) 
    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:116) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) 
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) 
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) 
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) 
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) 
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot run additions goals. 
    at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.invokePostArchetypeGenerationGoals(CreateProjectFromArchetypeMojo.java:241) 
    at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:219) 
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) 
    ... 20 more 
Caused by: org.apache.maven.shared.invoker.MavenInvocationException: Error configuring command-line. Reason: Maven executable not found at: <MAVEN_PATH>\bin\mvn.bat 
    at org.apache.maven.shared.invoker.DefaultInvoker.execute(DefaultInvoker.java:105) 
    at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.invokePostArchetypeGenerationGoals(CreateProjectFromArchetypeMojo.java:237) 
    ... 23 more 
Caused by: org.apache.maven.shared.invoker.CommandLineConfigurationException: Maven executable not found at: <MAVEN_PATH>\bin\mvn.bat 
    at org.apache.maven.shared.invoker.MavenCommandLineBuilder.findMavenExecutable(MavenCommandLineBuilder.java:597) 
    at org.apache.maven.shared.invoker.MavenCommandLineBuilder.build(MavenCommandLineBuilder.java:68) 
    at org.apache.maven.shared.invoker.DefaultInvoker.execute(DefaultInvoker.java:101) 
    ... 24 more 
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 

回答

4

這是Maven Archetype插件的一個錯誤:在JIRA問題是ARCHETYPE-488。它會影響插件的所有版本,其版本號爲≤ 2.4,並使用版本3.0.0進行解析。

在鏈接的問題引用Jörg Hohwiller(08日-JAN-2016 13:47):

是否有它的解決方法?

是的。只需在MAVEN_HOME/bin中創建一個名爲「mvn.bat」的「mvn.cmd」副本。

因此,使用2.4或更早版本的可能解決方法是僅使用其他名稱複製mvn可執行文件。

+0

謝謝!我們實際上已經嘗試過了,它工作。但是我們需要分發這個archteype,並且我們不能在客戶端的計算機上運行這些更改。還會有其他什麼嗎? –

+0

@Rems恐怕問題來自客戶端本身。因此,我們需要等待解決該錯誤或修改客戶端計算機。 (請注意,在關聯的問題中,有人嘗試過你的方法,但同樣的錯誤也失敗了) – Tunaki

+0

傷心:( Sooo,我想我在原型的POM中添加的''部分永遠不會被使用,因爲執行'archetype:生成'我實際上並沒有在POM上運行Maven,所以這些設置在運行的生命週期中不被使用? –

2

通過@Tunaki的錯誤引用已修復(張貼供參考)和pom.xml需求:

<plugin> 
    <artifactId>maven-archetype-plugin</artifactId> 
    <version>2.4</version> 
    <dependencies> 
    <dependency> 
      <groupId>org.apache.maven.shared</groupId> 
      <artifactId>maven-invoker</artifactId> 
      <version>2.2</version> 
    </dependency> 
    </dependencies> 
</plugin>