Skip to content

Commit d941aaf

Browse files
committed
move publication into buildSrc plugin
1 parent 78326ee commit d941aaf

File tree

6 files changed

+76
-85
lines changed

6 files changed

+76
-85
lines changed

build.gradle.kts

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -8,81 +8,6 @@ plugins {
88

99

1010
subprojects {
11-
plugins.withType<JavaPlugin> {
12-
13-
configure<JavaPluginExtension> {
14-
withSourcesJar()
15-
withJavadocJar()
16-
}
17-
18-
tasks.withType<Test> {
19-
useJUnitPlatform()
20-
systemProperty("java.io.tmpdir", layout.buildDirectory.dir("tmp").get().asFile.absolutePath)
21-
}
22-
23-
plugins.withType<MavenPublishPlugin> {
24-
25-
with(the<PublishingExtension>()) {
26-
publications.create<MavenPublication>("mavenJava") {
27-
from(components["java"])
28-
}
29-
}
30-
}
31-
}
32-
33-
34-
plugins.withType<MavenPublishPlugin> {
35-
36-
plugins.apply(SigningPlugin::class)
37-
38-
val publishing = the<PublishingExtension>()
39-
40-
publishing.publications.withType<MavenPublication> {
41-
pom {
42-
val githubRepo = providers.gradleProperty("githubRepo")
43-
val githubUrl = githubRepo.map { "https://github.com/$it" }
44-
45-
name.set(providers.gradleProperty("projectName"))
46-
description.set(providers.gradleProperty("projectDescription"))
47-
url.set(providers.gradleProperty("projectUrl"))
48-
licenses {
49-
license {
50-
name.set(providers.gradleProperty("projectLicenseName"))
51-
url.set(providers.gradleProperty("projectLicenseUrl"))
52-
}
53-
}
54-
developers {
55-
developer {
56-
name.set(providers.gradleProperty("developerName"))
57-
email.set(providers.gradleProperty("developerEmail"))
58-
url.set(providers.gradleProperty("developerUrl"))
59-
}
60-
}
61-
scm {
62-
url.set(githubUrl.map { "$it/tree/master" })
63-
connection.set(githubRepo.map { "scm:git:git://github.com/$it.git" })
64-
developerConnection.set(githubRepo.map { "scm:git:ssh://github.com:$it.git" })
65-
}
66-
issueManagement {
67-
url.set(githubUrl.map { "$it/issues" })
68-
system.set("GitHub")
69-
}
70-
}
71-
}
72-
73-
publishing.repositories {
74-
maven {
75-
name = "local"
76-
url = file(layout.buildDirectory.dir("repos/releases")).toURI()
77-
}
78-
}
79-
80-
with(the<SigningExtension>()) {
81-
sign(publishing.publications)
82-
}
83-
}
84-
85-
8611
plugins.withId("org.jetbrains.dokka") {
8712

8813
val dokkaVersion: String by extra
@@ -112,7 +37,6 @@ subprojects {
11237
}
11338
}
11439

115-
11640
nexusPublishing.repositories {
11741
sonatype()
11842
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import org.gradle.api.publish.PublishingExtension
2+
import org.gradle.api.publish.maven.MavenPublication
3+
import org.gradle.kotlin.dsl.create
4+
import org.gradle.kotlin.dsl.get
5+
import org.gradle.kotlin.dsl.the
6+
7+
plugins {
8+
`maven-publish`
9+
}
10+
11+
with(the<PublishingExtension>()) {
12+
publications.create<MavenPublication>("mavenJava") {
13+
from(components["java"])
14+
}
15+
}
16+
17+
18+
19+
plugins.apply(SigningPlugin::class)
20+
21+
val publishing = the<PublishingExtension>()
22+
23+
publishing.publications.withType<MavenPublication> {
24+
pom {
25+
val githubRepo = providers.gradleProperty("githubRepo")
26+
val githubUrl = githubRepo.map { "https://github.com/$it" }
27+
28+
name.set(providers.gradleProperty("projectName"))
29+
description.set(providers.gradleProperty("projectDescription"))
30+
url.set(providers.gradleProperty("projectUrl"))
31+
licenses {
32+
license {
33+
name.set(providers.gradleProperty("projectLicenseName"))
34+
url.set(providers.gradleProperty("projectLicenseUrl"))
35+
}
36+
}
37+
developers {
38+
developer {
39+
name.set(providers.gradleProperty("developerName"))
40+
email.set(providers.gradleProperty("developerEmail"))
41+
url.set(providers.gradleProperty("developerUrl"))
42+
}
43+
}
44+
scm {
45+
url.set(githubUrl.map { "$it/tree/master" })
46+
connection.set(githubRepo.map { "scm:git:git://github.com/$it.git" })
47+
developerConnection.set(githubRepo.map { "scm:git:ssh://github.com:$it.git" })
48+
}
49+
issueManagement {
50+
url.set(githubUrl.map { "$it/issues" })
51+
system.set("GitHub")
52+
}
53+
}
54+
}
55+
56+
publishing.repositories {
57+
maven {
58+
name = "local"
59+
url = file(layout.buildDirectory.dir("repos/releases")).toURI()
60+
}
61+
}
62+
63+
with(the<SigningExtension>()) {
64+
sign(publishing.publications)
65+
}

buildSrc/src/main/kotlin/kotlin-convention.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,15 @@ configure<KotlinJvmProjectExtension> {
1616
dependencies {
1717
"compileOnly"(kotlin("stdlib"))
1818
"compileOnly"(kotlin("stdlib-jdk8"))
19+
}
20+
21+
22+
configure<JavaPluginExtension> {
23+
withSourcesJar()
24+
withJavadocJar()
25+
}
26+
27+
tasks.withType<Test> {
28+
useJUnitPlatform()
29+
systemProperty("java.io.tmpdir", layout.buildDirectory.dir("tmp").get().asFile.absolutePath)
1930
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
plugins {
2-
kotlin("jvm")
32
id("kotlin-convention") // keep shared logic here
4-
`java-library`
5-
`maven-publish`
63
id("org.jetbrains.dokka")
74
}
85

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
plugins {
2-
kotlin("jvm")
32
id("kotlin-convention") // keep shared logic here
4-
`java-library`
5-
`maven-publish`
63
id("org.jetbrains.dokka")
74
}
85

gradle-plugin-utils/build.gradle.kts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
plugins {
2-
kotlin("jvm")
32
id("kotlin-convention") // keep shared logic here
4-
`java-library`
5-
`maven-publish`
63
id("org.jetbrains.dokka")
74
}
85

0 commit comments

Comments
 (0)