Skip to content

Commit

Permalink
Oss sonatype deploy (#1)
Browse files Browse the repository at this point in the history
* prepare for OSS deployment
* 0.4 is released to mavenCentral
  • Loading branch information
pull-vert authored Apr 12, 2021
1 parent 15288c6 commit 75fb24b
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 73 deletions.
84 changes: 64 additions & 20 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,42 +1,85 @@
import net.researchgate.release.GitAdapter

val ossrhUsername = if (project.hasProperty("ossrhUsername")) {
project.property("ossrhUsername") as String?
} else {
System.getenv("OSSRH_USERNAME")
}
val ossrhPassword = if (project.hasProperty("ossrhPassword")) {
project.property("ossrhPassword") as String?
} else {
System.getenv("OSSRH_PASSWORD")
}

plugins {
kotlin("multiplatform") apply false
kotlin("jvm") apply false
id("org.jetbrains.dokka") apply false
id("com.android.library") apply false
`maven-publish`
signing
id("net.researchgate.release")
id("maven-publish")
}

subprojects {
apply(plugin = "maven-publish")
apply(plugin = "signing")

repositories {
google()
mavenCentral()
jcenter() // todo remove me when kotlinx-html is on maven central
}

publishing {
repositories {
maven {
val user = "ufoss"
val repo = "ufoss"
val name = "kolog"
url = uri("https://api.bintray.com/maven/$user/$repo/$name/;publish=0")
if (project.version.toString().endsWith("SNAPSHOT")) {
setUrl("https://s01.oss.sonatype.org/content/repositories/snapshots/")
} else {
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
}

credentials {
username =
if (project.hasProperty("bintray_user")) project.property("bintray_user") as String? else System.getenv(
"BINTRAY_USER"
)
password =
if (project.hasProperty("bintray_api_key")) project.property("bintray_api_key") as String? else System.getenv(
"BINTRAY_API_KEY"
)
username = ossrhUsername
password = ossrhPassword
}
}
}

publications.withType<MavenPublication> {
pom {
name.set(project.name)
description.set("kolog duty is to be the idiomatic way to log in Kotlin")
url.set("https://github.com/ufoss-org/kolog")

licenses {
license {
name.set("The Unlicence")
url.set("https://unlicense.org")
}
}

developers {
developer {
name.set("pull-vert")
url.set("https://github.com/pull-vert")
}
}

scm {
connection.set("scm:git:https://github.com/ufoss-org/kolog")
developerConnection.set("scm:git:[email protected]:ufoss-org/kolog.git")
url.set("https://github.com/ufoss-org/kolog")
}
}
}
}

repositories {
google()
jcenter()
signing {
// Require signing.keyId, signing.password and signing.secretKeyRingFile
//useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(publishing.publications)
}
}

Expand All @@ -45,17 +88,18 @@ fun CopySpec.setExecutablePermissions() {
filesMatching("gradlew.bat") { mode = 0b110100100 }
}

// Workaround for project with modules https://github.com/researchgate/gradle-release/issues/144
tasks.withType<GradleBuild> {
/*tasks.withType<GradleBuild> {
buildFile = file("build.gradle.kts")
buildName = "kolog-build"
}
}*/

tasks.register("build") {
// Workaround for project with modules https://github.com/researchgate/gradle-release/issues/144
tasks.register("releaseBuild") {
dependsOn(subprojects.map { it.tasks.findByName("build") }.toTypedArray())
}

release {
buildTasks = listOf("releaseBuild")
val git: GitAdapter.GitConfig = getProperty("git") as GitAdapter.GitConfig
git.requireBranch = "main"
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=org.ufoss.kolog
version=0.4-beta1
version=0.4

# plugins
kotlinVersion=1.4.32
Expand Down
85 changes: 33 additions & 52 deletions kolog/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -99,72 +99,53 @@ kotlin {
}

val iosMain by getting
}
}

configure(targets) {
mavenPublication {
pom {
description.set("kolog duty is to be the idiomatic way to log in Kotlin")
url.set("https://github.com/ufoss-org/kolog")
licenses {
license {
name.set("The Unlicence")
url.set("https://unlicense.org")
}
}
scm {
connection.set("scm:git:git://github.com/ufoss-org/kolog.git")
url.set("https://github.com/ufoss-org/kolog.git")
sourceSets.all {
languageSettings.apply {
languageVersion = "1.4"
apiVersion = "1.4"
enableLanguageFeature("InlineClasses")
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
useExperimentalAnnotation("kotlin.time.ExperimentalTime")
useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi")
progressiveMode = true
}
}
}
}

sourceSets.all {
languageSettings.apply {
languageVersion = "1.4"
apiVersion = "1.4"
enableLanguageFeature("InlineClasses")
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
useExperimentalAnnotation("kotlin.time.ExperimentalTime")
useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi")
progressiveMode = true
}
}
}


tasks.getByName<Test>("jvmTest") {
useJUnitPlatform()
testLogging {
events = setOf(TestLogEvent.STARTED, TestLogEvent.FAILED, TestLogEvent.SKIPPED)
showStandardStreams = true
}
useJUnitPlatform()
testLogging {
events = setOf(TestLogEvent.STARTED, TestLogEvent.FAILED, TestLogEvent.SKIPPED)
showStandardStreams = true
}
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}

tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets {
named("jvmMain") {
configureEach {
jdkVersion.set(8)
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
}
}

android {
compileSdkVersion(30)
defaultConfig {
minSdkVersion(15)
}
compileSdkVersion(30)
defaultConfig {
minSdkVersion(15)
}

val main by sourceSets.getting {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
val main by sourceSets.getting {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
}
}

tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets {
named("jvmMain") {
configureEach {
jdkVersion.set(8)
}
}
}
}

0 comments on commit 75fb24b

Please sign in to comment.