I have a static xml file that I want to publish to a Maven repository (my local Maven repo for now) from Gradle using the maven-publish plugin.
build.gradle looks like this:
apply plugin: 'maven-publish'
group 'com.example.gradletest'
version '1.0-SNAPSHOT'
publishing {
publications {
beta(MavenPublication) {
artifactId 'feature-file'
artifact 'src/main/resources/features.xml'
}
}
}
This works, but I would like to add a classifier too, where should I define that? https://docs.gradle.org/current/userguide/publishing_maven.html says in section 68.2.2 that it should be possible to do:
publishing {
publications {
beta(MavenPublication) {
artifactId 'feature-file'
artifact ('src/main/resources/features.xml') {
classifier 'features'
}
}
}
}
but then I get this error:
A problem occurred configuring root project 'testapplication'.
Exception thrown while executing model rule: org.gradle.api.publish.plugins.PublishingPlugin$Rules#publishing(org.gradle.api.plugins.ExtensionContainer) No signature of method: java.io.File.call() is applicable for argument types: (build_101arjzoe908rdkh5aikrn6bt$_run_closure5_closure16_closure19_closure20) values: [build_101arjzoe908rdkh5aikrn6bt$_run_closure5_closure16_closure19_closure20@2aa7399c] Possible solutions: wait(), any(), wait(long), each(groovy.lang.Closure), any(groovy.lang.Closure), list()
Using the below solution will correctly add the classifier, but will also change the packaging in the pom.xml from <packaging>xml</packaging> to <packaging>pom</packaging>. I don't want that.
publishing {
publications {
beta(MavenPublication) {
artifactId 'feature-file'
artifact source: 'src/main/resources/features.xml', classifier: 'features'
}
}
}
Use the map syntax as specified here.
publishing {
publications {
beta(MavenPublication) {
artifactId 'feature-file'
artifact source: 'src/main/resources/features.xml', classifier: 'features'
}
}
}
Adding pom { packaging 'xml' }
works for me (gradle 3.2.1)
publishing {
publications {
beta(MavenPublication) {
artifactId 'feature-file'
artifact source: 'src/main/resources/features.xml', classifier: 'features'
pom { packaging 'xml' }
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With