Skip to content

Commit

Permalink
migrate to gradle-bintray-plugin #55
Browse files Browse the repository at this point in the history
  • Loading branch information
yshrsmz committed Sep 30, 2018
1 parent 75db77e commit 24aa494
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
build
/local.properties
/captures
.envrc
15 changes: 13 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apply from: "${project.rootDir}/metadata.gradle"
apply plugin: 'com.github.ben-manes.versions'

buildscript {
apply from: "${rootDir.absolutePath}/ext.gradle"

repositories {
google()
jcenter()
Expand All @@ -13,15 +15,24 @@ buildscript {
classpath 'com.android.tools.build:gradle:3.2.0'

classpath 'com.github.ben-manes:gradle-versions-plugin:0.20.0'
classpath 'com.novoda:bintray-release:0.8.1' // https://github.com/novoda/bintray-release
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.7.5"
}
}

def generatePomFilesTask = tasks.create("generatePomFiles")

allprojects {
repositories {
google()
jcenter()
}

tasks.whenTaskAdded {
if (it.name.matches("generatePomFileFor([A-Z][a-zA-Z]*)Publication")) {
generatePomFilesTask.dependsOn it
}
}
}

ext {
Expand Down Expand Up @@ -62,7 +73,7 @@ task releng {
}

// # release commands:
// ./gradlew clean build releaseAndroidJavadocs releaseAndroidJavadocJar releaseAndroidSourceJar generatePomFileForReleasePublication
// ./gradlew clean build generatePomFileForReleasePublication
// ./gradlew bintrayUpload

task wrapper(type: Wrapper) {
Expand Down
5 changes: 5 additions & 0 deletions ext.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ext {
bintrayUser = System.getenv("bintrayUser")
bintrayKey = System.getenv("bintrayKey")
dryRun = System.getenv("dryRun") == "true"
}
23 changes: 23 additions & 0 deletions gradle/release.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
if (!project.hasProperty('publicationName')) {
throw new ProjectConfigurationException("Project '$project.name' needs to specify 'proejct.ext.publicationName' if Artifactory support should be added!", null)
}

apply plugin: 'com.jfrog.artifactory'

artifactory {
def metadata = project.rootProject.ext.metadata
contextUrl = 'https://oss.jfrog.org/artifactory'
publish {
repository {
// The Artifactory repository key to publish to
repoKey = metadata.version.endsWith('SNAPSHOT') ? 'oss-snapshot-local' : 'oss-release-local'
username = System.getenv('bintrayUser') // The publisher user name
password = System.getenv('bintrayKey') // The publisher password
maven = true
}
defaults {
publishArtifacts = true
publications project.ext.publicationName
}
}
}
82 changes: 72 additions & 10 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'

android {
compileSdkVersion 28
Expand All @@ -23,15 +24,76 @@ dependencies {
implementation "android.arch.lifecycle:extensions:$architecture_version"
}

publish {
artifactId = 'licenseadapter'
desc = 'Adapter for RecyclerView to display oss dependencies'
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

task javadoc(type: Javadoc) {
source += android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
failOnError false
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives javadocJar
archives sourcesJar
}

publishing {
def metadata = project.rootProject.ext.metadata
userOrg = metadata.userOrg
groupId = metadata.groupId
publishVersion = metadata.version
website = metadata.website
repository = metadata.repository
licences = metadata.licences

publications {
release(MavenPublication) {
artifact sourcesJar
artifact javadocJar
artifact "$buildDir/outputs/aar/library-release.aar"
groupId metadata.groupId
artifactId metadata.artifactId
version metadata.version

pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
// Iterate over the compile dependencies, adding a <dependency> node for each
configurations.implementation.allDependencies.each {
if (it.group != null && it.name != null && it.version != null) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}

bintray {
def metadata = project.rootProject.ext.metadata

publications 'release'
user bintrayUser
key bintrayKey
dryRun = dryRun
publish = true

pkg {
repo = 'maven'
userOrg = metadata.userOrg
name = metadata.artifactId
vcsUrl = metadata.repository
licenses = metadata.licenses
version {
name = metadata.version
desc = 'Adapter for RecyclerView to display oss dependencies'
}
}
}

project.ext.publicationName = "release"
apply from: rootProject.file('gradle/release.gradle')
1 change: 1 addition & 0 deletions metadata.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ext {
metadata = [
userOrg : 'yshrsmz',
groupId : 'net.yslibrary.licenseadapter',
artifactId: 'licenseadapter',
website : 'https://github.com/yshrsmz/LicenseAdapter',
repository: 'git@github.com:yshrsmz/LicenseAdapter.git',
licences : ['Apache-2.0']
Expand Down

0 comments on commit 24aa494

Please sign in to comment.