I am using gradle 4.3.1
I have dependencies in scope compileOnly
when I publish to maven I see that these dependencies are not in the pom file.
I would like to map them to provided
scope of maven.
How can I do that?
I am using gradle 4.3.1
I have dependencies in scope compileOnly
when I publish to maven I see that these dependencies are not in the pom file.
I would like to map them to provided
scope of maven.
How can I do that?
I'm not aware of any clean solution (maven-publish plugin is still incubating), so I took inspiration from https://stackoverflow.com/a/25201395/2838501 and have a dirty solution:
publications {
mavenJava(MavenPublication) {
from components.java
pom.withXml {
project.configurations.compileOnly.allDependencies.each { dep ->
asNode().dependencies[0].appendNode('dependency').with {
it.appendNode('groupId', dep.group)
it.appendNode('artifactId', dep.name)
it.appendNode('version', dep.version)
it.appendNode('scope', 'provided')
}
}
}
}
}