Skip to content

Commit eacfdb9

Browse files
committed
build: register agp in root build.gradle.kts to prevent agp not found from vanniktech
1 parent c4d7192 commit eacfdb9

4 files changed

Lines changed: 76 additions & 68 deletions

File tree

build-logic/conventions/src/main/kotlin/RollbarPublishPlugin.kt

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,56 @@ class RollbarPublishPlugin : Plugin<Project> {
66
override fun apply(project: Project) {
77

88
project.pluginManager.withPlugin("com.android.library") {
9-
//TODO apply vanniktech plugin
9+
applyPlugin(project)
1010
}
1111

1212
project.plugins.withId("java-library") {
13-
project.plugins.apply("com.vanniktech.maven.publish")
14-
15-
project.extensions.configure(MavenPublishBaseExtension::class.java) {
16-
pom {
17-
name.set(project.findProperty("POM_NAME") as String)
18-
description.set(project.findProperty("POM_DESCRIPTION") as String)
19-
url.set(project.findProperty("POM_URL") as String)
20-
21-
licenses {
22-
license {
23-
name.set(project.findProperty("POM_LICENCE_NAME") as String)
24-
url.set(project.findProperty("POM_LICENCE_URL") as String)
25-
distribution.set(project.findProperty("POM_LICENCE_DIST") as String)
26-
}
27-
}
13+
applyPlugin(project)
14+
}
15+
16+
}
17+
18+
private fun applyPlugin(project: Project) {
19+
project.plugins.apply("com.vanniktech.maven.publish")
20+
21+
project.extensions.configure(MavenPublishBaseExtension::class.java) {
22+
pom {
23+
name.set(project.findProperty("POM_NAME") as String)
24+
description.set(project.findProperty("POM_DESCRIPTION") as String)
25+
url.set(project.findProperty("POM_URL") as String)
2826

29-
developers {
30-
developer {
31-
id.set("rokob")
32-
name.set("Andrew Weiss")
33-
}
34-
developer {
35-
id.set("basoko")
36-
name.set("David Basoco")
37-
}
38-
developer {
39-
id.set("diegov")
40-
name.set("Diego Veralli")
41-
}
27+
licenses {
28+
license {
29+
name.set(project.findProperty("POM_LICENCE_NAME") as String)
30+
url.set(project.findProperty("POM_LICENCE_URL") as String)
31+
distribution.set(project.findProperty("POM_LICENCE_DIST") as String)
4232
}
33+
}
4334

44-
scm {
45-
url.set(project.findProperty("POM_SCM_URL") as String)
46-
connection.set(project.findProperty("POM_SCM_CONNECTION") as String)
47-
developerConnection.set(project.findProperty("POM_SCM_DEV_CONNECTION") as String)
35+
developers {
36+
developer {
37+
id.set("rokob")
38+
name.set("Andrew Weiss")
39+
}
40+
developer {
41+
id.set("basoko")
42+
name.set("David Basoco")
43+
}
44+
developer {
45+
id.set("diegov")
46+
name.set("Diego Veralli")
4847
}
4948
}
5049

51-
publishToMavenCentral()
52-
signAllPublications()
50+
scm {
51+
url.set(project.findProperty("POM_SCM_URL") as String)
52+
connection.set(project.findProperty("POM_SCM_CONNECTION") as String)
53+
developerConnection.set(project.findProperty("POM_SCM_DEV_CONNECTION") as String)
54+
}
5355
}
56+
57+
publishToMavenCentral()
58+
signAllPublications()
5459
}
5560
}
5661
}

build.gradle.kts

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
alias(rollbarlibs.plugins.androidLibrary) apply false
23
alias(rollbarlibs.plugins.vanniktech) apply false
34
alias(rollbarlibs.plugins.spotbugs) apply false
45
alias(rollbarlibs.plugins.revapi) apply false
@@ -20,40 +21,42 @@ subprojects {
2021
val isExample = name.contains("examples") || parent?.name == "examples"
2122
val isAndroid = name.contains("android")
2223

23-
if (!isExample && !isAndroid) {
24-
apply(plugin = "java-library")
25-
apply(plugin = "com.rollbar.conventions.release")
26-
apply(from = "$rootDir/gradle/quality.gradle")
27-
apply(from = "$rootDir/gradle/compatibility.gradle")
24+
if (isExample || isAndroid) {
25+
return@subprojects
26+
}
2827

29-
repositories {
30-
mavenCentral()
31-
}
28+
apply(plugin = "java-library")
29+
apply(plugin = "com.rollbar.conventions.release")
30+
apply(from = "$rootDir/gradle/quality.gradle")
31+
apply(from = "$rootDir/gradle/compatibility.gradle")
3232

33-
tasks.withType<Jar>().configureEach {
34-
manifest {
35-
attributes(
36-
mapOf(
37-
"Implementation-Title" to project.name,
38-
"Implementation-Version" to versionName
39-
)
33+
repositories {
34+
mavenCentral()
35+
}
36+
37+
tasks.withType<Jar>().configureEach {
38+
manifest {
39+
attributes(
40+
mapOf(
41+
"Implementation-Title" to project.name,
42+
"Implementation-Version" to versionName
4043
)
41-
}
44+
)
4245
}
46+
}
4347

44-
dependencies {
45-
add("testImplementation", "junit:junit:4.13.2")
46-
add("testImplementation", "org.hamcrest:hamcrest-all:1.3")
47-
add("testImplementation", "org.mockito:mockito-core:3.8.0")
48-
}
48+
dependencies {
49+
add("testImplementation", "junit:junit:4.13.2")
50+
add("testImplementation", "org.hamcrest:hamcrest-all:1.3")
51+
add("testImplementation", "org.mockito:mockito-core:3.8.0")
52+
}
4953

50-
tasks.withType<JavaCompile>().configureEach {
51-
if (JavaVersion.current().isJava9Compatible) {
52-
options.release.set(8)
53-
} else {
54-
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
55-
targetCompatibility = JavaVersion.VERSION_1_8.toString()
56-
}
54+
tasks.withType<JavaCompile>().configureEach {
55+
if (JavaVersion.current().isJava9Compatible) {
56+
options.release.set(8)
57+
} else {
58+
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
59+
targetCompatibility = JavaVersion.VERSION_1_8.toString()
5760
}
5861
}
5962
}

gradle/rollbarlibs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ spotbugs = "4.8.0"
66
revapi = "1.8.0"
77

88
[plugins]
9-
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
9+
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
1010
vanniktech = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech" }
1111
spotbugs = { id = "com.github.spotbugs", version.ref = "spotbugs" }
1212
revapi = { id = "com.palantir.revapi", version.ref = "revapi" }
13-
android-library = { id = "com.android.library", version.ref = "agp" }
14-
java-library = { id = "java-library" }
13+
androidLibrary = { id = "com.android.library", version.ref = "agp" }
14+
javaLibrary = { id = "java-library" }
1515

1616
[libraries]
1717
junit = { group = "junit", name = "junit", version = "4.13.2" }

rollbar-android/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
2-
id("com.android.library") version "8.6.0"
3-
//id("com.rollbar.conventions.release") //TODO: AGP not applied, don't know why
2+
id("com.android.library")
3+
id("com.rollbar.conventions.release")
44
}
55

66
//apply(from = "$rootDir/gradle/android.quality.gradle") //TODO: Update as convention plugin

0 commit comments

Comments
 (0)