Maven SCM 插件:Git SSH 提供程序未找到

17

我在使用Maven SCM插件与Git时遇到了问题。由于插件无法找到提供程序,我无法使插件正常工作。当我运行mvn scm:tag时,它会给我以下错误:

  

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-scm-plugin:1.9:tag    (default-cli) on project hello-world-service-minimal: Cannot run tag command :   无法加载scm提供程序。没有这样的提供程序:'git:ssh://git@git-eng.REDACTED.com'。   。 -> [Help 1]

我的pom.xml如下所示:

<project>
  <modelVersion>4.0.0</modelVersion>

  <groupId>net.REDACTED</groupId>
  <artifactId>hello-world-service-minimal</artifactId>
  <version>1.0.13</version>
  <packaging>pom</packaging>

  <name>hello-world-service</name>

  <properties>
     <lang.java.source>1.7</lang.java.source>
     <lang.java.target>1.7</lang.java.target>

    <dep.junit>4.11</dep.junit>
  </properties>

  <scm>
     <developerConnection>scm:git:ssh://git@git-eng.REDACTED.com|PROJECT_NAME/hello-world-service-minimal.git</developerConnection>
     <url>scm:git:http://git-eng.REDACTED.com/PROJECT_NAME/hello-world-service-minimal/tree/master</url>
  </scm>

  <distributionManagement>
     <repository>
        <id>dev.release</id>
        <url>file:${project.build.directory}/repository/</url>
     </repository>
  </distributionManagement>

  <build>
      <plugins>
          <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>versions-maven-plugin</artifactId>
              <version>2.1</version>
          </plugin>
          <plugin>
              <artifactId>maven-scm-plugin</artifactId>
              <version>1.9</version>
              <configuration>
                  <tag>${project.artifactId}-${project.version}</tag>
              </configuration>
          </plugin>
      </plugins>
  </build>
</project>

有人知道该如何修复这个问题吗?这让我疯了。我完全想不出我做错了什么。

1个回答

28

<url>标签用于常规可浏览的 URL。您需要一个<connection>标签(<connection> 用于读取访问,<developerConnection>用于写入访问):

<scm>
  <connection>scm:git:ssh://git@git-eng.REDACTED.com|PROJECT_NAME/hello-world-service-minimal.git</connection>
  <developerConnection>scm:git:ssh://git@git-eng.REDACTED.com|PROJECT_NAME/hello-world-service-minimal.git</developerConnection>
  <url>http://git-eng.REDACTED.com/PROJECT_NAME/hello-world-service-minimal/tree/master</url>
</scm>

有关更多信息,请参阅Maven POM参考文档


1
另外,我不确定管道符号(|)是怎么回事,也许应该使用斜杠(/)? - Adam Batkin
1
它仍然无法使用<connection>标签。管道符是因为这里的文档:http://maven.apache.org/scm/git.html,该文档建议将冒号替换为|... Git-Lab在第一个斜杠之前使用:<project name>。 - Philip Lombardi
5
管道符仅用于替换冒号,当一个软件配置管理路径包含例如Windows驱动器盘符时,因为Git插件假定冒号后面是TCP端口。将其替换为斜杠,并查看是否出现与上述错误相同或不同的错误。 - Adam Batkin
1
搞定了!哇,非常感谢你。这个问题一直困扰我整个晚上了。 - Philip Lombardi
3
对于GitLab,请注意Adam Batkin上面所述的“用斜杠替换”的说明。使用管道进行替换会导致我出现“未找到SCM提供程序”的错误。使用斜杠让我基本上可以工作了。 - demaniak

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接