Skip to content

Commit

Permalink
Add maven publishing and upload to Bintray (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroql committed Jul 1, 2020
1 parent af882b5 commit cdff955
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 2 deletions.
66 changes: 66 additions & 0 deletions bintray.build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
apply plugin: "com.jfrog.bintray"

afterEvaluate {
// needs afterEvaluate to load project description from module's build.gradle
loadLocalBintrayProperties()

bintray {
// https://github.com/bintray/gradle-bintray-plugin
user = readProperty('BINTRAY_USER')
key = readProperty('BINTRAY_KEY')
publications = ["MVFlowPublication"]
pkg {
repo = 'MVFlow'
name = project.name
assert project.description: "Missing description for project :${project.name} to be used for uploading to Bintray"
desc = project.description
licenses = ['MIT']
websiteUrl = 'https://github.com/pedroql/mvflow'
issueTrackerUrl = 'https://github.com/pedroql/mvflow/issues'
vcsUrl = 'https://github.com/pedroql/mvflow.git'
// the next line requires extra authentication
// githubRepo = 'pedroql/mvflow'
version {
name = project.version
released = new Date()
vcsTag = readVcsTag()
}
// publish = true //[Default: false]
dryRun = true //[Default: false]
// override = true //[Default: false] Whether to override version artifacts already published
}
}

}

static private def readProperty(propertyName) {
def value = System.getProperty(propertyName) ?: System.getenv(propertyName)
if (value == null) {
throw new NullPointerException("Missing property $propertyName")
}
return value
}

private static def readVcsTag() {
return System.getProperty("VCS_TAG")
}

private def loadLocalBintrayProperties() {
Properties properties = new Properties()
def propertiesFile = project.rootProject.file('local.properties')
if (propertiesFile.exists()) {
properties.load(propertiesFile.newDataInputStream())

println("Loading Bintray properties into system")
loadPropertyIntoSystem("BINTRAY_USER", properties)
loadPropertyIntoSystem("BINTRAY_KEY", properties)
}
}

private static void loadPropertyIntoSystem(String propertyName, Map properties) {
def missingInSystem = !System.properties.containsKey(propertyName)
def presentInLocalProperties = propertyName in properties
if (missingInSystem && presentInLocalProperties) {
System.setProperty(propertyName, properties[propertyName].toString())
}
}
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.72' apply false
id "org.jetbrains.kotlin.jvm" version "1.3.72" apply false
id "com.jfrog.bintray" version "1.8.5" apply false
}

allprojects {
Expand All @@ -8,7 +9,9 @@ allprojects {
}

subprojects {
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: "org.jetbrains.kotlin.jvm"
apply from: "$rootDir/publishing.build.gradle"
apply from: "$rootDir/bintray.build.gradle"

repositories {
mavenCentral()
Expand Down
3 changes: 3 additions & 0 deletions mvflow-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ tasks.test {
events("passed", "skipped", "failed")
}
}

// project description is sent to Bintray during bintrayUpload task
project.description = "Core functionality of MVFlow"
39 changes: 39 additions & 0 deletions publishing.build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apply plugin: "maven-publish"

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

publishing {
// https://docs.gradle.org/5.0/dsl/org.gradle.api.publish.maven.MavenPublication.html
publications {
MVFlowPublication(MavenPublication) {
from components.java
artifact sourceJar
pom {
description = "Simple MVI architecture using Kotlin Flows"
url = "https://github.com/pedroql/mfflow"
licenses {
license {
name = 'The MIT License'
url = 'https://opensource.org/licenses/MIT'
distribution = 'repo'
}
}
scm {
connection = "scm:git:https://github.com/pedroql/mvflow.git"
developerConnection = "scm:git:git@github.com/pedroql/mvflow.git"
url = "https://github.com/pedroql/mfflow"
}
}
}

}
repositories {
maven {
url = uri("$buildDir/local-maven-repository")
name = "local"
}
}
}

0 comments on commit cdff955

Please sign in to comment.