Skip to content

Commit 766deb4

Browse files
authored
Merge pull request #3 from build-extensions-oss/publish-to-maven
Publish to maven
2 parents 612e3f4 + f036d41 commit 766deb4

File tree

11 files changed

+47
-68
lines changed

11 files changed

+47
-68
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ build/
55
# IntelliJ IDEA
66
.idea/
77
*.iml
8+
.run/

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
11
This is the fork of [unbroken-dome/gradle-plugin-utils](https://github.com/unbroken-dome/gradle-plugin-utils) to support
22
newer Gradle.
33

4-
The project has extensions to simplify Gradle plugins build and test.
4+
The project has extensions to simplify Gradle plugins build and test.
5+
6+
# Publishing
7+
8+
In short - publishing doesn't work well, because of breaking changes in Maven Central, plus Gradle Plugins incompatibilities.
9+
10+
At the time of writing Javadoc isn't published properly.
11+
12+
To run publishing tasks, the following needs to be done:
13+
14+
1. File `~/.gradle/gradle.properties` needs to be updated to:
15+
```properties
16+
mavenCentralUsername=???
17+
mavenCentralPassword=???
18+
```
19+
1. And then the following task will work: `./gradlew publishToMavenCentral --stacktrace`
20+
21+
## Signing
22+
23+
Add lines like below into ~/.gradle/gradle.properties:
24+
```properties
25+
signing.keyId=F27AB2F4
26+
signing.password=
27+
# can be exported via gpg --export-secret-keys -o xxx.gpg
28+
# see https://stackoverflow.com/a/39573795/185498
29+
signing.secretKeyRingFile=xxx.gpg
30+
```

build.gradle.kts

Lines changed: 8 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
2-
import java.net.URI
32

43
plugins {
4+
signing
55
kotlin("jvm") apply false
6-
id("org.jetbrains.dokka") apply false
7-
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
6+
alias(libs.plugins.com.vanniktech.maven.publish) apply false
87
}
98

10-
119
subprojects {
1210

1311
plugins.withId("org.jetbrains.kotlin.jvm") {
@@ -22,34 +20,29 @@ subprojects {
2220
}
2321
}
2422

25-
2623
plugins.withType<JavaPlugin> {
2724

2825
configure<JavaPluginExtension> {
2926
withSourcesJar()
30-
withJavadocJar()
27+
// We don't publish Javadoc, because it is useless in out case. We publish sources, plus it is easy to find
28+
// GitHub project and read the source code. We don't have any comprehensive documentation, so let's just publish nothing.
29+
// Additionally, JavaDoc task conflicts with publishing plugin, so let's simply delete one of them.
30+
// withJavadocJar()
3131
}
3232

3333
tasks.withType<Test> {
3434
useJUnitPlatform()
35+
// store all temporary results inside the Gradle folder
3536
systemProperty("java.io.tmpdir", layout.buildDirectory.dir("tmp"))
3637
}
3738

3839
plugins.withType<MavenPublishPlugin> {
39-
40-
with(the<PublishingExtension>()) {
41-
publications.create<MavenPublication>("mavenJava") {
42-
from(components["java"])
43-
}
44-
}
40+
plugins.apply(com.vanniktech.maven.publish.MavenPublishPlugin::class)
4541
}
4642
}
4743

4844

4945
plugins.withType<MavenPublishPlugin> {
50-
51-
plugins.apply(SigningPlugin::class)
52-
5346
val publishing = the<PublishingExtension>()
5447

5548
publishing.publications.withType<MavenPublication> {
@@ -91,43 +84,6 @@ subprojects {
9184
url = file(layout.buildDirectory.dir("repos/releases")).toURI()
9285
}
9386
}
94-
95-
with(the<SigningExtension>()) {
96-
sign(publishing.publications)
97-
}
98-
}
99-
100-
101-
plugins.withId("org.jetbrains.dokka") {
102-
103-
val dokkaVersion: String by extra
104-
105-
dependencies {
106-
"dokkaJavadocPlugin"("org.jetbrains.dokka:kotlin-as-java-plugin:$dokkaVersion")
107-
}
108-
109-
tasks.withType<Jar>().matching { it.name == "javadocJar" }
110-
.configureEach {
111-
from(tasks.named("dokkaJavadoc"))
112-
}
113-
114-
tasks.withType<org.jetbrains.dokka.gradle.DokkaTask> {
115-
dependsOn("classes")
116-
dokkaSourceSets {
117-
named("main") {
118-
sourceLink {
119-
val githubUrl = project.extra["github.url"] as String
120-
localDirectory.set(project.file("src/main/kotlin"))
121-
remoteUrl.set(URI("$githubUrl/tree/master/").toURL())
122-
remoteLineSuffix.set("#L")
123-
}
124-
}
125-
}
126-
}
12787
}
12888
}
12989

130-
131-
nexusPublishing.repositories {
132-
sonatype()
133-
}

gradle-plugin-integration-test-utils/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ plugins {
22
kotlin("jvm")
33
`java-library`
44
`maven-publish`
5-
id("org.jetbrains.dokka")
65
}
76

87

gradle-plugin-test-utils/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ plugins {
22
kotlin("jvm")
33
`java-library`
44
`maven-publish`
5-
id("org.jetbrains.dokka")
65
}
76

87

gradle-plugin-utils/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ plugins {
22
kotlin("jvm")
33
`java-library`
44
`maven-publish`
5-
id("org.jetbrains.dokka")
65
}
76

87

gradle.properties

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
kotlin.code.style=official
22

3-
group=io.github.gradle-cloud.gradle-plugin-utils
3+
group=io.github.build-extensions-oss
44
version=0.5.0
55

66
projectName=Gradle Plugin Utilities
77
projectDescription=A collection of utilities for developing Gradle plugins
8-
projectUrl=https://github.com/Gradle-Cloud/gradle-plugin-utils/
8+
projectUrl=https://github.com/build-extensions-oss/gradle-plugin-utils/
99
projectLicenseName=The MIT License (MIT)
1010
projectLicenseUrl=https://mit-license.org
1111

12-
githubRepo=Gradle-Cloud/gradle-plugin-utils
12+
githubRepo=build-extensions-oss/gradle-plugin-utils
1313

14-
dokkaVersion=1.8.20
14+
# Enable publication tasks by default
15+
mavenCentralPublishing=true
16+
# Sign everything by default - otherwise Maven Central will reject us
17+
signAllPublications=true

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
2020
reflections = { module = "org.reflections:reflections", version.ref = "reflections" }
2121

2222
spek-dsl = { module = "org.spekframework.spek2:spek-dsl", version.ref = "spek2" }
23+
24+
[plugins]
25+
com-vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version = "0.34.0" }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

settings.gradle.kts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,12 @@ pluginManagement {
44
gradlePluginPortal()
55
mavenCentral()
66
}
7-
8-
val dokkaVersion: String by settings
9-
107
resolutionStrategy.eachPlugin {
118
if (requested.id.namespace == "org.jetbrains.kotlin" ||
129
requested.id.namespace.orEmpty().startsWith("org.jetbrains.kotlin.")) {
1310
useVersion(embeddedKotlinVersion)
1411
}
1512
}
16-
17-
plugins {
18-
id("org.jetbrains.dokka") version dokkaVersion apply false
19-
}
2013
}
2114

2215
@Suppress("UnstableApiUsage")

0 commit comments

Comments
 (0)