简体   繁体   English

Gradle 正在发布源代码和 Javadoc JARs,但不是源代码 JAR

[英]Gradle is publishing source and Javadoc JARs, but not source JAR

I'm new to Gradle and attempting to publish a simple project to Maven Central.我是 Gradle 的新手,正在尝试将一个简单的项目发布到 Maven Central。 My build.gradle script is nearly identical to the example in their documentation but my primary/compiled JAR is not being uploaded.我的build.gradle脚本与他们文档中的示例几乎相同,但我的主要/编译的 JAR 没有被上传。 Source JAR, Javadoc JAR, etc. are uploading fine but not the compiled one.源代码 JAR、Javadoc JAR 等正在上传,但未编译。

When publishing local via publishToMavenLocal everything works as expected.当通过publishToMavenLocal发布本地时,一切都按预期工作。 I'll note that I'm using version 6.0.1 and using publishMavenJavaPublicationToMavenRepository to publish to Central.我会注意到我使用的是版本6.0.1并使用publishMavenJavaPublicationToMavenRepository发布到 Central。

What am I missing?我错过了什么? How can I get my compiled JARs to Central?如何将编译后的 JARs 发送到 Central?

Update: I just realized that the POM isn't being uploaded either.更新:我刚刚意识到 POM 也没有被上传。

Here is the complete build.gradle :这是完整的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
    }
}

I had the same issue that Alexis mentions above, on the GitHub Packages web UI the sources and java-doc where not showing up.我遇到了与 Alexis 上面提到的相同的问题,在 GitHub Packages web UI 上没有显示源和 java-doc。 But on s01.oss.sonatype.org I was able to see them.但是在 s01.oss.sonatype.org 上我能够看到它们。 Using Gradle 6.7使用 Gradle 6.7

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM