TeamCity插件开发maven失败

TeamCity plugin development maven failure

我正在关注 https://confluence.jetbrains.com/display/TCD10/Getting+Started+with+Plugin+Development

的插件开发教程

在第 2 步,当我 运行 命令时:

mvn archetype:generate -DarchetypeRepository=http://download.jetbrains.com/teamcity-repository -DarchetypeArtifactId=teamcity-server-plugin -DarchetypeGroupId=org.jetbrains.teamcity.archetypes -DarchetypeVersion=RELEASE

我收到以下错误:

[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:3.0.0:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:3.0.0:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO] 
[INFO] --- maven-archetype-plugin:3.0.0:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[WARNING] Archetype not found in any catalog. Falling back to central repository (http://repo.maven.apache.org/maven2).
[WARNING] Use -DarchetypeRepository=<your repository> if archetype's repository is elsewhere.
Downloading: http://repo.maven.apache.org/maven2/org/jetbrains/teamcity/archetypes/teamcity-server-plugin/maven-metadata.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.638 s
[INFO] Finished at: 2017-03-14T11:24:41-06:00
[INFO] Final Memory: 14M/185M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.0:generate (default-cli) on project standalone-pom: The desired archetype does not exist (org.jetbrains.teamcity.archetypes:teamcity-server-plugin:RELEASE) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/MojoFailureException

关于如何让它工作的任何想法?

修改%M2_HOME%\conf\settings.xml

中的镜像
<mirrors>
  <mirror>
    <id>google-maven-central</id>
    <name>Google Maven Central</name>
    <url>https://maven-central.storage.googleapis.com</url>
    <mirrorOf>central</mirrorOf>
  </mirror> 
</mirrors> 

此答案发现于:

Maven Archetype 3.0.0 移除了 archetypeRepository 参数,参见https://issues.apache.org/jira/browse/ARCHETYPE-439

因此您必须将远程原型存储库添加到您的 settings.xml 中。转到您的 [users]/.m2 文件夹,create/edit settings.xml 喜欢:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                          https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <profiles>
    <profile>
      <id>teamcity</id>
      <repositories>
        <repository>
          <id>teamcity-repository</id>
          <name>Teamcity Repository</name>
          <url>http://download.jetbrains.com/teamcity-repository</url>
          <layout>default</layout>
        </repository>
      </repositories>          
    </profile>
  </profiles>
</settings>

然后在你的命令行中执行maven

 mvn archetype:generate -P teamcity -DarchetypeArtifactId=teamcity-server-plugin -DarchetypeGroupId=org.jetbrains.teamcity.archetypes -DarchetypeVersion=RELEASE

正确的命令是

mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -DarchetypeRepository=http://download.jetbrains.com/teamcity-repository -DarchetypeArtifactId=teamcity-server-plugin -DarchetypeGroupId=org.jetbrains.teamcity.archetypes -DarchetypeVersion=RELEASE

(使用固定版本的原型插件)

文档将相应更新。