简体   繁体   English

Gradle,使用gpg进行多项目签名。 访问“扩展”扩展名后无法配置

[英]Gradle, multiproject signing with gpg. Cannot configure the 'publishing' extension after it has been accessed

I have multiproject gradle configuration. 我有多项目gradle配置。 I'd like to sign my artifacts before publishing. 我想在发布之前先签名。 I do the following: 我执行以下操作:

allprojects {
    apply plugin: 'java'
    sourceCompatibility = 1.10
}

subprojects {
    group 'com.example'
    version '1.0.0'

    apply plugin: 'maven-publish'
    apply plugin: 'signing'

    repositories {
        mavenLocal()
        mavenCentral()
    }

    dependencies {
        ...
    }

    test {
        useJUnitPlatform()
    }

    publishing {
        publications {
            mavenJava(MavenPublication) {
                from components.java
            }
        }

        repositories {
            mavenLocal()
        }
    }

    signing {
        sign publishing.publications.mavenJava
    }

}

I get the following error: 我收到以下错误:

Cannot configure the 'publishing' extension after it has been accessed. 访问“扩展”扩展名后,无法对其进行配置。

I have no idea what does it mean. 我不知道这是什么意思。 I use gradle 4.8. 我使用gradle 4.8。 I have 3 subprojects there. 我在那里有3个子项目。

I ran into the same issue with Gradle 4.9 我在Gradle 4.9中遇到了相同的问题

Apply the signing plugin before the maven-publish. 在Maven发布之前应用签名插件。 Hope it helps. 希望能帮助到你。

apply plugin: 'signing'
apply plugin: 'maven-publish'

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

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