Skip to content

Instantly share code, notes, and snippets.

@kyungw00k
Created October 29, 2013 14:12
Show Gist options
  • Save kyungw00k/7215421 to your computer and use it in GitHub Desktop.
Save kyungw00k/7215421 to your computer and use it in GitHub Desktop.
apply plugin: 'android-library'
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
versionCode 1
versionName "0.0.1"
minSdkVersion 3
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.1+'
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.6.0'
}
}
def isReleaseBuild() {
return version.contains("SNAPSHOT") == false
}
allprojects {
groupId = POM_GROUP_ID
artifactId = POM_ARTIFACT_ID
version = POM_VERSION
repositories {
mavenCentral()
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
}
apply from: 'config/android-library.gradle'
apply from: 'config/license.gradle'
//apply from: 'config/sign.gradle'
apply from: 'config/maven_push.gradle'
android.libraryVariants.all { variant ->
task("generate${variant.name}Javadoc", type: Javadoc) {
description "Generates Javadoc for $variant.name."
source = variant.javaCompile.source
ext.androidJar =
"${android.plugin.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
}
}
Copyright (C) ${project.inceptionYear} ${owner} (${email})
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
apply plugin: 'license'
license {
header rootProject.file('HEADER')
strictCheck = true
useDefaultMappings = true
ext.year = Calendar.getInstance().get(Calendar.YEAR)
ext.name = 'Snowdream Mobile'
ext.email = 'yanghui1986527@gmail.com'
}
apply plugin: 'maven'
apply plugin: 'signing'
configurations {
archives {
extendsFrom configurations.default
}
}
def sonatypeRepositoryUrl
if (isReleaseBuild()) {
println 'Sonatype RELEASE BUILD'
sonatypeRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
} else {
println 'Sonatype SNAPSHOT BUILD'
sonatypeRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
}
def githubRepositoryUrl
if (isReleaseBuild()) {
println 'GITHUB RELEASE BUILD'
githubRepositoryUrl = "file:///home/snowdream/workspace/git/mvn-repo/releases"
} else {
println 'GITHUB SNAPSHOT BUILD'
githubRepositoryUrl = "file:///home/snowdream/workspace/git/mvn-repo/snapshots"
}
if (ext.properties.containsKey('signing.keyId') &&
!ext.properties.containsKey('signing.password')) {
if (System.console()) {
ext.set('signing.password',
System.console().readPassword("\n\$ Type in GPG key password: "))
} else {
ext.set('signing.password', 'snowdream')
}
}
if (!ext.properties.containsKey('nexusUsername')) {
if (System.console()) {
ext.set('nexusUsername', new String(System.console().readPassword(
"\n\$ Type in username for Sonatype nexus account ${nexusUsername}: ")))
} else {
ext.set('nexusUsername', 'snowdream')
}
}
if (!ext.properties.containsKey('nexusPassword')) {
if (System.console()) {
ext.set('nexusPassword', new String(System.console().readPassword(
"\n\$ Type in password for Sonatype nexus account ${nexusUsername}: ")))
} else {
ext.set('nexusPassword', 'snowdream')
}
}
afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: sonatypeRepositoryUrl) {
authentication(userName: nexusUsername, password: nexusPassword)
}
repository(url: githubRepositoryUrl)
pom.project {
groupId POM_GROUP_ID
artifactId POM_ARTIFACT_ID
version POM_VERSION
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
inceptionYear POM_INCEPTION_YEAR
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
comments POM_LICENCE_COMMENTS
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
email POM_DEVELOPER_EMAIL
url POM_DEVELOPER_URL
}
}
issueManagement {
system POM_ISSUE_MANAGEMENT_SYSTEM
url POM_ISSUE_MANAGEMENT_URL
}
}
}
}
}
signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
task androidReleaseJar(type: Jar, dependsOn: assembleRelease) {
from "$buildDir/classes/release/"
}
task androidJavadocsJar(type: Jar) {
classifier = 'javadoc'
from generateReleaseJavadoc.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.allSource
}
artifacts {
archives androidReleaseJar
archives androidSourcesJar
archives androidJavadocsJar
}
}
apply plugin: 'signing'
signing {
sign configurations.archives
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment