Skip to content

Commit 230f5ab

Browse files
committed
build: Migrate publication to precompiled build script
Also add gradle-nexus.publish-plugin
1 parent fcb10e5 commit 230f5ab

16 files changed

Lines changed: 129 additions & 163 deletions

File tree

build.gradle.kts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2-
subprojects {
3-
version = getLibVersion()
4-
group = "com.redmadrobot.debug"
2+
plugins {
3+
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
4+
}
55

6+
subprojects {
67
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
78
kotlinOptions.freeCompilerArgs += listOf(
89
"-opt-in=com.redmadrobot.debug_panel_core.annotation.DebugPanelInternal"
910
)
1011
}
1112
}
1213

14+
nexusPublishing {
15+
// Uncomment if you need to release artifacts uploaded using "publish" task.
16+
// repositoryDescription.set("Implicitly created (auto staging).")
17+
repositories {
18+
sonatype {
19+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
20+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
21+
}
22+
}
23+
}
24+
1325
tasks.register("clean", Delete::class) {
1426
delete(rootProject.layout.buildDirectory)
1527
}

buildSrc/build.gradle.kts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@ repositories {
99
mavenCentral()
1010
}
1111

12-
gradlePlugin {
13-
plugins {
14-
create("PublishPlugin") {
15-
id = "publishPlugin"
16-
implementationClass = "com.redmadrobot.build.PublishPlugin"
17-
}
18-
}
19-
}
20-
2112
dependencies {
2213
implementation(kotlin("gradle-plugin", version = "1.9.23"))
2314
implementation("com.android.tools.build:gradle:8.3.2")

buildSrc/src/main/kotlin/Project.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,3 @@ object Project {
1717
const val projectRules = "proguard-rules.pro"
1818
}
1919
}
20-
21-
fun Project.getLibVersion(): String = Properties().apply {
22-
load(File("$rootDir/gradle/publish.properties").inputStream())
23-
}.getProperty("lib_version")

buildSrc/src/main/kotlin/PublishPlugin.kt

Lines changed: 0 additions & 136 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import internal.android
2+
import java.util.Properties
3+
4+
plugins {
5+
id("maven-publish")
6+
id("signing")
7+
}
8+
9+
android {
10+
publishing {
11+
singleVariant("release") {
12+
withSourcesJar()
13+
}
14+
}
15+
}
16+
17+
private val publishProperties by lazy {
18+
rootProject.file("gradle/publish.properties").inputStream()
19+
.use { Properties().apply { load(it) } }
20+
}
21+
val libraryName by lazy {
22+
val properties = project.file("library.properties").inputStream()
23+
.use { Properties().apply { load(it) } }
24+
properties.getProperty("lib_name")
25+
}
26+
27+
publishing {
28+
publications.create<MavenPublication>("release") {
29+
artifactId = libraryName
30+
31+
afterEvaluate { from(components["release"]) }
32+
33+
pom {
34+
name = libraryName
35+
description = provider { project.description }
36+
url = publishProperties.getProperty("home_page")
37+
38+
licenses {
39+
license {
40+
name = publishProperties.getProperty("license_name")
41+
url = publishProperties.getProperty("license_url")
42+
}
43+
}
44+
45+
developers {
46+
developer {
47+
id = "Zestxx"
48+
name = "Roman Choriev"
49+
email = "r.choryev@redmadrobot.com"
50+
}
51+
}
52+
53+
contributors {
54+
contributor {
55+
name = "Osip Fatkullin"
56+
email = "o.fatkullin@redmadrobot.com"
57+
}
58+
contributor {
59+
name = "Alexandr Anisimov"
60+
email = "PilotOfSparrow@gmail.com"
61+
}
62+
contributor {
63+
name = "Dmitry trabo"
64+
email = "dtrabo@gmail.com"
65+
}
66+
}
67+
68+
scm {
69+
connection = "scm:git:git://github.com/RedMadRobot/debug-panel-android.git"
70+
developerConnection = "scm:git:ssh://github.com/RedMadRobot/debug-panel-android.git"
71+
url = publishProperties.getProperty("home_page")
72+
}
73+
}
74+
}
75+
76+
repositories {
77+
mavenLocal()
78+
maven {
79+
name = "OSSRH"
80+
url = project.uri(publishProperties.getProperty("sonatype_repo"))
81+
82+
credentials {
83+
username = System.getenv("OSSRH_USER")
84+
password = System.getenv("OSSRH_PASSWORD")
85+
}
86+
}
87+
}
88+
}
89+
90+
afterEvaluate {
91+
signing {
92+
useGpgCmd()
93+
sign(publishing.publications["release"])
94+
}
95+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package internal
2+
3+
import com.android.build.api.dsl.LibraryExtension
4+
import org.gradle.api.plugins.ExtensionAware
5+
6+
internal fun ExtensionAware.android(configure: LibraryExtension.() -> Unit) {
7+
extensions.configure<LibraryExtension>("android", configure)
8+
}

debug-panel-common/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id(Plugins.Android.libraryPlagin)
33
kotlin(Plugins.Kotlin.androidPlugin)
44
kotlin(Plugins.Kotlin.kapt)
5-
id("publishPlugin")
5+
id("convention-publish")
66
}
77

88
description = "Debug panel common components"

debug-panel-core/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id(Plugins.Android.libraryPlagin)
33
kotlin(Plugins.Kotlin.androidPlugin)
44
kotlin(Plugins.Kotlin.kapt)
5-
id("publishPlugin")
5+
id("convention-publish")
66
}
77

88
description = "Debug panel core library"

debug-panel-no-op/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
id(Plugins.Android.libraryPlagin)
33
kotlin(Plugins.Kotlin.androidPlugin)
4-
id("publishPlugin")
4+
id("convention-publish")
55
}
66

77
description = "Debug panel no-op dependency module"

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Project-wide Gradle settings.
2+
group=com.redmadrobot.debug
3+
version=0.7.6
4+
25
# IDE (e.g. Android Studio) users:
36
# Gradle settings configured through the IDE *will override*
47
# any settings specified in this file.

0 commit comments

Comments
 (0)