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".
The code sample should use the currently recommended, non-deprecated way of adding custom artifacts to a publication.
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
}
}
}
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?
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 thearchiveClassifier
which returns aProperty<String>
, meaning your method looks as follows.To: