When I use the gradle plug-in maven pbulish
to upload jars to the Maven repository, how can I exclude some dependencies in the gradle project?
My gradle. Build file is as follows:
dependencies {
compile project(":frame:f_frame");
compile project(":p_AppComm");
compile project(":p_Systemaudit");
}
publishing {
repositories {
maven {
url = 'http://XXX/repository/infra_test_snapshot/'
credentials {
username = 'admin'
password = 'admin'
}
}
}
publications {
maven(MavenPublication) {
groupId "AAAAA"
artifactId "BBBBB"
version "CCCCC"
from components.java
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.implementation.allDependencies.each {
if (it.name != null && !"unspecified".equals(it.name) && !"f_frame".equals(it.name) && !"p_AppComm".equals(it.name)) {
println it.toString()
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
dependencyNode.appendNode('scope', 'implementation')
}
}
}
artifact sourceJar {
classifier "sources"
}
}
}
}
How can I modify the contents of the pom.withxml
function to remove the f_frame
and p_Appcomm
in the POM file dependency in the Maven repository.