Java 如何指定Git remote';使用标准SSH语法的Maven发布插件的URL? 直奔具体问题
如果我在Java 如何指定Git remote';使用标准SSH语法的Maven发布插件的URL? 直奔具体问题,java,git,maven,ssh,Java,Git,Maven,Ssh,如果我在pom.xml <scm> <developerConnection>scm:git:username@hostname:/absolute/path/to/repo.git</developerConnection> </scm> 然后我得到一个错误,比如 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepar
pom.xml
<scm>
<developerConnection>scm:git:username@hostname:/absolute/path/to/repo.git</developerConnection>
</scm>
然后我得到一个错误,比如
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project maven_dependencies: Unable to tag SCM
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] fatal: 'hostname/absolute/path/to/repo.git' does not appear to be a git repository
[ERROR] fatal: Could not read from remote repository.
注意:在pom.xml
中的hostname
和/absolute/path/to/repo.git
之间的分号在错误输出中消失了
其他细节
绝对路径与相对路径
实际上,我能够在SSH URL中使用具有非绝对路径的Git(相对于usernname
的主目录)。例如,使用
scm:git:username@hostname:path/to/repo.git
而不是
scm:git:username@hostname:/home/username/path/to/repo.git
工作完美
官方文件
我读过Git,因为标准的类似SSH的URL至少在相对路径的情况下已经起作用了,所以我故意忽略了它奇怪的URL规范:
scm:git:ssh://username@hostname[:port]/~/path/to/repository
违背并忽略此语法的原因是无法暗示相对于用户家的路径(如果路径不以/
开头,SSH默认会这样做)。此外,标准SSH-like-URL的冒号:
在hostname
之后是hostname
和路径(不是端口号)之间的分隔符
这意味着SSH的Git URL必须针对Maven发布插件进行专门的重新格式化-真是令人头痛 展望未来,我必须遵守文档中的规范,并让所有将要查看此类URL的人感到困惑。所以,它已经起作用了。问题更多的是关于使用标准SSH-like URL的替代方案。
scm:git:ssh://username@hostname[:port]/~/path/to/repository