[英]Gradle is publishing source and Javadoc JARs, but not source JAR
我是 Gradle 的新手,正在嘗試將一個簡單的項目發布到 Maven Central。 我的build.gradle
腳本與他們文檔中的示例幾乎相同,但我的主要/編譯的 JAR 沒有被上傳。 源代碼 JAR、Javadoc JAR 等正在上傳,但未編譯。
當通過publishToMavenLocal
發布本地時,一切都按預期工作。 我會注意到我使用的是版本6.0.1
並使用publishMavenJavaPublicationToMavenRepository
發布到 Central。
我錯過了什么? 如何將編譯后的 JARs 發送到 Central?
更新:我剛剛意識到 POM 也沒有被上傳。
這是完整的build.gradle
:
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.0.1'
implementation 'com.squareup.moshi:moshi:1.9.1'
implementation 'com.squareup.moshi:moshi-adapters:1.9.1'
implementation 'com.google.guava:guava:28.0-jre'
api 'org.apache.commons:commons-math3:3.6.1'
testImplementation 'junit:junit:4.12'
}
group = 'com.acme'
version = '0.0.1-SNAPSHOT'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'thttpd'
from components.java
pom {
name = 'thttpd'
licenses {
license {
name = 'The MIT License (MIT)'
url = 'https://opensource.org/licenses/MIT'
}
}
scm {
connection = 'scm:git:https://acme.com'
developerConnection = 'scm:git:https://acme.com'
url = 'https://acme.com'
}
}
}
}
repositories {
// Maven Central
maven {
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
url = isReleaseVersion ? releasesRepoUrl : snapshotsRepoUrl
credentials {
username = nexusUsername
password = nexusPassword
}
}
}
}
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
if( required ) {
sign publishing.publications.mavenJava
}
}
我遇到了與 Alexis 上面提到的相同的問題,在 GitHub Packages web UI 上沒有顯示源和 java-doc。 但是在 s01.oss.sonatype.org 上我能夠看到它們。 使用 Gradle 6.7
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.