Skip to content

Commit 131df63

Browse files
committed
update build
1 parent 877c27e commit 131df63

17 files changed

Lines changed: 212 additions & 143 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
plugins {
2-
java
2+
base
33
alias(libs.plugins.jacoco)
4-
alias(libs.plugins.nexus)
5-
id("openapi-parser.publish-central")
64
}
75

86
repositories {
@@ -17,26 +15,3 @@ tasks.named("build") {
1715
group = "io.openapiprocessor"
1816
version = libs.versions.openapiparser.get()
1917
println("version: $version")
20-
21-
extra["publishUser"] = buildProperty("PUBLISH_USER")
22-
extra["publishKey"] = buildProperty("PUBLISH_KEY")
23-
val publishUser: String by extra
24-
val publishKey: String by extra
25-
26-
centralPublishing {
27-
username = publishUser
28-
password = publishKey
29-
stagingDir = layout.buildDirectory.dir("central")
30-
}
31-
32-
nexusPublishing {
33-
this.repositories {
34-
sonatype {
35-
username.set(publishUser)
36-
password.set(publishKey)
37-
38-
nexusUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/")
39-
snapshotRepositoryUrl = uri("https://central.sonatype.com/repository/maven-snapshots/")
40-
}
41-
}
42-
}

buildSrc/build.gradle.kts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,12 @@ plugins {
22
`kotlin-dsl`
33
}
44

5-
repositories {
6-
mavenCentral()
7-
maven {
8-
url = uri("https://plugins.gradle.org/m2/")
9-
}
10-
}
11-
125
dependencies {
136
// catalog hack: https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
147
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
158

169
implementation(libs.plugin.kotlin)
1710
implementation(libs.plugin.checker)
18-
implementation(libs.plugin.outdated)
19-
20-
implementation(libs.kotlinx.json)
11+
implementation(libs.plugin.updates)
12+
implementation(libs.plugin.build)
2113
}

buildSrc/settings.gradle.kts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
1+
@file:Suppress("UnstableApiUsage", "UNUSED_VARIABLE")
2+
3+
pluginManagement {
4+
repositories {
5+
gradlePluginPortal()
6+
mavenCentral()
7+
}
8+
}
9+
110
dependencyResolutionManagement {
211
versionCatalogs {
312
create("libs") {
413
from(files("../gradle/libs.versions.toml"))
514
}
615
}
16+
17+
repositories {
18+
gradlePluginPortal()
19+
mavenCentral()
20+
maven {
21+
url = uri("https://central.sonatype.com/repository/maven-snapshots")
22+
mavenContent {
23+
snapshotsOnly()
24+
}
25+
}
26+
}
727
}
Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
11
import org.gradle.api.Project
22

3-
fun Project.buildProperty(property: String): String {
4-
val prop: String? = findProperty(property) as String?
5-
if(prop != null) {
6-
return prop
7-
}
8-
9-
val env: String? = System.getenv(property)
10-
if (env != null) {
11-
return env
12-
}
13-
14-
return "n/a"
15-
}
16-
17-
fun Project.buildSignKey(property: String): String {
18-
return buildProperty(property).replace("\\n", "\n")
19-
}
20-
21-
fun Project.isReleaseVersion(): Boolean {
22-
return !(version.toString().endsWith("SNAPSHOT"))
23-
}
24-
253
fun Project.isPlatform(): Boolean {
264
return pluginManager.hasPlugin("java-platform")
275
}

buildSrc/src/main/kotlin/openapi-parser.java-conventions.gradle.kts renamed to buildSrc/src/main/kotlin/openapiparser.library.gradle.kts

Lines changed: 60 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,24 @@
11
import com.github.benmanes.gradle.versions.reporter.PlainTextReporter
22
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
33
import org.gradle.accessors.dm.LibrariesForLibs
4+
import org.gradle.jvm.toolchain.JavaLanguageVersion
5+
import org.gradle.kotlin.dsl.withType
46

57
plugins {
68
`java-library`
79
jacoco
8-
kotlin("jvm")
9-
10+
kotlin
1011
id("org.checkerframework")
1112
id("com.github.ben-manes.versions")
1213
}
1314

14-
// see buildSrc/build.gradle catalog hack
15+
// see buildSrc/build.gradle.kts
1516
val libs = the<LibrariesForLibs>()
1617

1718
group = "io.openapiprocessor"
1819
version = libs.versions.openapiparser.get()
1920
println("version: $version")
2021

21-
repositories {
22-
mavenCentral()
23-
}
24-
25-
dependencies {
26-
checkerFramework(libs.checker)
27-
compileOnly(libs.checkerq)
28-
29-
testImplementation(platform(libs.kotest.bom))
30-
testImplementation(libs.kotest.runner)
31-
testImplementation(libs.kotest.table)
32-
testImplementation(libs.mockk)
33-
testCompileOnly(libs.checkerq)
34-
}
35-
3622
java {
3723
withJavadocJar()
3824
withSourcesJar()
@@ -43,46 +29,42 @@ java {
4329
}
4430

4531
kotlin {
46-
jvmToolchain {
47-
languageVersion.set(JavaLanguageVersion.of(libs.versions.build.jdk.get()))
48-
}
49-
}
32+
jvmToolchain(libs.versions.build.jdk.get().toInt())
5033

51-
//tasks.getByName<Test>("test") {
52-
// useJUnitPlatform()
53-
//}
54-
55-
tasks.withType<Test>().configureEach {
56-
useJUnitPlatform()
57-
58-
javaLauncher.set(javaToolchains.launcherFor {
59-
languageVersion.set(JavaLanguageVersion.of(libs.versions.test.jdk.get()))
60-
})
61-
62-
finalizedBy(tasks.named("jacocoTestReport"))
34+
compilerOptions {
35+
freeCompilerArgs.add("-Xannotation-default-target=param-property")
36+
}
6337
}
6438

65-
tasks.withType<JavaCompile>().configureEach {
66-
options.compilerArgs.add("-Xlint:deprecation")
39+
repositories {
40+
mavenCentral()
41+
maven {
42+
url = uri("https://central.sonatype.com/repository/maven-snapshots")
43+
mavenContent {
44+
snapshotsOnly()
45+
}
46+
}
6747
}
6848

69-
tasks.withType<JavaExec>().configureEach {
70-
args("-ea")
49+
dependencies {
50+
checkerFramework(libs.checker)
51+
compileOnly(libs.checkerq)
7152
}
7253

7354
jacoco {
7455
toolVersion = libs.versions.jacoco.get()
7556
}
7657

77-
tasks.jacocoTestReport {
58+
tasks.named<JacocoReport>("jacocoTestReport") {
7859
reports {
7960
xml.required.set(true)
8061
csv.required.set(false)
8162
html.required.set(false)
82-
// html.outputLocation.set(layout.buildDirectory.dir("jacocoHtml"))
63+
//html.outputLocation.set(layout.buildDirectory.dir("jacocoHtml"))
8364
}
8465
}
8566

67+
8668
configure<org.checkerframework.gradle.plugin.CheckerFrameworkExtension> {
8769
// skipCheckerFramework = true
8870
// excludeTests = true
@@ -96,12 +78,9 @@ configure<org.checkerframework.gradle.plugin.CheckerFrameworkExtension> {
9678
)
9779
}
9880

99-
100-
101-
102-
10381
tasks.withType<DependencyUpdatesTask> {
10482
rejectVersionIf {
83+
println("candidate: $candidate stable: ${!candidate.version.isNonStable()}")
10584
candidate.version.isNonStable()
10685
}
10786

@@ -117,17 +96,37 @@ tasks.withType<DependencyUpdatesTask> {
11796
}
11897
}
11998

99+
tasks.withType<Test>().configureEach {
100+
jvmArgs(listOf(
101+
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
102+
"--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
103+
"--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
104+
"--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
105+
"--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
106+
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
107+
))
108+
109+
javaLauncher.set(javaToolchains.launcherFor {
110+
languageVersion.set(JavaLanguageVersion.of(libs.versions.test.jdk.get()))
111+
})
112+
113+
finalizedBy(tasks.named("jacocoTestReport"))
114+
}
115+
116+
117+
120118

121119
fun String.isNonStable(): Boolean {
122120
val nonStable = listOf(
123121
".M[0-9]+$",
124122
".RC[0-9]*$",
125-
".alpha[0-9]+$",
126-
".beta[0-9]+$",
123+
".alpha.?[0-9]+$",
124+
".beta.?[0-9]+$",
127125
)
128126

129127
for (n in nonStable) {
130128
if (this.contains("(?i)$n".toRegex())) {
129+
//println("not stable: $this")
131130
return true
132131
}
133132
}
@@ -138,3 +137,18 @@ fun String.isNonStable(): Boolean {
138137
val ignore = listOf(
139138
"org.checkerframework:jdk8"
140139
)
140+
141+
/*
142+
configure<CheckerFrameworkExtension> {
143+
skipCheckerFramework = true
144+
excludeTests = true
145+
extraJavacArgs = listOf("-Awarns")
146+
147+
checkers = listOf(
148+
"org.checkerframework.checker.nullness.NullnessChecker",
149+
// "org.checkerframework.checker.interning.InterningChecker",
150+
// "org.checkerframework.checker.resourceleak.ResourceLeakChecker",
151+
// "org.checkerframework.checker.index.IndexChecker"
152+
)
153+
}
154+
*/
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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
5+
import org.gradle.accessors.dm.LibrariesForLibs
6+
7+
plugins {
8+
id("io.openapiprocessor.build.plugin.publish-central")
9+
}
10+
11+
// see buildSrc/build.gradle.kts
12+
val libs = the<LibrariesForLibs>()
13+
14+
val componentName = if (isPlatform()) { "javaPlatform" } else { "java" }
15+
16+
publishing {
17+
publications {
18+
create<MavenPublication>("openapiparser") {
19+
from(components[componentName])
20+
21+
pom {
22+
pom.initFrom(getPomProperties(project))
23+
}
24+
}
25+
}
26+
27+
repositories {
28+
sonatype(project)
29+
}
30+
}
31+
32+
signing {
33+
initSignKey()
34+
sign(publishing.publications["openapiparser"])
35+
}
36+
37+
publishProcessor {
38+
publish = true
39+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@file:Suppress("UnstableApiUsage", "UNUSED_VARIABLE")
2+
3+
import org.gradle.accessors.dm.LibrariesForLibs
4+
5+
plugins {
6+
java
7+
groovy
8+
kotlin
9+
}
10+
11+
// see buildSrc/build.gradle.kts
12+
val libs = the<LibrariesForLibs>()
13+
14+
testing {
15+
suites {
16+
val test by getting(JvmTestSuite::class) {
17+
useJUnitJupiter(libs.versions.junit.get())
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
testImplementation(platform(libs.kotest.bom))
24+
testImplementation(libs.kotest.runner)
25+
testImplementation(libs.kotest.table)
26+
testImplementation(libs.mockk)
27+
testCompileOnly(libs.checkerq)
28+
}

gradle.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
projectGroupId=io.openapiprocessor
2+
3+
projectUrl=https://github.com/openapi-processor/openapi-parser
4+
projectTitle=openapi-parser
5+
projectDesc=OpenAPI 3.0/3.1 parser
6+
projectRepo=openapi-processor/openapi-parser
7+
18
# avoids kotlin stdlib in published pom, kotlin is only used for testing
29
kotlin.stdlib.default.dependency = false
310

0 commit comments

Comments
 (0)