-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle.kts
172 lines (145 loc) · 5.84 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import nebula.plugin.contacts.Contact
import nebula.plugin.contacts.ContactsExtension
import nebula.plugin.release.NetflixOssStrategies.SNAPSHOT
import nebula.plugin.release.git.base.ReleasePluginExtension
import nl.javadude.gradle.plugins.license.LicenseExtension
import java.util.*
plugins {
`java-library`
signing
id("com.netflix.nebula.maven-resolved-dependencies") version "21.0.0"
id("com.netflix.nebula.release") version "19.0.10"
id("io.github.gradle-nexus.publish-plugin") version "1.0.0"
id("com.github.hierynomus.license") version "0.16.1"
id("com.github.jk1.dependency-license-report") version "1.16"
id("org.owasp.dependencycheck") version "latest.release"
id("com.netflix.nebula.maven-publish") version "21.0.0"
id("com.netflix.nebula.contacts") version "7.0.1"
id("com.netflix.nebula.info") version "13.1.2"
id("com.netflix.nebula.javadoc-jar") version "21.0.0"
id("com.netflix.nebula.source-jar") version "21.0.0"
id("com.netflix.nebula.maven-apache-license") version "21.0.0"
}
group = "org.openrewrite"
description = "Auto-templating for rewrite-java."
apply(plugin = "com.netflix.nebula.publish-verification")
configure<ReleasePluginExtension> {
defaultVersionStrategy = SNAPSHOT(project)
}
dependencyCheck {
analyzers.assemblyEnabled = false
suppressionFile = "suppressions.xml"
failBuildOnCVSS = 9.0F
nvd.apiKey = System.getenv("NVD_API_KEY")
}
repositories {
mavenLocal()
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
mavenCentral()
}
configurations.all {
resolutionStrategy {
cacheChangingModulesFor(0, TimeUnit.SECONDS)
cacheDynamicVersionsFor(0, TimeUnit.SECONDS)
}
}
nexusPublishing {
repositories {
sonatype()
}
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
val compiler = javaToolchains.compilerFor {
languageVersion.set(JavaLanguageVersion.of(8))
}
val tools = compiler.get().metadata.installationPath.file("lib/tools.jar")
dependencies {
compileOnly(files(tools))
compileOnly("org.jetbrains:annotations:24.0.+")
compileOnly("org.projectlombok:lombok:latest.release")
annotationProcessor("org.projectlombok:lombok:latest.release")
compileOnly("org.openrewrite:rewrite-java:latest.release")
implementation("org.jspecify:jspecify:latest.release")
// Needed for annotation processing tests
testImplementation(files(tools))
testImplementation("org.openrewrite:rewrite-java:latest.integration")
testImplementation("org.openrewrite:rewrite-test:latest.integration")
testRuntimeOnly("org.openrewrite:rewrite-java-8:latest.integration")
// Skip `2.1.0-alpha0` for now over "class file has wrong version 55.0, should be 52.0"
testImplementation("org.slf4j:slf4j-api:2.0.+")
testImplementation("com.google.testing.compile:compile-testing:latest.release")
testImplementation("jakarta.annotation:jakarta.annotation-api:2.+")
testImplementation("org.junit.jupiter:junit-jupiter-api:latest.release")
testImplementation("org.junit.jupiter:junit-jupiter-params:latest.release")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:latest.release")
}
tasks.withType<Test> {
useJUnitPlatform()
// enforce reading resources as UTF-8 also on JDKs before Java 18
systemProperty("file.encoding", "UTF-8")
}
tasks.withType<Javadoc> {
// assertTrue(boolean condition) -> assertThat(condition).isTrue()
// warning - invalid usage of tag >
// see also: https://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
}
configure<ContactsExtension> {
val j = Contact("team@moderne.io")
j.moniker("Team Moderne")
people["team@moderne.io"] = j
}
configure<LicenseExtension> {
ext.set("year", Calendar.getInstance().get(Calendar.YEAR))
skipExistingHeaders = true
header = project.rootProject.file("gradle/licenseHeader.txt")
mapping(kotlin.collections.mapOf("kt" to "SLASHSTAR_STYLE", "java" to "SLASHSTAR_STYLE"))
strictCheck = true
exclude("recipes/")
}
configure<PublishingExtension> {
publications {
named("nebula", MavenPublication::class.java) {
suppressPomMetadataWarningsFor("runtimeElements")
pom.withXml {
(asElement().getElementsByTagName("dependencies")
.item(0) as org.w3c.dom.Element?)?.let { dependencies ->
dependencies.getElementsByTagName("dependency").let { dependencyList ->
var i = 0
var length = dependencyList.length
while (i < length) {
(dependencyList.item(i) as org.w3c.dom.Element).let { dependency ->
if ((dependency.getElementsByTagName("scope")
.item(0) as org.w3c.dom.Element).textContent == "provided"
) {
dependencies.removeChild(dependency)
i--
length--
}
}
i++
}
}
}
}
}
}
}
val signingKey: String? by project
val signingPassword: String? by project
val requireSigning = project.hasProperty("forceSigning") || project.hasProperty("releasing")
if (signingKey != null && signingPassword != null) {
signing {
isRequired = requireSigning
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["nebula"])
}
} else if (requireSigning) {
throw RuntimeException("Artifact signing is required, but signingKey and/or signingPassword are null")
}