我有一个使用SBT的开源Scala项目,我想将我的库发布到Maven.我该怎么做?
我正在尝试将我的 Java 库发布到 Maven Central。其中一部分涉及使用signinggradle 插件对工件进行签名。我需要在不使用密钥环文件作为文档的情况下对其进行签名,因为我无法提供对密钥环文件的 CI 安全访问。
但是,当我这样做时,我的构建失败了:
FAILURE: Build failed with an exception.
* What went wrong:
Could not evaluate onlyIf predicate for task ':signArchives'.
> Could not read PGP secret key
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?我认为这与我的GPG_SIGNING_KEY. 我使用了响应中的完整私钥gpg --list-secret-keys --keyid-format LONG。这不正确吗?
我的 build.gradle
apply plugin: 'java'
apply plugin: 'signing'
apply plugin: 'maven'
apply from: 'publish.gradle'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
testCompile 'junit:junit:4.11'
} …Run Code Online (Sandbox Code Playgroud) 我想,需要一些传递来向Maven Central存储库提交工件.
我想详细了解哪些要求,要遵循的程序,以及是否有帮助这一过程的教程或指南.
我听说你还需要对这些文物进行数字签名(gpg),有关这方面的一些细节也会受到欢迎.
我想在我的Scala项目Java库中使用Maven Central.在解决此依赖关系时,SBT将附加Scala version到存储库URL,这显然不存在这种格式.我可以以某种方式禁用为此特定工件附加Scala版本吗?
我们有一个maven构建,在亚马逊ec2实例中的jenkins中运行.总构建需要20-30分钟,并且大致每次运行它都会失败,因为它无法从maven中心下载工件.这是日志的失败部分:
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://repo.maven.apache.org/maven2
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repo.maven.apache.org/maven2
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-failsafe-plugin/2.18.1/maven-failsafe-plugin-2.18.1.pom
Feb 03, 2017 3:39:00 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.maven.apache.org:443: …Run Code Online (Sandbox Code Playgroud) 我\xc2\xb4m 在 GitLab 中设置了我的 Maven 项目的 CI,我需要在将 jar 发布到 Maven 中心之前对其进行签名。(https://gitlab.com/awe-team/ade)
\n我使用 gnuPgp 生成密钥对,并将公钥添加到我的 GitLab 配置文件中。
\n我有 GitLab-ci 工作文件夹的私钥副本吗?
\n得到的错误是找不到密钥。
\n[DEBUG] Configuring mojo \'org.apache.maven.plugins:maven-gpg-plugin:1.5:sign\' \n with basic configurator -->\n [DEBUG] (f) ascDirectory = /builds/awe-team/ade/target/gpg\n [DEBUG] (f) defaultKeyring = true\n [DEBUG] (f) interactive = false\n [DEBUG] (f) passphrase = *******\n [DEBUG] (f) skip = false\n [DEBUG] (f) useAgent = true\n [DEBUG] (f) project = MavenProject: com.almis.ade:ade:2.0.5 @ /builds/awe- team/ade/pom.xml\n [DEBUG] -- end configuration --\n [DEBUG] …Run Code Online (Sandbox Code Playgroud) 我有一个 Java 项目,它使用 Gradle 来构建和打包。我的目的是创建发布到 Maven Central 的工件。
第一步,我配置了 Gradle 项目,如文档中的以下示例所示:
https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:complete_example
当我运行时gradle publishToMavenLocal,我会在本地存储库中安装以下文件:
maven-metadata-local.xml
my-library-1.0.2-SNAPSHOT.jar
my-library-1.0.2-SNAPSHOT.jar.asc
my-library-1.0.2-SNAPSHOT-javadoc.jar
my-library-1.0。 2-SNAPSHOT-javadoc.jar.asc
my-library-1.0.2-SNAPSHOT.pom
my-library-1.0.2-SNAPSHOT.pom.asc
my-library-1.0.2-SNAPSHOT-sources.jar
my-library- 1.0.2-SNAPSHOT-sources.jar.asc
文件一切正常。我遇到的唯一问题是未生成校验和文件(md5 和 sha1)。然而,校验和文件是通过 OSS Sonatype 在 Maven Central 上部署工件的必要条件。
如何生成丢失的校验和文件?似乎maven-publish或签名插件没有用于此目的的选项?怎么了?
我正在遵循Maven 插件的这个指南,之后我添加了以下内容:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
Run Code Online (Sandbox Code Playgroud)
maven-release-plugin&2.5.3都是红色的。我正在使用本地 Maven 存储库。我怎样才能更新它?我是否需要安装任何东西才能让IntelliJ找到它?我是 Maven 的新手,希望被指出正确的方向。
由于 Jcenter 即将关闭,我\xe2\x80\x99m 尝试将我的库迁移到 Maven Central。我进行了很多搜索以找到任何可用的脚本,但没有运气。有官方文档,但这就像一个笑话,只是告诉将maven-publish插件添加到 gradle 脚本中,瞧,\xe2\x80\x99s 它。
目前我收到错误:
\nCaused by: org.gradle.api.publish.maven.InvalidMavenPublicationException: Invalid publication \'js\': multiple artifacts with the identical extension and classifier (\'jar\', \'sources\').\nRun Code Online (Sandbox Code Playgroud)\n我的脚本如下所示:
\nplugins {\n id("kotlin-multiplatform")\n id("org.jetbrains.dokka") version "1.4.0-rc"\n `maven-publish`\n signing\n}\n\nkotlin {\n sourceSets {\n jvm()\n js() {\n nodejs()\n browser()\n }\n linuxX64()\n linuxArm64()\n mingwX64()\n macosX64()\n iosArm64()\n iosX64()\n\n val commonMain by getting {\n dependencies {\n }\n }\n val commonTest by getting {\n dependencies {\n implementation(kotlin("test-common"))\n implementation(kotlin("test-annotations-common"))\n }\n }\n\n val jsMain …Run Code Online (Sandbox Code Playgroud) 我有一个 .jar 文件,我想使用 Travis 将其上传到 Maven Central。用于创建帐户的Jira票由我公司发送给Sonatype,并且帐户已创建。
我在 Travis 脚本中上传工件的命令如下:
mvn gpg:sign-and-deploy-file \
-DpomFile=stuff/pom.xml \
-Dfile=_build/java/Packager.jar \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
-DrepositoryId=maven-central \
-Dgpg.passphrase=${mvn_passphrase}
Run Code Online (Sandbox Code Playgroud)
命令的输出以以下错误结束:
Uploading to maven-central: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/cloudblue/connect-sdk/18.0/connect-sdk-18.0.jar
Uploading to maven-central: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/cloudblue/connect-sdk/18.0/connect-sdk-18.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.115 s
[INFO] Finished at: 2020-01-15T16:48:51Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.6:sign-and-deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts: Could not transfer artifact com.cloudblue:connect-sdk:jar:18.0 from/to maven-central (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Transfer failed for https://oss.sonatype.org/service/local/staging/deploy/maven2/com/cloudblue/connect-sdk/18.0/connect-sdk-18.0.jar 400 Bad Request -> [Help …Run Code Online (Sandbox Code Playgroud) maven-central ×10
maven ×6
java ×3
gradle ×2
sbt ×2
scala ×2
sonatype ×2
amazon-ec2 ×1
artifacts ×1
gitlab-ci ×1
gnupg ×1
jenkins ×1
kotlin ×1
maven-plugin ×1
open-source ×1
pgp ×1
release ×1
repository ×1
sbt-release ×1