From e69dada548ac88025fb57b27e1e24d469017514f Mon Sep 17 00:00:00 2001 From: furiya-daichi Date: Sun, 11 Jan 2015 22:43:38 +0900 Subject: [PATCH] setting project --- build.gradle | 3 +- example/build.gradle | 5 +- gradle.properties | 1 + transformations/android-artifacts.gradle | 24 ++++++ transformations/bintray-publish.gradle | 63 ++++++++++++++++ transformations/build.gradle | 45 ++++++++---- transformations/central-publish.gradle | 94 ++++++++++++++++++++++++ transformations/gradle.properties | 3 + 8 files changed, 220 insertions(+), 18 deletions(-) create mode 100644 transformations/android-artifacts.gradle create mode 100644 transformations/bintray-publish.gradle create mode 100644 transformations/central-publish.gradle create mode 100644 transformations/gradle.properties diff --git a/build.gradle b/build.gradle index 6356aab..33c9e38 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,8 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.0.0' + classpath 'com.android.tools.build:gradle:1.0.+' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/example/build.gradle b/example/build.gradle index 8437cad..fa6e985 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -50,8 +50,7 @@ def getKeyAliasPasswordProperty() { } dependencies { -// compile project(':animators') - compile 'com.github.bumptech.glide:glide:3.4.+' + compile project(':transformations') compile 'com.android.support:appcompat-v7:+' - compile 'com.squareup.picasso:picasso:+' + compile 'com.github.bumptech.glide:glide:3.+' } diff --git a/gradle.properties b/gradle.properties index d45fadc..35ad388 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,7 @@ ARTIFACT_ID=glide-transformations COMPILE_SDK_VERSION=21 BUILD_TOOLS_VERSION=21.1.2 TARGET_SDK_VERSION=21 +RENDERSCRIPT_TARGET_API=21 MIN_SDK_VERSION=11 POM_DESCRIPTION=which provides simple Tranformations to Glide diff --git a/transformations/android-artifacts.gradle b/transformations/android-artifacts.gradle new file mode 100644 index 0000000..f8d302d --- /dev/null +++ b/transformations/android-artifacts.gradle @@ -0,0 +1,24 @@ +task androidJavadocs(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) +} + +task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { + classifier = 'javadoc' + from androidJavadocs.destinationDir +} + +task androidSourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.sourceFiles +} + +task androidJar(type: Jar) { + from 'build/intermediates/classes/release' +} + +artifacts { + archives androidSourcesJar + archives androidJavadocsJar + archives androidJar +} \ No newline at end of file diff --git a/transformations/bintray-publish.gradle b/transformations/bintray-publish.gradle new file mode 100644 index 0000000..df0bb42 --- /dev/null +++ b/transformations/bintray-publish.gradle @@ -0,0 +1,63 @@ +apply plugin: 'maven-publish' +apply plugin: 'com.jfrog.bintray' + +publishing { + publications { + mavenJava(MavenPublication) { + groupId GROUP + version VERSION_NAME + artifactId ARTIFACT_ID + artifact androidJar + artifact androidJavadocsJar + artifact androidSourcesJar + pom.withXml { + Node root = asNode() + root.appendNode('name', ARTIFACT_ID) + root.appendNode('description', POM_DESCRIPTION) + root.appendNode('url', POM_URL) + + def issues = root.appendNode('issueManagement') + issues.appendNode('system', 'github') + issues.appendNode('url', ISSUE_URL) + + def scm = root.appendNode('scm') + scm.appendNode('url', POM_SCM_URL) + scm.appendNode('connection', POM_SCM_CONNECTION) + scm.appendNode('developerConnection', POM_SCM_DEV_CONNECTION) + + def license = root.appendNode('licenses').appendNode('license') + license.appendNode('name', POM_LICENCE_NAME) + license.appendNode('url', POM_LICENCE_URL) + license.appendNode('distribution', POM_LICENCE_DIST) + } + } + } +} + +def getBintrayUserProperty() { + return hasProperty('bintrayUser') ? bintrayUser : "" +} + +def getBintrayApiKeyProperty() { + return hasProperty('bintrayApiKey') ? bintrayApiKey : "" +} + +bintray { + user = bintrayUserProperty + key = bintrayApiKeyProperty + publications = ['mavenJava'] + + dryRun = false + publish = false + pkg { + repo = 'maven' + name = ARTIFACT_ID + licenses = ['Apache-2.0'] + labels = ['android'] + + version { + name = VERSION_NAME + vcsTag = VERSION_NAME + } + } +} diff --git a/transformations/build.gradle b/transformations/build.gradle index 300779b..ebc8974 100644 --- a/transformations/build.gradle +++ b/transformations/build.gradle @@ -1,24 +1,41 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 21 - buildToolsVersion "21.1.2" + compileSdkVersion COMPILE_SDK_VERSION as int + buildToolsVersion BUILD_TOOLS_VERSION defaultConfig { - minSdkVersion 11 - targetSdkVersion 21 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } + minSdkVersion MIN_SDK_VERSION as int + targetSdkVersion TARGET_SDK_VERSION as int + versionCode VERSION_CODE as int + versionName VERSION_NAME + renderscriptTargetApi RENDERSCRIPT_TARGET_API as int + renderscriptSupportModeEnabled true } } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:21.0.3' + compile 'com.github.bumptech.glide:glide:3.+' } + +android.libraryVariants.all { variant -> + if (variant.buildType.isDebuggable()) { + return; // Skip debug builds. + } + task("javadoc${variant.name.capitalize()}", type: Javadoc) { + description "Generates Javadoc for $variant.name." + source = variant.javaCompile.source + ext.androidJar = System.getenv("ANDROID_HOME") + "/platforms/${android.compileSdkVersion}/android.jar" + classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar) + } + + task("bundleJavadoc${variant.name.capitalize()}", type: Jar) { + description "Bundles Javadoc into zip for $variant.name." + classifier = "javadoc" + from tasks["javadoc${variant.name.capitalize()}"] + } +} + +apply from: 'android-artifacts.gradle' +apply from: 'central-publish.gradle' +apply from: 'bintray-publish.gradle' \ No newline at end of file diff --git a/transformations/central-publish.gradle b/transformations/central-publish.gradle new file mode 100644 index 0000000..4575f08 --- /dev/null +++ b/transformations/central-publish.gradle @@ -0,0 +1,94 @@ +/* + * Copyright 2013 Chris Banes + * + * 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: 'maven' +apply plugin: 'signing' + +def isReleaseBuild() { + return VERSION_NAME.contains("SNAPSHOT") == false +} + +def getReleaseRepositoryUrl() { + return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL + : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" +} + +def getSnapshotRepositoryUrl() { + return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL + : "https://oss.sonatype.org/content/repositories/snapshots/" +} + +def getRepositoryUsername() { + return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "" +} + +def getRepositoryPassword() { + return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "" +} + +afterEvaluate { project -> + uploadArchives { + repositories { + mavenDeployer { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + + pom.groupId = GROUP + pom.artifactId = POM_ARTIFACT_ID + pom.version = VERSION_NAME + + repository(url: getReleaseRepositoryUrl()) { + authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) + } + snapshotRepository(url: getSnapshotRepositoryUrl()) { + authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) + } + + pom.project { + name POM_NAME + packaging POM_PACKAGING + description POM_DESCRIPTION + url POM_URL + + 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 + } + } + + developers { + developer { + id POM_DEVELOPER_ID + name POM_DEVELOPER_NAME + } + } + } + } + } + } + + signing { + required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } + sign configurations.archives + } +} \ No newline at end of file diff --git a/transformations/gradle.properties b/transformations/gradle.properties new file mode 100644 index 0000000..92ca31b --- /dev/null +++ b/transformations/gradle.properties @@ -0,0 +1,3 @@ +POM_NAME=which provides simple Tranformations to Glide +POM_ARTIFACT_ID=glide-transformations +POM_PACKAGING=aar \ No newline at end of file