-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add maven publishing and upload to Bintray (#2)
- Loading branch information
Showing
4 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |