Skip to content

Commit 2f784a5

Browse files
kittinunfiNoles
andauthored
[3.x] Add maven publication to Fuel (#850)
* Update with publication kts * Fix new line * Hmm, let try this! * Added pluginManagement for includeBuild * Fix Github Actions! (#851) * Try this * Fix lint --------- Co-authored-by: Jonathan Steele <iNoles@users.noreply.github.com>
1 parent bf47b7c commit 2f784a5

File tree

10 files changed

+141
-37
lines changed

10 files changed

+141
-37
lines changed

build.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ allprojects {
66
repositories {
77
mavenCentral()
88
}
9-
10-
group = "com.github.kittinunf.fuel"
11-
version = "3.0.0-SNAPSHOT"
9+
val artifactPublishVersion: String by project
10+
val artifactGroupId: String by project
11+
group = artifactGroupId
12+
version = artifactPublishVersion
1213
}

fuel-forge-jvm/build.gradle.kts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
plugins {
22
kotlin("jvm")
3-
`maven-publish`
3+
id("publication")
44
}
55

66
kotlin {
77
explicitApi()
88
}
99

10-
publishing {
11-
publications {
12-
create<MavenPublication>("maven") {
13-
artifactId = "fuel-forge-jvm"
14-
from(components["java"])
15-
}
16-
}
17-
}
18-
1910
tasks.withType<JavaCompile> {
2011
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
2112
targetCompatibility = JavaVersion.VERSION_1_8.toString()

fuel-jackson-jvm/build.gradle.kts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
plugins {
22
kotlin("jvm")
3-
`maven-publish`
3+
id("publication")
44
}
55

66
kotlin {
77
explicitApi()
88
}
99

10-
publishing {
11-
publications {
12-
create<MavenPublication>("maven") {
13-
artifactId = "fuel-jackson-jvm"
14-
from(components["java"])
15-
}
16-
}
17-
}
18-
1910
tasks.withType<JavaCompile> {
2011
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
2112
targetCompatibility = JavaVersion.VERSION_1_8.toString()

fuel-kotlinx-serialization/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
kotlin("multiplatform")
33
kotlin("plugin.serialization") version "1.8.10"
4-
`maven-publish`
4+
id("publication")
55
}
66

77
kotlin {

fuel-moshi-jvm/build.gradle.kts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
plugins {
22
kotlin("jvm")
33
kotlin("kapt")
4-
`maven-publish`
4+
id("publication")
55
}
66

77
kotlin {
88
explicitApi()
99
}
1010

11-
publishing {
12-
publications {
13-
create<MavenPublication>("maven") {
14-
artifactId = "fuel-moshi-jvm"
15-
from(components["java"])
16-
}
17-
}
18-
}
19-
2011
tasks.withType<JavaCompile> {
2112
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
2213
targetCompatibility = JavaVersion.VERSION_1_8.toString()

fuel/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
33

44
plugins {
55
kotlin("multiplatform")
6-
`maven-publish`
6+
id("publication")
77
}
88

99
kotlin {

gradle.properties

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
kotlin.code.style=official
2-
kotlin.js.generate.executable.default=false
2+
kotlin.js.generate.executable.default=false
3+
4+
artifactName=Fuel
5+
artifactDesc=The easiest HTTP networking library for Kotlin/Android
6+
artifactUrl=https://github.com/kittinunf/fuel
7+
artifactScm=git@github.com:kittinunf/fuel.git
8+
artifactLicenseName=MIT License
9+
artifactLicenseUrl=http://www.opensource.org/licenses/mit-license.php
10+
artifactPublishVersion=3.0.0-alpha1
11+
artifactGroupId=com.github.kittinunf.fuel

plugins/build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
}
8+
9+
java {
10+
sourceCompatibility = JavaVersion.VERSION_1_8
11+
targetCompatibility = JavaVersion.VERSION_1_8
12+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import java.util.Properties
2+
3+
plugins {
4+
`maven-publish`
5+
signing
6+
}
7+
8+
ext["signing.key"] = null
9+
ext["signing.password"] = null
10+
ext["sonatype.username"] = null
11+
ext["sonatype.password"] = null
12+
13+
val secretPropsFile = project.rootProject.file("local.properties")
14+
if (secretPropsFile.exists()) {
15+
secretPropsFile.reader().use {
16+
Properties().apply { load(it) }
17+
}.onEach { (name, value) ->
18+
ext[name.toString()] = value
19+
}
20+
} else {
21+
ext["signing.key"] = System.getenv("SIGNING_KEY")
22+
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
23+
ext["sonatype.username"] = System.getenv("SONATYPE_USERNAME")
24+
ext["sonatype.password"] = System.getenv("SONATYPE_PASSWORD")
25+
}
26+
27+
val javadocJar by tasks.registering(Jar::class) {
28+
archiveClassifier.set("javadoc")
29+
}
30+
31+
fun getExtraString(name: String) = ext[name]?.toString()
32+
33+
val isReleaseBuild: Boolean
34+
get() = properties.containsKey("release")
35+
36+
publishing {
37+
repositories {
38+
maven {
39+
name = "sonatype"
40+
url = uri(
41+
if (isReleaseBuild) {
42+
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
43+
} else {
44+
"https://oss.sonatype.org/content/repositories/snapshots"
45+
}
46+
)
47+
48+
credentials {
49+
username = getExtraString("sonatype.username")
50+
password = getExtraString("sonatype.password")
51+
}
52+
}
53+
}
54+
55+
// Configure all publications
56+
publications.withType<MavenPublication> {
57+
val artifactName: String by project
58+
val artifactDesc: String by project
59+
val artifactUrl: String by project
60+
val artifactScm: String by project
61+
val artifactLicenseName: String by project
62+
val artifactLicenseUrl: String by project
63+
64+
artifactId = project.name
65+
66+
artifact(javadocJar)
67+
68+
pom {
69+
name.set(artifactName)
70+
description.set(artifactDesc)
71+
url.set(artifactUrl)
72+
licenses {
73+
license {
74+
name.set(artifactLicenseName)
75+
url.set(artifactLicenseUrl)
76+
distribution.set("repo")
77+
}
78+
}
79+
developers {
80+
developer {
81+
id.set("iNoles")
82+
}
83+
developer {
84+
id.set("kittinunf")
85+
}
86+
}
87+
contributors {
88+
}
89+
scm {
90+
connection.set(artifactScm)
91+
developerConnection.set(artifactScm)
92+
url.set(artifactUrl)
93+
}
94+
}
95+
}
96+
}
97+
98+
signing {
99+
val signingKey = project.ext["signing.key"] as? String
100+
val signingPassword = project.ext["signing.password"] as? String
101+
if (signingKey == null || signingPassword == null) return@signing
102+
103+
useInMemoryPgpKeys(signingKey, signingPassword)
104+
sign(publishing.publications)
105+
}

settings.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@ include(":fuel-jackson-jvm")
66
include(":fuel-kotlinx-serialization")
77
include(":fuel-moshi-jvm")
88

9-
include(":samples:httpbin-js")
9+
// include(":samples:httpbin-js")
1010
include(":samples:mockbin-native")
11+
12+
pluginManagement {
13+
includeBuild("plugins")
14+
}

0 commit comments

Comments
 (0)