Skip to content

Commit c564d97

Browse files
committed
move publication into buildSrc plugin
1 parent 7314141 commit c564d97

File tree

13 files changed

+104
-104
lines changed

13 files changed

+104
-104
lines changed

build.gradle.kts

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +0,0 @@
1-
plugins {
2-
signing
3-
kotlin("jvm") apply false
4-
alias(libs.plugins.com.vanniktech.maven.publish) apply false
5-
}
6-
7-
subprojects {
8-
plugins.withType<JavaPlugin> {
9-
10-
configure<JavaPluginExtension> {
11-
withSourcesJar()
12-
// We don't publish Javadoc, because it is useless in out case. We publish sources, plus it is easy to find
13-
// GitHub project and read the source code. We don't have any comprehensive documentation, so let's just publish nothing.
14-
// Additionally, JavaDoc task conflicts with publishing plugin, so let's simply delete one of them.
15-
// withJavadocJar()
16-
}
17-
18-
tasks.withType<Test> {
19-
useJUnitPlatform()
20-
// store all temporary results inside the Gradle folder
21-
val localTempFolder = layout.buildDirectory.dir("tmp").get().asFile
22-
systemProperty("java.io.tmpdir", localTempFolder.absolutePath)
23-
24-
doFirst {
25-
// create the folder if needed
26-
localTempFolder.mkdirs()
27-
}
28-
}
29-
30-
plugins.withType<MavenPublishPlugin> {
31-
plugins.apply(com.vanniktech.maven.publish.MavenPublishPlugin::class)
32-
}
33-
}
34-
35-
36-
plugins.withType<MavenPublishPlugin> {
37-
val publishing = the<PublishingExtension>()
38-
39-
publishing.publications.withType<MavenPublication> {
40-
pom {
41-
val githubRepo = providers.gradleProperty("githubRepo")
42-
val githubUrl = githubRepo.map { "https://github.com/$it" }
43-
44-
name.set(providers.gradleProperty("projectName"))
45-
description.set(providers.gradleProperty("projectDescription"))
46-
url.set(providers.gradleProperty("projectUrl"))
47-
licenses {
48-
license {
49-
name.set(providers.gradleProperty("projectLicenseName"))
50-
url.set(providers.gradleProperty("projectLicenseUrl"))
51-
}
52-
}
53-
developers {
54-
developer {
55-
name.set(providers.gradleProperty("developerName"))
56-
email.set(providers.gradleProperty("developerEmail"))
57-
url.set(providers.gradleProperty("developerUrl"))
58-
}
59-
}
60-
scm {
61-
url.set(githubUrl.map { "$it/tree/master" })
62-
connection.set(githubRepo.map { "scm:git:git://github.com/$it.git" })
63-
developerConnection.set(githubRepo.map { "scm:git:ssh://github.com:$it.git" })
64-
}
65-
issueManagement {
66-
url.set(githubUrl.map { "$it/issues" })
67-
system.set("GitHub")
68-
}
69-
}
70-
}
71-
72-
publishing.repositories {
73-
maven {
74-
name = "local"
75-
url = file(layout.buildDirectory.dir("repos/releases")).toURI()
76-
}
77-
}
78-
}
79-
}
80-

buildSrc/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ repositories {
88

99
dependencies {
1010
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${embeddedKotlinVersion}")
11+
implementation(libs.com.vanniktech.maven.publish.gradle.plugin)
1112
}

buildSrc/settings.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dependencyResolutionManagement {
2+
versionCatalogs {
3+
create("libs") {
4+
from(files("../gradle/libs.versions.toml"))
5+
}
6+
}
7+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
plugins.apply(com.vanniktech.maven.publish.MavenPublishPlugin::class)
12+
plugins.apply(SigningPlugin::class)
13+
14+
val publishing = the<PublishingExtension>()
15+
16+
publishing.publications.withType<MavenPublication> {
17+
pom {
18+
val githubRepo = providers.gradleProperty("githubRepo")
19+
val githubUrl = githubRepo.map { "https://github.com/$it" }
20+
21+
name.set(providers.gradleProperty("projectName"))
22+
description.set(providers.gradleProperty("projectDescription"))
23+
url.set(providers.gradleProperty("projectUrl"))
24+
licenses {
25+
license {
26+
name.set(providers.gradleProperty("projectLicenseName"))
27+
url.set(providers.gradleProperty("projectLicenseUrl"))
28+
}
29+
}
30+
developers {
31+
developer {
32+
name.set(providers.gradleProperty("developerName"))
33+
email.set(providers.gradleProperty("developerEmail"))
34+
url.set(providers.gradleProperty("developerUrl"))
35+
}
36+
}
37+
scm {
38+
url.set(githubUrl.map { "$it/tree/master" })
39+
connection.set(githubRepo.map { "scm:git:git://github.com/$it.git" })
40+
developerConnection.set(githubRepo.map { "scm:git:ssh://github.com:$it.git" })
41+
}
42+
issueManagement {
43+
url.set(githubUrl.map { "$it/issues" })
44+
system.set("GitHub")
45+
}
46+
}
47+
}
48+
49+
publishing.repositories {
50+
maven {
51+
name = "local"
52+
url = file(layout.buildDirectory.dir("repos/releases")).toURI()
53+
}
54+
}

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,40 @@ plugins {
77
id("dependencies-lock")
88
}
99

10+
repositories {
11+
// for Gradle dependencies
12+
gradlePluginPortal()
13+
// for all other jars
14+
mavenCentral()
15+
}
1016

1117
configure<KotlinJvmProjectExtension> {
1218
// fix the toolchain for now
1319
jvmToolchain(11)
1420
}
1521

1622
dependencies {
17-
"compileOnly"(kotlin("stdlib"))
18-
"compileOnly"(kotlin("stdlib-jdk8"))
23+
compileOnly(kotlin("stdlib"))
24+
compileOnly(kotlin("stdlib-jdk8"))
25+
}
26+
27+
28+
configure<JavaPluginExtension> {
29+
withSourcesJar()
30+
// We don't publish Javadoc, because it is useless in out case. We publish sources, plus it is easy to find
31+
// GitHub project and read the source code. We don't have any comprehensive documentation, so let's just publish nothing.
32+
// Additionally, JavaDoc task conflicts with publishing plugin, so let's simply delete one of them.
33+
// withJavadocJar()
34+
}
35+
36+
tasks.withType<Test> {
37+
useJUnitPlatform()
38+
// store all temporary results inside the Gradle folder
39+
val localTempFolder = layout.buildDirectory.dir("tmp").get().asFile
40+
systemProperty("java.io.tmpdir", localTempFolder.absolutePath)
41+
42+
doFirst {
43+
// create the folder if needed
44+
localTempFolder.mkdirs()
45+
}
1946
}

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
}
74

85

gradle-plugin-integration-test-utils/gradle.lockfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
# This file is expected to be part of source control.
44
com.google.code.findbugs:jsr305:3.0.2=runtimeClasspath,testRuntimeClasspath
55
org.javassist:javassist:3.28.0-GA=runtimeClasspath,testRuntimeClasspath
6-
org.jetbrains.kotlin:kotlin-stdlib-common:1.9.0=testRuntimeClasspath
7-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.0=testRuntimeClasspath
8-
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0=testRuntimeClasspath
9-
org.jetbrains.kotlin:kotlin-stdlib:1.9.0=testRuntimeClasspath
6+
org.jetbrains.kotlin:kotlin-stdlib:1.9.20=testRuntimeClasspath
107
org.jetbrains:annotations:13.0=testRuntimeClasspath
118
org.reflections:reflections:0.10.2=runtimeClasspath,testRuntimeClasspath
129
org.slf4j:slf4j-api:1.7.32=runtimeClasspath,testRuntimeClasspath

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
}
74

85

gradle-plugin-test-utils/gradle.lockfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
# This file is expected to be part of source control.
44
com.google.code.findbugs:jsr305:3.0.2=runtimeClasspath,testRuntimeClasspath
55
org.javassist:javassist:3.28.0-GA=runtimeClasspath,testRuntimeClasspath
6-
org.jetbrains.kotlin:kotlin-stdlib-common:1.9.0=testRuntimeClasspath
7-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.0=testRuntimeClasspath
8-
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0=testRuntimeClasspath
9-
org.jetbrains.kotlin:kotlin-stdlib:1.9.0=testRuntimeClasspath
6+
org.jetbrains.kotlin:kotlin-stdlib:1.9.20=testRuntimeClasspath
107
org.jetbrains:annotations:13.0=testRuntimeClasspath
118
org.reflections:reflections:0.10.2=runtimeClasspath,testRuntimeClasspath
129
org.slf4j:slf4j-api:1.7.32=runtimeClasspath,testRuntimeClasspath

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
}
74

85

0 commit comments

Comments
 (0)