guru_lib/guru_checker/GuruChecker/maven-publish.gradle

69 lines
2.9 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

publishing { // Repositories *to* which Gradle can publish artifacts
repositories { RepositoryHandler handler ->
handler.mavenLocal()
maven {
url "$buildDir/repo" // change to point to your repo, e.g. http://my.org/repo
}
}
publications { PublicationContainer publication ->
// Creates a Maven publication called "myPublication".
maven(MavenPublication) {
groupId 'guru.core.checker'
artifactId 'GuruChecker'
version '1.0.0' // Your package version
// artifact publishArtifact //Example: *./target/myJavaClasses.jar*
// artifact "build/outputs/aar/aar-test-release.aar"//aar包的目录
afterEvaluate { artifact(tasks.getByName("bundleReleaseAar")) } // 方式一生成aar包
//带上依赖 ,否则会报错
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
def scopes = []
if (configurations.hasProperty("api")) {
scopes.add(configurations.api)
}
if (configurations.hasProperty("implementation")) {
scopes.add(configurations.implementation)
}
if (configurations.hasProperty("debugImplementation")) {
scopes.add(configurations.debugImplementation)
}
if (configurations.hasProperty("releaseImplementation")) {
scopes.add(configurations.releaseImplementation)
}
// if (project.ext.targetType != "jar") {
// scopes.add(configurations.provided)
// }
scopes.each { scope ->
scope.allDependencies.each {
if (it instanceof ModuleDependency) {
boolean isTransitive = ((ModuleDependency) it).transitive
if (!isTransitive) {
println "<<<< not transitive dependency: [${it.group}, ${it.name}, ${it.version}]"
return
}
}
if (it.group == "${project.rootProject.name}.libs" || it.version == 'unspecified') {
return
}
if (it.group && it.name && it.version) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
dependencyNode.appendNode('scope', scope.name)
}
}
}
}
}
}
}