Skip to content

Instantly share code, notes, and snippets.

@piyush-malaviya
Last active April 19, 2018 09:04
Show Gist options
  • Save piyush-malaviya/de048b86c3c09875d2debad0a0e8d578 to your computer and use it in GitHub Desktop.
Save piyush-malaviya/de048b86c3c09875d2debad0a0e8d578 to your computer and use it in GitHub Desktop.
apply plugin: 'com.android.library'
apply plugin: 'checkstyle'
apply plugin: 'maven-publish'
android {
publishNonDefault true
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
versionName project.VERSION_NAME
versionCode project.VERSION_CODE.toInteger()
vectorDrawables.useSupportLibrary true
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'AUTHORS'
exclude 'NOTICE'
}
buildTypes {
debug {
debuggable true
}
dev.initWith(buildTypes.debug)
staging.initWith(buildTypes.debug)
release {
minifyEnabled false
shrinkResources false
}
}
lintOptions {
abortOnError false
}
}
repositories {
flatDir {
dirs 'libs'
}
mavenLocal()
jcenter()
}
// library package name (group id)
def packageName = 'com.app.test'
def libraryVersion = '1.0.0'
publishing {
publications {
aar(MavenPublication) {
groupId packageName
version = libraryVersion
artifactId project.getName()
// output path
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
//generate pom nodes for dependencies
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.compile.allDependencies.each { dependency ->
if (dependency.group != null && dependency.name != null && dependency.version != null) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dependency.group)
dependencyNode.appendNode('artifactId', dependency.name)
dependencyNode.appendNode('version', dependency.version)
}
}
}
}
}
repositories {
maven {
url "$buildDir/repo"
}
}
}
def ANDROID_SUPPORT_VERSION = "25.3.1"
def OK_HTTP3_VERSION = "3.6.0"
def PICASSO_VERSION = "2.5.2"
def GSON_VERSION = "2.8.0"
def AWS_KINESIS_VERSION = "2.4.2"
def PLAY_SERVICE_VERSION = "10.2.6"
dependencies {
compile(name: 'library-release', ext: 'aar')
compile "com.android.support:appcompat-v7:$ANDROID_SUPPORT_VERSION"
compile "com.android.support:design:$ANDROID_SUPPORT_VERSION"
compile "com.android.support:cardview-v7:$ANDROID_SUPPORT_VERSION"
compile "com.squareup.okhttp3:okhttp:$OK_HTTP3_VERSION"
compile "com.squareup.okhttp3:okhttp-urlconnection:$OK_HTTP3_VERSION"
compile "com.squareup.okhttp3:logging-interceptor:$OK_HTTP3_VERSION"
compile "com.google.code.gson:gson:$GSON_VERSION"
compile "com.google.firebase:firebase-messaging:$PLAY_SERVICE_VERSION"
compile "com.google.android.gms:play-services-location:$PLAY_SERVICE_VERSION"
compile "com.squareup.picasso:picasso:$PICASSO_VERSION"
checkstyle('com.puppycrawl.tools:checkstyle:7.6.1')
compile "com.amazonaws:aws-android-sdk-kinesis:$AWS_KINESIS_VERSION"
}
apply plugin: 'com.google.gms.google-services'
task checkstyle(type: Checkstyle) {
showViolations = true
configFile file("config/checkstyle/checkstyle.xml")
description 'applies the checkstyle config to the java files'
source 'src/main/java'
include '**/*.java'
exclude '**/gen/**'
// empty classpath
classpath = files()
}
preBuild.dependsOn('checkstyle') // run checkstyle prior to building
/**
Execute command to run
./gradlew assembleRelease
./gradlew publish
**/
apply plugin: 'maven-publish'
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file:///path")
pom.version = '1.0.0'
pom.groupId = 'com.app'
pom.artifactId = 'lib'
}
}
}
/**
Execute command to run
./gradlew assembleRelease
./gradlew uploadArchives
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment