Skip to content

Commit

Permalink
Update gradle maven publising tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Oct 27, 2020
1 parent e509d60 commit bebd5e6
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
classpath "com.diffplug.spotless:spotless-plugin-gradle:$versions.spotlessGradle"
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$versions.dokkaGradle"
classpath "com.novoda:bintray-release:$versions.bintrayRelease"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$versions.bintrayPlugin"
}
}

Expand Down
6 changes: 3 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ ext.versions = [
versionName : '1.0.6',

gradleBuildTool : '3.6.3',
spotlessGradle : '5.6.1',
spotlessGradle : '5.7.0',
ktlintGradle : '0.39.0',
dokkaGradle : '0.9.17',
bintrayRelease : '0.9.2',
bintrayPlugin : '1.8.5',

kotlin : '1.4.0',
kotlin : '1.4.10',
androidxAppcompat: '1.2.0',

// for demo
Expand Down
138 changes: 128 additions & 10 deletions publish.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,131 @@
apply plugin: 'com.novoda.bintray-release'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'
apply from: '../dependencies.gradle'

publish {
userOrg = 'devmagician'
groupId = 'com.github.skydoves'
artifactId = 'expandablelayout'
publishVersion = versions.versionName
desc = 'An expandable layout that shows a two-level layout with an indicator. '
website = '/~https://github.com/skydoves/ExpandableLayout'
issueTracker = "${website}/issues"
repository = "${website}.git"
ext.repository = [
name : "expandablelayout",
description: "An expandable layout that shows a two-level layout with an indicator.",
websiteUrl : "/~https://github.com/skydoves/ExpandableLayout",
scm : 'scm:git@github.com/skydoves/ExpandableLayout.git'
]

def (property_user, property_key) = getBintrayProperties()
bintray {
user = property_user
key = property_key

publications = ["release"]
publish = true
override = true
dryRun = false

pkg {
repo = "maven"
name = repository.name
userOrg = "devmagician"
desc = repository.description
websiteUrl = repository.websiteUrl
vcsUrl = "${websiteUrl}.git"
issueTrackerUrl = "${websiteUrl}/issues"
licenses = ["Apache-2.0"]
labels = ["android"]
publicDownloadNumbers = false

githubRepo = websiteUrl
githubReleaseNotesFile = "${websiteUrl}/releases"

version {
desc = repository.description
name = versions.versionName
vcsTag = versions.versionName
released = new Date()
gpg { sign = true }
}
}
}

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release

group = "com.github.skydoves"
artifactId = repository.name
version = versions.versionName

artifact androidJavadocsJar
artifact(sourceJar)

pom {
name = repository.name
description = repository.description
url = repository.websiteUrl
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "skydoves"
name = "Jaewoong Eum"
}
}
scm {
connection = repository.scm
developerConnection = repository.scm
url = repository.websiteUrl
}
}
}
}
}
}

def getBintrayProperties() {
def filename = "local.properties"
def propsFile = rootProject.file(filename)
if (propsFile.exists()) {
Properties properties = new Properties()
properties.load(project.rootProject.file(filename).newDataInputStream())
return [
properties.getProperty("bintray.user"),
properties.getProperty("bintray.key")
]
} else {
print(filename + " does not exist!")
return ["", ""]
}
}

task checkBintrayConfig {
doLast {
def (user, key) = getBintrayProperties()
if (user == null || user.isEmpty() || key == null || key.isEmpty()) {
throw new IllegalArgumentException("Must specify Bintray information! Check your local.properties file.")
}
}
}

task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
android.libraryVariants.all { variant ->
if (variant.name == 'release') {
owner.classpath += variant.javaCompileProvider.get().classpath
}
}
exclude '**/R.html', '**/R.*.html', '**/index.html'
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
archiveClassifier.set('javadoc')
from androidJavadocs.destinationDir
}

task sourceJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier "sources"
}

0 comments on commit bebd5e6

Please sign in to comment.