Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Add publish.gradle (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
benasher44 committed Jun 26, 2019
1 parent a5bc0d1 commit 31336ff
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 51 deletions.
52 changes: 2 additions & 50 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ repositories {

apply plugin: 'kotlin-multiplatform'
apply plugin: 'maven-publish'
apply plugin: 'signing'

kotlin {
targets {
Expand Down Expand Up @@ -147,53 +148,4 @@ tasks.register("ktlintFormat", JavaExec) {
args "-F", "src/**/*.kt"
}

def getDeployVersion() {
return project.findProperty('DEPLOY_VERSION') ?: VERSION
}

group 'com.autodesk'
version getDeployVersion()

afterEvaluate {
publishing {
publications {
all {
groupId = group
version getDeployVersion()
pom.withXml {
def root = asNode()
root.children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST

description 'Native coroutine-based workers'
name = project.name
url 'https://github.com/autodesk/coroutineworker'
scm {
url 'https://github.com/autodesk/coroutineworker'
connection 'scm:git:git://github.com/autodesk/coroutineworker.git'
developerConnection 'scm:git:ssh://git@github.com/autodesk/coroutineworker.git'
}
developers {
developer {
id 'autodesk'
name = 'Autodesk'
}
}
}
}
}
}

//TODO(basher): update for jcenter
// repositories {
// maven {
// credentials {
// username
// password
// }
// url = ""
// }
// }
}
}

apply from: 'publish.gradle'
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=0.0.1
VERSION=0.1.0
107 changes: 107 additions & 0 deletions publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
buildscript {
ext."signing.keyId" = System.getenv("SIGNING_KEYID")
ext."signing.password" = System.getenv("SIGNING_PASSWORD")
ext."signing.secretKeyRingFile" = System.getenv("SIGNING_KEYRING")
}

def getDeployVersion() {
return project.findProperty('DEPLOY_VERSION') ?: VERSION
}

group 'com.autodesk'
version getDeployVersion()

def isReleaseBuild() {
return VERSION.contains('SNAPSHOT') == false
}

def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL :
'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
}

def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL :
'https://oss.sonatype.org/content/repositories/snapshots/'
}

def getRepositoryUsername() {
return System.getenv('SONATYPE_USERNAME') ?: ''
}

def getRepositoryPassword() {
return System.getenv('SONATYPE_PASSWORD') ?: ''
}

task emptySourcesJar(type: Jar) {
classifier = 'sources'
}

//task javadocsJar(type: Jar, dependsOn: dokka) {
// classifier = 'javadoc'
// from dokka.outputDirectory
//}

publishing {
publications {
all {
groupId = group
version getDeployVersion()
pom.withXml {
def root = asNode()
root.children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST

description 'Native coroutine-based workers'
name project.name
url 'https://github.com/autodesk/coroutineworker'
scm {
url 'https://github.com/autodesk/coroutineworker'
connection 'scm:git:git://github.com/autodesk/coroutineworker.git'
developerConnection 'scm:git:ssh://git@github.com/autodesk/coroutineworker.git'
}
developers {
developer {
id 'autodesk'
name 'Autodesk'
}
}
}
}
}
}

afterEvaluate {
publications.getByName('kotlinMultiplatform') {
// Source jars are only created for platforms, not the common artifact.
artifact emptySourcesJar
}
}

repositories {
maven {
url isReleaseBuild() ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl()
credentials {
username getRepositoryUsername()
password getRepositoryPassword()
}
}
}
}

signing {
required { isReleaseBuild() }
sign(publishing.publications)
}

tasks.register('publishMac') {
dependsOn 'publishIosArm64PublicationToMavenRepository'
dependsOn 'publishIosX64PublicationToMavenRepository'
dependsOn 'publishJvmPublicationToMavenRepository'
dependsOn 'publishMetadataPublicationToMavenRepository'
dependsOn 'publishKotlinMultiplatformPublicationToMavenRepository'
}

tasks.register('publishWindows') {
dependsOn 'publishMingwX64PublicationToMavenRepository'
}

0 comments on commit 31336ff

Please sign in to comment.