Skip to content

Commit 142edf7

Browse files
committed
Configure publishing to Bintray/JCenter and Maven Central
1 parent b3ef5bd commit 142edf7

File tree

6 files changed

+96
-5
lines changed

6 files changed

+96
-5
lines changed

build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ buildscript {
55
repositories {
66
jcenter()
77
}
8+
9+
dependencies {
10+
classpath(Plugins.bintrayReleaseVersioned)
11+
}
812
}
913

1014
plugins {

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
object Plugins {
2+
const val bintrayRelease = "com.novoda.bintray-release"
3+
const val bintrayReleaseVersioned = "com.novoda:bintray-release:${Versions.bintrayRelease}"
24
const val detekt = "io.gitlab.arturbosch.detekt"
35
const val dokka = "org.jetbrains.dokka"
46
const val gradleVersions = "com.github.ben-manes.versions"
@@ -13,11 +15,6 @@ object Libs {
1315
object TestLibs {
1416
const val assertJCore = "org.assertj:assertj-core:${Versions.assertJCore}"
1517
const val junit5Api = "org.junit.jupiter:junit-jupiter-api:${Versions.junit5}"
16-
const val junit5Parameterized = "org.junit.jupiter:junit-jupiter-params:${Versions.junit5}"
1718
const val junit5Runtime = "org.junit.jupiter:junit-jupiter-engine:${Versions.junit5}"
1819
const val mockk = "io.mockk:mockk:${Versions.mockk}"
1920
}
20-
21-
object Groups {
22-
const val kotlin = "org.jetbrains.kotlin"
23-
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.gradle.api.Project
2+
3+
fun Project.propertyOrEmpty(name: String): String {
4+
val property = findProperty(name) as String?
5+
return property ?: environmentVariable(name)
6+
}
7+
8+
fun environmentVariable(name: String) = System.getenv(name) ?: ""
9+
10+
fun Project.isPublishing() = gradle.startParameter.taskNames.any { it.contains("bintrayUpload") }

buildSrc/src/main/kotlin/Turtle.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
object Turtle {
2+
private const val VERSION_MAJOR = 0
3+
private const val VERSION_MINOR = 1
4+
private const val VERSION_PATCH = 0
5+
6+
const val VERSION_NAME = "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
7+
const val VERSION_CODE = VERSION_MAJOR * 100000 + VERSION_MINOR * 100 + VERSION_PATCH
8+
9+
const val GROUP_ID = "com.lordcodes.turtle"
10+
const val ARTIFACT_ID = "turtle"
11+
12+
const val DESCRIPTION = "Run shell commands from a Kotlin script or application with ease \uD83D\uDC22"
13+
const val LICENSE = "Apache-2.0"
14+
const val WEBSITE = "https://github.com/lordcodes/turtle"
15+
const val ISSUE_TRACKER = "https://github.com/lordcodes/turtle/issues"
16+
const val SOURCE_CONTROL = "https://github.com/lordcodes/turtle.git"
17+
18+
const val BINTRAY_USER = "lordcodes"
19+
const val BINTRAY_REPOSITORY = "maven"
20+
21+
const val DEVELOPER_USER = "lordcodes"
22+
const val DEVELOPER_NAME = "Andrew Lord"
23+
}

buildSrc/src/main/kotlin/Versions.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
object Versions {
22
const val assertJCore = "3.13.2"
3+
const val bintrayRelease = "0.9.1"
34
const val detekt = "1.0.0"
45
const val dokka = "0.9.18"
56
const val junit5 = "5.5.1"

turtle/build.gradle.kts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
@file:Suppress("UnstableApiUsage")
2+
3+
import com.novoda.gradle.release.PublishExtension
14
import org.jetbrains.dokka.gradle.DokkaTask
25

36
plugins {
@@ -26,3 +29,56 @@ val dokka by tasks.getting(DokkaTask::class) {
2629
suffix = "#L"
2730
}
2831
}
32+
33+
apply(plugin = Plugins.bintrayRelease)
34+
35+
configure<PublishExtension> {
36+
bintrayUser = propertyOrEmpty("Turtle_Bintray_User")
37+
bintrayKey = propertyOrEmpty("Turtle_Bintray_ApiKey")
38+
39+
userOrg = Turtle.BINTRAY_USER
40+
repoName = Turtle.BINTRAY_REPOSITORY
41+
42+
groupId = Turtle.GROUP_ID
43+
artifactId = Turtle.ARTIFACT_ID
44+
publishVersion = Turtle.VERSION_NAME
45+
46+
desc = Turtle.DESCRIPTION
47+
setLicences(Turtle.LICENSE)
48+
website = Turtle.WEBSITE
49+
issueTracker = Turtle.ISSUE_TRACKER
50+
repository = Turtle.SOURCE_CONTROL
51+
}
52+
53+
if (project.isPublishing()) {
54+
apply(plugin = "maven")
55+
56+
gradle.taskGraph.whenReady {
57+
tasks.withType<GenerateMavenPom>().configureEach {
58+
pom.description.set(Turtle.DESCRIPTION)
59+
pom.packaging = "jar"
60+
pom.url.set(Turtle.WEBSITE)
61+
62+
pom.scm {
63+
url.set(Turtle.SOURCE_CONTROL)
64+
connection.set(Turtle.SOURCE_CONTROL)
65+
developerConnection.set(Turtle.SOURCE_CONTROL)
66+
}
67+
68+
pom.licenses {
69+
license {
70+
name.set("The Apache Software License, Version 2.0")
71+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
72+
distribution.set("repo")
73+
}
74+
}
75+
76+
pom.developers {
77+
developer {
78+
id.set(Turtle.DEVELOPER_USER)
79+
name.set(Turtle.DEVELOPER_NAME)
80+
}
81+
}
82+
}
83+
}
84+
}

0 commit comments

Comments
 (0)