Skip to content

Instantly share code, notes, and snippets.

@andhikayuana
Last active September 22, 2023 04:31
Show Gist options
  • Save andhikayuana/d8b76cbe1f9f8dcfcf9d8d9753cde42b to your computer and use it in GitHub Desktop.
Save andhikayuana/d8b76cbe1f9f8dcfcf9d8d9753cde42b to your computer and use it in GitHub Desktop.
publishing aar

Publish Android module to aar

please set like this, inside build.gradle project level :

buildscript {
    ...
    dependencies {
        ...
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.5.1"
    }
}

please include this script in build.gradle module

like this :

apply from: 'publish.gradle'
libraryGroupId=yuana.id
libraryArtifactId=anu
libraryVersion=1.0.0
artifactory_url=https://artifactory.yoururl.com
artifactory_username=youruser
artifactory_password=youruserkey
artifactory_repokey=yourrepokey
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
publishing {
publications {
aar(MavenPublication) {
setGroupId libraryGroupId
artifactId libraryArtifactId
version libraryVersion
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
pom.withXml {
def dependencies = asNode().appendNode('dependencies')
configurations.getByName("releaseCompileClasspath").getResolvedConfiguration().getFirstLevelModuleDependencies().each {
if (it.moduleGroup == 'com.android.databinding' || it.moduleVersion == 'unspecified') {
println("ignoring dependency ${it.moduleGroup}:${it.moduleName}:${it.moduleVersion}")
return;
}
def dependency = dependencies.appendNode('dependency')
dependency.appendNode('groupId', it.moduleGroup)
println(it.moduleGroup)
println(it.moduleVersion)
println(it.moduleName)
dependency.appendNode('artifactId', it.moduleName)
dependency.appendNode('version', it.moduleVersion)
}
}
}
}
}
Properties properties = new Properties()
InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream()
properties.load( inputStream )
artifactory {
contextUrl = properties.getProperty('artifactory_url')
publish {
repository {
repoKey = properties.getProperty('artifactory_repokey')
username = properties.getProperty('artifactory_username')
password = properties.getProperty('artifactory_password')
}
defaults {
publications('aar')
publishArtifacts = true
properties = ['qa.level': 'basic', 'q.os': 'android', 'dev.team': 'core']
publishPom = true
}
}
}
@zetbaitsu
Copy link

zetbaitsu commented May 7, 2018

publish using this command

./gradlew clean && ./gradlew :moduleName:build && ./gradlew artifactoryPublish

@yogasw
Copy link

yogasw commented Apr 8, 2020

if an error is published, please update the version "org.jfrog.buildinfo:build-info-extractor-gradle:4.5.1" to "org.jfrog.buildinfo:build-info-extractor-gradle:4.15.1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment