无法放置 https://oss.sonatype.org/service/local/staging/deploy/maven2/bom-plugin/

问题描述

我正在尝试将我的第一个 Gradle 插件发布到 maven central (sonatype),但我收到以下错误

> Failed to publish publication 'bom-pluginPluginMarkerMaven' to repository 'maven'
   > Could not PUT 'https://oss.sonatype.org/service/local/staging/deploy/maven2/bom-plugin/bom-plugin.gradle.plugin/0.3/bom-plugin.gradle.plugin-0.3.pom'.
Received status code 400 from server: Bad Request

似乎由于某种原因,发布任务试图在 sonatype 存储库的根目录下发布我的插件,当我执行任务 publishToMavenLocal 时它起作用,但是,在我的 m2 中发布了这个奇怪的文件本地:/.m2/repository/bom-plugin/bom-plugin.gradle.plugin 并在此处发布插件/.m2/repository/dev/thiagosouto/bom-plugin/0.3/

我认为这是导致问题的原因,但我没有解决此问题的任何线索。

我的 build.gradle.kts 文件

plugins {
    java
    `java-gradle-plugin`
    `kotlin-dsl`
    `maven-publish`
    signing
    kotlin("jvm") version "1.4.31"
    id("com.gradle.plugin-publish") version "0.13.0"
}

group  "dev.thiagosouto"
version "0.3"

buildscript {
    repositories {
        mavenCentral()
        maven {
            url = uri("https://plugins.gradle.org/m2/")
        }
    }
}

gradlePlugin {
    plugins {
        create("bom-plugin") {
            id = "bom-plugin"
            implementationClass = "dev.thiagosouto.plugins.bom.BomPlugin"
        }
    }

}

repositories {
    mavenCentral()
}

dependencies {
    implementation("com.squareup:kotlinpoet:1.7.2")

    testImplementation("com.google.truth:truth:1.1.2")
    testImplementation("junit:junit:4.13.2")
    testImplementation("dev.thiagosouto:file-butler:0.3.0")
}

sourceSets.main {
    java.srcDirs("src/main/kotlin")
}

sourceSets.test {
    java.srcDirs("src/test/kotlin")
}

tasks.withType<GenerateModuleMetadata> {
    enabled = false
}

publishing {
    val ossrhUsername: String by project
    val ossrhPassword: String by project

    repositories {
        maven(url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
            credentials {
                username = ossrhUsername
                password = ossrhPassword
            }
        }
    }
    publications {
        group = "dev.thiagosouto"
        version = "0.3"
        create<MavenPublication>("mavenJava") {
            pom {
                name.set("bom-plugin")
                description.set("A library to help apply tdd through help functions");
                url.set("https://thiagosouto.dev")

                licenses {
                    license {
                        name.set("The Apache License,Version 2.0")
                        url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
                    }
                }

                scm {
                    connection.set("scm:git:git://github.com/othiagosouto/bom-plugin.git/")
                    developerConnection.set("scm:git:ssh://github.com:othiagosouto/bom-plugin.git")
                    url.set("https://github.com/othiagosouto/bom-plugin")
                }
                developers {
                    developer {
                        id.set("othiagosouto")
                        name.set("Thiago Souto silva de barros Santos")
                        email.set("soutosss@gmail.com")
                    }
                }
            }
        }
    }
}
afterEvaluate {
    signing {
        sign(publishing.publications["mavenJava"])
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)