diff --git a/DanmakuFlameMaster/build.gradle b/DanmakuFlameMaster/build.gradle index 445b9b1a..6729cac7 100644 --- a/DanmakuFlameMaster/build.gradle +++ b/DanmakuFlameMaster/build.gradle @@ -14,16 +14,7 @@ * limitations under the License. */ -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath 'com.android.tools.build:gradle:1.0.1+' - } -} -//apply plugin: 'android' -apply plugin: 'android-library' +apply plugin: 'com.android.library' android { compileSdkVersion 19 @@ -32,6 +23,14 @@ android { defaultConfig { minSdkVersion 7 targetSdkVersion 19 + versionName VERSION_NAME + versionCode Integer.parseInt(VERSION_CODE) + } + sourceSets { + main { + jniLibs.srcDirs = ['src/main/libs'] + } } - } + +apply from: rootProject.file('gradle/gradle-mvn-push.gradle') \ No newline at end of file diff --git a/DanmakuFlameMaster/gradle.properties b/DanmakuFlameMaster/gradle.properties new file mode 100644 index 00000000..8b2f4a00 --- /dev/null +++ b/DanmakuFlameMaster/gradle.properties @@ -0,0 +1,3 @@ +POM_NAME=DanmakuFlameMaster +POM_ARTIFACT_ID=dfm +POM_PACKAGING=aar \ No newline at end of file diff --git a/DanmakuFlameMaster/src/main/AndroidManifest.xml b/DanmakuFlameMaster/src/main/AndroidManifest.xml index 55d98c23..cd73ce71 100644 --- a/DanmakuFlameMaster/src/main/AndroidManifest.xml +++ b/DanmakuFlameMaster/src/main/AndroidManifest.xml @@ -16,7 +16,7 @@ --> diff --git a/Sample/build.gradle b/Sample/build.gradle index ebc02566..b4233143 100644 --- a/Sample/build.gradle +++ b/Sample/build.gradle @@ -14,15 +14,7 @@ * limitations under the License. */ -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath 'com.android.tools.build:gradle:1.0.1+' - } -} -apply plugin: 'android' +apply plugin: 'com.android.application' dependencies { compile project(':DanmakuFlameMaster') @@ -34,22 +26,7 @@ android { defaultConfig { minSdkVersion 7 targetSdkVersion 19 - } - - task copyNativeLibs(type: Copy) { - from(new File(project(':DanmakuFlameMaster').getProjectDir(), 'src/main/libs')) { include '**/*.so' } - into new File(buildDir, 'native-libs') - } - - tasks.withType(JavaCompile) { - compileTask -> compileTask.dependsOn copyNativeLibs - } - - clean.dependsOn 'cleanCopyNativeLibs' - - tasks.withType(com.android.build.gradle.tasks.PackageApplication) { - pkgTask -> - pkgTask.jniFolders = new HashSet() - pkgTask.jniFolders.add(new File(buildDir, 'native-libs')) + versionCode 1 + versionName "1.0" } } diff --git a/build.gradle b/build.gradle index 010584ed..25807ee9 100644 --- a/build.gradle +++ b/build.gradle @@ -1 +1,14 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.1.0' + } +} + +allprojects { + repositories { + jcenter() + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..ada83ba0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,18 @@ +GROUP=com.github.ctiao +VERSION_CODE=2600 +VERSION_NAME=0.2.6-SNAPSHOT + +POM_DESCRIPTION=A Danmaku render library. + +POM_URL=https://github.com/ctiao/DanmakuFlameMaster +POM_SCM_URL=https://github.com/ctiao/DanmakuFlameMaster +POM_SCM_CONNECTION=scm:git:git://github.com/ctiao/DanmakuFlameMaster.git +POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/ctiao/DanmakuFlameMaster.git + +POM_LICENCE_NAME=The Apache Software License, Version 2.0 +POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENCE_DIST=repo + +POM_DEVELOPER_ID=calmer91 +POM_DEVELOPER_NAME=Chen Hui +POM_DEVELOPER_EMAIL=calmer91@gmail.com \ No newline at end of file diff --git a/gradle/gradle-mvn-push.gradle b/gradle/gradle-mvn-push.gradle new file mode 100644 index 00000000..b510cfc6 --- /dev/null +++ b/gradle/gradle-mvn-push.gradle @@ -0,0 +1,113 @@ +/* + * Copyright (c) 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 getRepositoryUsername() { + return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : "" +} + +def getRepositoryPassword() { + return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_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: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { + authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) + } + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { + 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 + email POM_DEVELOPER_EMAIL + } + } + } + } + } + } + + signing { + required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } + sign configurations.archives + } + + task androidJavadocs(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + options.encoding = 'UTF-8' + if (JavaVersion.current().isJava8Compatible()) { + allprojects { + tasks.withType(Javadoc) { + options.addStringOption('Xdoclint:none', '-quiet') + } + } + } + } + + task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { + classifier = 'javadoc' + from androidJavadocs.destinationDir + } + + task androidSourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.sourceFiles + } + + artifacts { + archives androidSourcesJar + archives androidJavadocsJar + } +} \ No newline at end of file