Skip to content

Commit cb0b2bf

Browse files
committed
improve build
1 parent 79f6ea6 commit cb0b2bf

File tree

19 files changed

+123
-303
lines changed

19 files changed

+123
-303
lines changed

build.gradle.kts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
plugins {
22
java
33
alias(libs.plugins.jacoco)
4-
alias(libs.plugins.nexus)
54
}
65

76
group = "io.openapiprocessor"
87
version = libs.versions.processor.get()
98
println("version: $version")
109

11-
repositories {
12-
mavenCentral()
13-
}
14-
1510
// do not create jar for the root project
1611
tasks.named("jar") { enabled = false }
1712

@@ -23,21 +18,3 @@ tasks.named("jacocoLogAggregatedCoverage") {
2318
tasks.named("build") {
2419
dependsOn ("jacocoLogAggregatedCoverage")
2520
}
26-
27-
extra["publishUser"] = buildProperty("PUBLISH_USER")
28-
extra["publishKey"] = buildProperty("PUBLISH_KEY")
29-
val publishUser: String by extra
30-
val publishKey: String by extra
31-
32-
nexusPublishing {
33-
this.repositories {
34-
sonatype {
35-
username.set(publishUser)
36-
password.set(publishKey)
37-
38-
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
39-
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
40-
}
41-
}
42-
}
43-

buildSrc/build.gradle.kts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
1-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2-
31
plugins {
42
`kotlin-dsl`
5-
// `java-gradle-plugin`
6-
}
7-
8-
repositories {
9-
mavenCentral()
10-
maven {
11-
url = uri("https://plugins.gradle.org/m2/")
12-
}
133
}
144

155
dependencies {
@@ -19,13 +9,5 @@ dependencies {
199
implementation(libs.plugin.kotlin)
2010
implementation(libs.plugin.checker)
2111
implementation(libs.plugin.outdated)
22-
}
23-
24-
gradlePlugin {
25-
plugins {
26-
create("VersionPlugin") {
27-
id = "openapiprocessor.version"
28-
implementationClass = "VersionPlugin"
29-
}
30-
}
12+
implementation(libs.plugin.build)
3113
}

buildSrc/settings.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1+
pluginManagement {
2+
repositories {
3+
gradlePluginPortal()
4+
mavenCentral()
5+
}
6+
}
7+
18
dependencyResolutionManagement {
29
versionCatalogs {
310
create("libs") {
411
from(files("../gradle/libs.versions.toml"))
512
}
613
}
14+
15+
repositories {
16+
gradlePluginPortal()
17+
mavenCentral()
18+
maven {
19+
url = uri("https://central.sonatype.com/repository/maven-snapshots")
20+
mavenContent {
21+
snapshotsOnly()
22+
}
23+
}
24+
}
725
}

buildSrc/src/main/groovy/VersionPlugin.groovy

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

buildSrc/src/main/groovy/VersionTask.groovy

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

buildSrc/src/main/kotlin/Project.kt

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

buildSrc/src/main/kotlin/openapiprocessor.library.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import org.gradle.kotlin.dsl.withType
66
plugins {
77
`java-library`
88
jacoco
9-
109
id("org.jetbrains.kotlin.jvm")
1110
id("com.github.ben-manes.versions")
1211
}
@@ -25,12 +24,16 @@ java {
2524

2625
kotlin {
2726
jvmToolchain(libs.versions.build.jdk.get().toInt())
27+
28+
compilerOptions {
29+
freeCompilerArgs.add("-Xannotation-default-target=param-property")
30+
}
2831
}
2932

3033
repositories {
3134
mavenCentral()
3235
maven {
33-
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
36+
url = uri("https://central.sonatype.com/repository/maven-snapshots")
3437
mavenContent {
3538
snapshotsOnly()
3639
}
Lines changed: 10 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,33 @@
1+
import io.openapiprocessor.build.core.dsl.initFrom
2+
import io.openapiprocessor.build.core.dsl.initSignKey
3+
import io.openapiprocessor.build.core.dsl.sonatype
4+
import io.openapiprocessor.build.core.getPomProperties
15
import org.gradle.accessors.dm.LibrariesForLibs
26

37
plugins {
4-
id("maven-publish")
5-
id("signing")
8+
id("io.openapiprocessor.build.plugin.publish-central")
69
}
710

8-
// see buildSrc/build.gradle catalog hack
11+
// see buildSrc/build.gradle.kts
912
val libs = the<LibrariesForLibs>()
1013

11-
fun properties(key: String): Provider<String> = providers.gradleProperty(key)
12-
val componentName = if (isPlatform()) { "javaPlatform" } else { "java" }
13-
1414
publishing {
1515
publications {
1616
create<MavenPublication>("openapiprocessor") {
17-
from(components[componentName])
17+
from(components["java"])
1818

1919
pom {
20-
group = "io.openapiprocessor"
21-
version = libs.versions.processor.get()
22-
23-
name.set("openapi-processor")
24-
description.set("OpenAPI Processor")
25-
url.set("https://openapiprocessor.io")
26-
27-
licenses {
28-
license {
29-
name.set("The Apache License, Version 2.0")
30-
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
31-
distribution.set("repo")
32-
}
33-
}
34-
35-
developers {
36-
developer {
37-
id.set("hauner")
38-
name.set("Martin Hauner")
39-
}
40-
}
41-
42-
scm {
43-
url.set("https://github.com/openapi-processor/openapi-processor-base")
44-
}
20+
pom.initFrom(getPomProperties(project))
4521
}
4622
}
4723
}
4824

4925
repositories {
50-
maven {
51-
val releasesRepoUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2"
52-
val snapshotsRepoUrl = "https://central.sonatype.com/repository/maven-snapshots"
53-
url = uri(if (isReleaseVersion()) releasesRepoUrl else snapshotsRepoUrl)
54-
55-
credentials {
56-
username = buildProperty("PUBLISH_USER")
57-
password = buildProperty("PUBLISH_KEY")
58-
}
59-
}
26+
sonatype(project)
6027
}
6128
}
6229

63-
// signing requires the sign key and pwd as environment variables:
64-
//
65-
// ORG_GRADLE_PROJECT_signKey=...
66-
// ORG_GRADLE_PROJECT_signPwd=...
67-
6830
signing {
69-
setRequired({ gradle.taskGraph.hasTask("${project.path}:publishToSonatype") })
70-
71-
val signKey: String? by project
72-
val signPwd: String? by project
73-
useInMemoryPgpKeys(signKey, signPwd)
74-
31+
initSignKey()
7532
sign(publishing.publications["openapiprocessor"])
7633
}

buildSrc/src/main/kotlin/openapiprocessor.test.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import org.gradle.accessors.dm.LibrariesForLibs
44

55
plugins {
66
java
7+
groovy
8+
kotlin
79
}
810

911
// see buildSrc/build.gradle.kts

gradle.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
projectGroupId=io.openapiprocessor
2+
3+
projectUrl=https://openapiprocessor.io
4+
projectTitle=openapi-processor
5+
projectDesc=OpenAPI Processor
6+
projectRepo=openapi-processor/openapi-processor-base
7+
8+
org.gradle.configuration-cache=true
9+
org.gradle.configuration-cache.parallel=true
110
org.gradle.warning.mode=all
211

312
org.gradle.jvmargs = -Xmx1g -Xms256m -XX:MaxMetaspaceSize=512m \

0 commit comments

Comments
 (0)