From 7fb6bda0c9f2b9ff1fc911a350403f151362c737 Mon Sep 17 00:00:00 2001 From: Belin Wu Date: Tue, 22 Jan 2019 18:10:29 +0800 Subject: [PATCH] Add publish.gradle script and release v0.1.0 --- README.md | 4 +- build.gradle | 26 ++++++++++- library/build.gradle | 2 + publish.gradle | 104 +++++++++++++++++++++++++++++++++++++++++++ sample/build.gradle | 1 + 5 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 publish.gradle diff --git a/README.md b/README.md index 6fed79f..15cc904 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,9 @@ Modular adapter for Android RecyclerView. # Download -Coming soon... +```groovy +implementation "com.samelody.modapter:modapter:0.1.0" +``` # Getting started diff --git a/build.gradle b/build.gradle index 152270f..001922e 100644 --- a/build.gradle +++ b/build.gradle @@ -19,13 +19,37 @@ buildscript { deps.test = "com.android.support.test:runner:1.0.2" deps.espresso = "com.android.support.test.espresso:espresso-core:3.0.2" + def pub = [:] + ext.pub = pub + + pub.packaging = 'aar' + pub.groupId = 'com.samelody.modapter' + pub.artifactId = 'modapter' + pub.libraryRepo = 'maven' + pub.libraryId = 'modapter' + pub.libraryName = 'Modapter' + pub.libraryDescription = 'Modular adapter for Android RecyclerView.' + pub.libraryVersion = deps.libVersionName + pub.libraryVersionCode = deps.libVersionCode + pub.siteUrl = 'https://github.com/samelody/modapter' + pub.gitUrl = 'https://github.com/samelody/modapter.git' + pub.issueUrl = 'https://github.com/samelody/modapter/issues' + pub.developerId = 'belinwu' + pub.developerName = 'Belin Wu' + pub.developerEmail = 'belinwu@qq.com' + pub.licenseName = 'Apache License 2.0' + pub.licenseUrl = 'https://raw.githubusercontent.com/samelody/modapter/master/LICENSE' + pub.licenses = ["Apache-2.0"] + repositories { google() jcenter() } + dependencies { classpath 'com.android.tools.build:gradle:3.2.1' - + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/library/build.gradle b/library/build.gradle index 86ada13..57eab5b 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -28,3 +28,5 @@ dependencies { androidTestImplementation deps.test androidTestImplementation deps.espresso } + +apply from: "../publish.gradle" \ No newline at end of file diff --git a/publish.gradle b/publish.gradle new file mode 100644 index 0000000..4bc4772 --- /dev/null +++ b/publish.gradle @@ -0,0 +1,104 @@ +apply plugin: 'com.github.dcendents.android-maven' + +group = pub.groupId +version = pub.libraryVersion + +install { + repositories.mavenInstaller { + pom { + project { + packaging pub.packaging + groupId pub.groupId + artifactId pub.artifactId + version pub.libraryVersion + + // Add your description here + name pub.libraryName + description pub.libraryDescription + url pub.siteUrl + + // Set your license + licenses { + license { + name pub.licenseName + url pub.licenseUrl + } + } + developers { + developer { + id pub.developerId + name pub.developerName + email pub.developerEmail + } + } + scm { + connection pub.gitUrl + developerConnection pub.gitUrl + url pub.siteUrl + } + } + } + } +} + +apply plugin: 'com.jfrog.bintray' + +task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + baseName = pub.libraryId + classifier = "sources" +} + +task javadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + description pub.libraryName + " Javadoc" + source = android.libraryVariants["release"].javaCompile.source + ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar" + classpath = files(android.libraryVariants["release"].javaCompile.classpath.files) + files(ext.androidJar) + options.links("http://docs.oracle.com/javase/7/docs/api/") + options.links("http://d.android.com/reference/") + exclude '**/BuildConfig.java' + exclude '**/R.java' +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = "javadoc" + baseName = pub.libraryId + from javadoc.destinationDir +} + +artifacts { + archives javadocJar + archives sourcesJar +} + +// Bintray +Properties properties = new Properties() +properties.load(project.rootProject.file('local.properties').newDataInputStream()) + +bintray { + user = properties.getProperty("bintray.user") + key = properties.getProperty("bintray.apikey") + + configurations = ['archives'] + pkg { + repo = pub.libraryRepo + name = pub.libraryId + desc = pub.libraryDescription + websiteUrl = pub.siteUrl + vcsUrl = pub.gitUrl + issueTrackerUrl = pub.issueUrl + licenses = pub.licenses + publish = true + publicDownloadNumbers = true + version { + desc = pub.libraryDescription +// gpg { +// sign = false //Determines whether to GPG sign the files. The default is false +// passphrase = properties.getProperty("bintray.gpg.password") +// //Optional. The passphrase for GPG signing' +// } + } + } +} \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 205638b..82ba85b 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -21,6 +21,7 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation project(':library') +// implementation "com.samelody.modapter:modapter:0.1.0" implementation deps.appcompat implementation deps.recyclerview implementation deps.constraintlayout