Skip to content

Commit 4796d75

Browse files
committed
Migrate build to shared convention plugins setup
1 parent 39046d2 commit 4796d75

File tree

5 files changed

+18
-152
lines changed

5 files changed

+18
-152
lines changed

build.gradle.kts

Lines changed: 13 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,37 @@
1-
plugins {
2-
val nmcpVersion = "1.2.0"
3-
val mavenPluginDevVersion = "1.0.3"
1+
plugins { id("org.gradlex.maven-plugin-development") version "1.0.3" }
42

5-
id("com.gradleup.nmcp") version nmcpVersion
6-
id("com.gradleup.nmcp.aggregation") version nmcpVersion
7-
id("org.gradlex.maven-plugin-development") version mavenPluginDevVersion
8-
id("maven-publish")
9-
id("signing")
10-
id("checkstyle")
11-
}
12-
13-
group = "org.gradlex"
143
version = "1.2"
154

165
val mvnVersion = "3.9.11"
176

187
dependencies {
19-
implementation("com.google.code.gson:gson:2.13.2")
8+
implementation("com.google.code.gson:gson:2.13.1")
209

2110
compileOnly("org.apache.maven:maven-core:$mvnVersion")
2211
compileOnly("org.apache.maven:maven-plugin-api:$mvnVersion")
2312
compileOnly("org.apache.maven.plugin-tools:maven-plugin-annotations:3.15.1")
24-
25-
nmcpAggregation(project(path))
2613
}
2714

28-
mavenPlugin {
29-
name = "Gradle Module Metadata Maven Plugin"
30-
description = "A Maven plugin to publish Gradle Module Metadata"
31-
helpMojoPackage = "org.gradlex.maven.gmm"
32-
}
33-
34-
java {
35-
toolchain.languageVersion = JavaLanguageVersion.of(17)
36-
withSourcesJar()
37-
withJavadocJar()
38-
}
39-
40-
tasks.compileJava {
41-
options.release = 8
42-
options.compilerArgs.add("-Werror")
15+
configurations.api {
16+
withDependencies { clear() } // remove gradleApi() dependency
4317
}
4418

4519
tasks.javadoc {
4620
options {
4721
this as StandardJavadocDocletOptions
48-
addStringOption("Xdoclint:all,-missing", "-Xwerror")
49-
tags(
50-
"goal:a:Goal:",
51-
"requiresProject:a:Requires Project:",
52-
"threadSafe:a:Thread Safe:"
53-
)
54-
}
55-
}
56-
57-
@Suppress("UnstableApiUsage")
58-
testing.suites.named<JvmTestSuite>("test") {
59-
useJUnitJupiter()
60-
dependencies {
61-
implementation(gradleTestKit())
62-
implementation("org.assertj:assertj-core:3.27.6")
63-
}
64-
}
65-
66-
publishing {
67-
publications.register<MavenPublication>("mavenPlugin") {
68-
from(components["java"])
69-
pom {
70-
name = mavenPlugin.name
71-
description = mavenPlugin.description
72-
url = "https://github.com/gradlex-org/gradle-module-metadata-maven-plugin"
73-
licenses {
74-
license {
75-
name = "Apache License, Version 2.0"
76-
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
77-
}
78-
}
79-
scm {
80-
connection = "scm:git:git://github.com/gradlex-org/gradle-module-metadata-maven-plugin.git"
81-
developerConnection = "scm:git:git://github.com/gradlex-org/gradle-module-metadata-maven-plugin.git"
82-
url = "https://github.com/gradlex-org/gradle-module-metadata-maven-plugin"
83-
}
84-
developers {
85-
developer {
86-
name = "Jendrik Johannes"
87-
88-
}
89-
}
90-
}
22+
tags("goal:a:Goal:", "requiresProject:a:Requires Project:", "threadSafe:a:Thread Safe:")
9123
}
9224
}
9325

94-
signing {
95-
if (providers.gradleProperty("sign").getOrElse("false").toBoolean()) {
96-
useInMemoryPgpKeys(
97-
providers.environmentVariable("SIGNING_KEY").getOrNull(),
98-
providers.environmentVariable("SIGNING_PASSPHRASE").getOrNull()
99-
)
100-
sign(publishing.publications["mavenPlugin"])
101-
}
26+
mavenPlugin {
27+
name = "Gradle Module Metadata Maven Plugin"
28+
description = "A Maven plugin to publish Gradle Module Metadata"
29+
helpMojoPackage = "org.gradlex.maven.gmm"
10230
}
10331

104-
nmcpAggregation {
105-
centralPortal {
106-
username = providers.environmentVariable("MAVEN_CENTRAL_USERNAME")
107-
password = providers.environmentVariable("MAVEN_CENTRAL_PASSWORD")
108-
publishingType = "AUTOMATIC" // "USER_MANAGED"
32+
publishingConventions {
33+
mavenCentral {
34+
displayName = mavenPlugin.name
35+
description = mavenPlugin.description
10936
}
11037
}
111-
112-
checkstyle {
113-
configDirectory = layout.projectDirectory.dir("gradle/checkstyle")
114-
}
115-
116-
tasks.checkstyleMain {
117-
exclude("**/HelpMojo.java")
118-
}

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.gradle.caching=true
2+
org.gradle.configuration-cache=true

gradle/checkstyle/checkstyle.xml

Lines changed: 0 additions & 23 deletions
This file was deleted.

gradle/checkstyle/header.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

settings.gradle.kts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
1-
plugins {
2-
id("com.gradle.develocity") version "4.2.2"
3-
}
1+
pluginManagement { includeBuild("build/plugin-publish-conventions") }
42

5-
rootProject.name = "gradle-module-metadata-maven-plugin"
6-
7-
@Suppress("UnstableApiUsage")
8-
dependencyResolutionManagement {
9-
repositories.mavenCentral()
10-
}
3+
plugins { id("org.gradlex.internal.gradlex-build-conventions") version "0.7" }
114

12-
develocity {
13-
buildScan {
14-
val isCi = providers.environmentVariable("CI").getOrElse("false").toBoolean()
15-
if (isCi) {
16-
termsOfUseUrl = "https://gradle.com/help/legal-terms-of-use"
17-
termsOfUseAgree = "yes"
18-
} else {
19-
publishing.onlyIf { false }
20-
}
21-
}
22-
}
5+
rootProject.name = "gradle-module-metadata-maven-plugin"

0 commit comments

Comments
 (0)