Last active
June 26, 2024 02:44
-
-
Save rayworks/e1dbe5176df7d60b184f839d48a7bfd7 to your computer and use it in GitHub Desktop.
The script to deploy Android aar files to maven repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'maven-publish' | |
// https://developer.android.google.cn/studio/build/maven-publish-plugin | |
// Because the components are created only during the afterEvaluate phase, you must | |
// configure your publications using the afterEvaluate() lifecycle method. | |
afterEvaluate { | |
publishing { | |
publications { | |
AgoraPub(MavenPublication) { | |
groupId = GROUP_ID | |
artifactId = ARTIFACT_ID | |
version = VERSION | |
// https://stackoverflow.com/questions/55864101/no-longer-able-to-use-bundlereleaseaar-in-mavenpublication | |
artifact bundleReleaseAar | |
//artifact sourcesJar | |
//artifact packageJavadoc | |
pom.withXml { | |
def dependenciesNode = asNode().appendNode("dependencies") | |
configurations.implementation.allDependencies.forEach() { | |
Dependency dependency -> | |
if (dependency.version != "unspecified" && dependency.name != "unspecified") { | |
def dependencyNode = dependenciesNode.appendNode('dependency') | |
dependencyNode.appendNode('groupId', dependency.group) | |
dependencyNode.appendNode('artifactId', dependency.name) | |
dependencyNode.appendNode('version', dependency.version) | |
} else { | |
println(">>> [WARN] Excluded module: " + dependency.group + ":" + dependency.name) | |
} | |
} | |
} | |
} | |
} | |
repositories { | |
maven { | |
url = VERSION.contains("SNAPSHOT") ? MAVEN_REPO_SNAPSHOT_URL : MAVEN_REPO_RELEASE_URL | |
println(">>> MAVEN_REPO : " + url) | |
credentials { | |
username USERNAME | |
password PASSWORD | |
} | |
if (PASSWORD != null) { | |
println("USERNAME: " + USERNAME + ", PASSWORD: " + PASSWORD.substring(0, 1) + "***") | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
exec
./gradlew publishToMavenLocal
to deploy library to local repoexec
./gradlew publish
to deploy library to remote repo