Gradle: 5.1.1 User Guide section "Publishing" uses deprecated "classifier" attribute

Created on 16 Jan 2019  ·  3Comments  ·  Source: gradle/gradle

The code sample in 5.1.1 User Guide section "Publishing", sub-section Adding custom artifacts to a publication, uses the deprecated Jar task attribute "classifier".

Expected Behavior

The code sample should use the currently recommended, non-deprecated way of adding custom artifacts to a publication.

Current Behavior

The code sample uses the deprecated Jar task attribute "classifier":

task sourcesJar(type: Jar) {
    classifier = 'sources'
    from sourceSets.main.allJava
}

task javadocJar(type: Jar) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

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

            artifact sourcesJar
            artifact javadocJar
        }
    }
}

Most helpful comment

I've recently upgraded to 5.1.1 and started getting deprecation warnings regarding this issue.

This issue is, notably, the only reference I've been able to find to this deprecation and I cannot, for the life of me, find the _proper_ non-deprecated way to handle this.

I realize that it's outside of the scope of your issue, but do you think you could elaborate on the updated method? I'd appreciate it. <3

EDIT:

Embarrassingly, I discovered an alternative, non-deprecated method soon after posting this. I'm not sure if it's the recommended or intended way, but it works.

Rather than the typical classifier = "sources" that we've all grown used to, we're supposed to use the archiveClassifier which returns a Property<String>, meaning your method looks as follows.

classifier = "sources"

To:

archiveClassifier.set("sources")

All 3 comments

I've recently upgraded to 5.1.1 and started getting deprecation warnings regarding this issue.

This issue is, notably, the only reference I've been able to find to this deprecation and I cannot, for the life of me, find the _proper_ non-deprecated way to handle this.

I realize that it's outside of the scope of your issue, but do you think you could elaborate on the updated method? I'd appreciate it. <3

EDIT:

Embarrassingly, I discovered an alternative, non-deprecated method soon after posting this. I'm not sure if it's the recommended or intended way, but it works.

Rather than the typical classifier = "sources" that we've all grown used to, we're supposed to use the archiveClassifier which returns a Property<String>, meaning your method looks as follows.

classifier = "sources"

To:

archiveClassifier.set("sources")

Thanks for noticing this. This is fixed on release and will be in 5.2

what pull request resolved this issue?

Was this page helpful?
0 / 5 - 0 ratings