Skip to content

Instantly share code, notes, and snippets.

@jaredsburrows
Last active March 20, 2016 00:15
Show Gist options
  • Save jaredsburrows/4548c65b21f860e8b4fd to your computer and use it in GitHub Desktop.
Save jaredsburrows/4548c65b21f860e8b4fd to your computer and use it in GitHub Desktop.
Publishing AARs locally
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' } // mirrors jcenter() and mavenCentral()
}
dependencies {
// Android gradle plugin
classpath 'com.android.tools.build:gradle:1.5.0'
// Google error-prone
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.8'
// Check for plugin updates
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
apply plugin: 'com.android.library'
apply from: rootProject.file('../common.gradle')
apply plugin: 'maven-publish'
group 'com.burrowsapps'
version '1.0.0'
android.lintOptions {
abortOnError !name.contains('test') // Test package should be ignored
disable 'UnusedResources', // Will be implemented in app
'IconDipSize', // Uses icons provided by Google
'GoogleAppIndexingWarning', // We might want to index our app later
'GradleDependency'
}
publishing {
// Publish to local repository
repositories {
mavenLocal() // ~/.m2
}
publications {
maven(MavenPublication) {
// AAR of each library
artifact "${project.buildDir}/outputs/aar/${project.name}-release.aar"
// Add dependencies to POM - normal Java projects use 'from components.java'
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
// Iterate over the 'compile' dependencies
configurations.compile.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
project.tasks.publishToMavenLocal.dependsOn 'assembleRelease'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment