From 2e2fc22b2b1ba983349a7aae78495d4f31fdf69f Mon Sep 17 00:00:00 2001 From: Michael Bull Date: Sat, 21 Oct 2017 22:33:59 +0100 Subject: [PATCH] Add release/publish configuration --- README.md | 4 +-- build.gradle | 20 ++++++------- gradle/publish.gradle | 67 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 13 deletions(-) create mode 100644 gradle/publish.gradle diff --git a/README.md b/README.md index d2e8732..f053337 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ It also iterates on other Result libraries written in Kotlin, namely: Improvements on the existing solutions include: -- Complete feature parity with Result types from other languages including Elm, - Haskell, & Rust +- Feature parity with Result types from other languages including Elm, Haskell, + & Rust - Lax constraints on `value`/`error` nullability - Lax constraints on the `error` type's inheritance (does not inherit from `Exception`) diff --git a/build.gradle b/build.gradle index 7b81067..d0d5e4a 100644 --- a/build.gradle +++ b/build.gradle @@ -8,13 +8,21 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokkaVersion" classpath "org.junit.platform:junit-platform-gradle-plugin:$junitPlatformVersion" + classpath "net.researchgate:gradle-release:$gradleReleaseVersion" } } +ext { + gradleDir = "$rootDir/gradle" +} + apply plugin: 'kotlin' -apply plugin: 'maven-publish' apply plugin: 'org.jetbrains.dokka' apply plugin: 'org.junit.platform.gradle.plugin' +apply plugin: 'net.researchgate.release' +apply from: "$gradleDir/publish.gradle" + +description = 'A Result monad for modelling success or failure operations.' repositories { mavenCentral() @@ -54,13 +62,3 @@ task sourcesJar(type: Jar) { classifier = 'sources' from sourceSets.main.allSource } - -publishing { - publications { - mavenJava(MavenPublication) { - from components.java - artifact javadocJar - artifact sourcesJar - } - } -} diff --git a/gradle/publish.gradle b/gradle/publish.gradle new file mode 100644 index 0000000..4340a69 --- /dev/null +++ b/gradle/publish.gradle @@ -0,0 +1,67 @@ +apply plugin: 'maven' +apply plugin: 'signing' + +ext.isSnapshot = version.endsWith('-SNAPSHOT') +ext.isCI = System.getenv('CI') != null + +if (!isCI) { + signing { + sign configurations.archives + } +} + +uploadArchives { + repositories { + mavenDeployer { + if (isSnapshot || isCI) { + repository(url: "file://~/.m2/repository") + } else { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + } + } + } +} + +rootProject.tasks.afterReleaseBuild.dependsOn tasks.uploadArchives + +afterEvaluate { + tasks.uploadArchives.repositories.mavenDeployer.pom.project { + groupId = project.group + artifactId = project.name + version = project.version + packaging = 'jar' + + name = project.name + description = project.description + inceptionYear = 2017 + url = 'https://github.com/michaelbull/kotlin-result' + + scm { + connection = 'scm:git:https://github.com/michaelbull/kotlin-result' + developerConnection = 'scm:git:git@github.com:michaelbull/kotlin-result.git' + url = 'https://github.com/michaelbull/kotlin-result' + } + + licenses { + license { + name = 'ISC License' + url = 'http://opensource.org/licenses/isc-license.txt' + } + } + + developers { + developer { + name = 'Michael Bull' + url = 'https://www.michael-bull.com' + } + } + } +}