This repository has been archived by the owner on Dec 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
/
build.gradle
261 lines (235 loc) · 8.14 KB
/
build.gradle
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
plugins {
id "groovy"
id "checkstyle"
id "codenarc"
id "idea"
// id "jacoco"
id "maven-publish"
id "signing"
id "java-gradle-plugin"
id "org.nosphere.gradle.github.actions" version "1.2.0"
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
// id "pl.droidsonroids.jacoco.testkit" version "1.0.8"
}
// Gradle TestKit (which most of this plugins tests run using) runs the builds in a separate
// JVM than the tests. Thus, for Jacoco to pick up on it, you need to do some extra legwork.
// https://github.com/koral--/jacoco-gradle-testkit-plugin seeks to solve that
// However, Gradle 7.1 doesn't currently support the combination of the configuration cache
// with a Java agent (such as Jacoco) and TestKit.
// Thus, for now, no coverage reporting, as I place a higher value on testing configuration cache
// support.
group = "com.github.davidmc24.gradle.plugin"
version = "1.9.2-SNAPSHOT"
def isCI = System.getenv("CI") == "true"
repositories {
mavenCentral()
maven {
// Used for snapshot builds for some libraries
name 'Sonatype OSS'
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
def compileAvroVersion = "1.11.3"
// Write the plugin's classpath to a file to share with the tests
task createClasspathManifest {
def outputDir = file("$buildDir/$name")
inputs.files sourceSets.main.runtimeClasspath
outputs.dir outputDir
doLast {
outputDir.mkdirs()
file("$outputDir/plugin-classpath.txt").text = sourceSets.main.runtimeClasspath.join("\n")
}
}
dependencies {
implementation localGroovy()
implementation "org.apache.avro:avro-compiler:${compileAvroVersion}"
constraints {
implementation ('com.fasterxml.jackson.core:jackson-databind:2.12.7.1') {
because 'previous versions have vulnerabilities: CVE-2022-42004, CVE-2022-42003'
}
implementation ('org.apache.commons:commons-text:1.10.0') {
because 'previous versions have vulnerability: CVE-2022-42889'
}
implementation ('org.apache.commons:commons-compress:1.24.0') {
because 'previous versions have vulnerability: CVE-2023-42503'
}
}
testImplementation "org.spockframework:spock-core:2.0-M5-groovy-3.0"
testImplementation gradleTestKit()
testImplementation "uk.co.datumedge:hamcrest-json:0.2"
testImplementation "com.vdurmont:semver4j:3.1.0"
testRuntimeOnly files(createClasspathManifest) // Add the classpath file to the test runtime classpath
// tool version specified in dependencies in order to override Groovy version for Java compatibility
codenarc "org.codenarc:CodeNarc:2.2.0"
codenarc "org.codehaus.groovy:groovy-all:3.0.9"
}
tasks.withType(AbstractCompile) {
options.encoding = "UTF-8"
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:all" << "-Xlint:-options" << "-Werror"
}
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
java {
withJavadocJar()
withSourcesJar()
}
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
options.addStringOption('Xdoclint:none', '-quiet')
}
publishing {
publications.withType(MavenPublication) {
pom {
name = "gradle-avro-plugin"
description = "A Gradle plugin to allow easily performing Java code generation for Apache Avro. It supports JSON schema declaration files, JSON protocol declaration files, and Avro IDL files."
url = "https://github.com/davidmc24/gradle-avro-plugin"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = 'davidmc24'
name = 'David M. Carr'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:https://github.com/davidmc24/gradle-avro-plugin.git'
developerConnection = 'scm:git:ssh://github.com/davidmc24/gradle-avro-plugin.git'
url = 'https://github.com/davidmc24/gradle-avro-plugin'
}
}
}
}
nexusPublishing {
repositories {
sonatype()
}
}
signing {
if (isCI) {
def signingKeyId = System.getenv("SIGNING_KEY_ID")
def signingKey = System.getenv("SIGNING_KEY")
def signingPassword = System.getenv("SIGNING_PASSWORD")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
}
publishing.publications.all { publication ->
sign publication
}
}
gradlePlugin {
plugins {
avro {
id = "com.github.davidmc24.gradle.plugin.avro"
implementationClass = "com.github.davidmc24.gradle.plugin.avro.AvroPlugin"
displayName = "avro"
description = "Conventions plugin for gradle-avro-plugin"
}
avroBase {
id = "com.github.davidmc24.gradle.plugin.avro-base"
implementationClass = "com.github.davidmc24.gradle.plugin.avro.AvroBasePlugin"
displayName = "avro-base"
description = "Capabilities plugin for gradle-avro-plugin"
}
}
}
idea {
project {
vcs = "Git"
ipr {
withXml { provider ->
def node = provider.asNode()
node.append(new XmlParser().parseText("""
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value>
<option name="LINE_SEPARATOR" value=" "/>
<option name="RIGHT_MARGIN" value="140"/>
</value>
</option>
<option name="USE_PER_PROJECT_SETTINGS" value="true"/>
</component>
""".stripIndent()))
}
}
}
}
checkstyle {
ignoreFailures = false
maxErrors = 0
maxWarnings = 0
showViolations = true
toolVersion = "8.23"
}
// In Gradle 4.8 the checkstyle basedir changed to no longer be the project root by default; thus we need to specify
checkstyleMain {
configProperties = ['basedir': "$rootDir/config/checkstyle"]
}
checkstyleTest {
configProperties = ['basedir': "$rootDir/config/checkstyle"]
}
codenarc {
config = project.resources.text.fromFile("config/codenarc/codenarc.groovy")
ignoreFailures = false
maxPriority1Violations = 0
maxPriority2Violations = 0
maxPriority3Violations = 0
// tool version specified in dependencies in order to override Groovy version for Java compatibility
// toolVersion = "2.2.0"
}
// Java 8+ is required due to requirements introduced in Avro 1.9.0
// Java 8+ is also required by Gradle 5.x
if (JavaVersion.current().java10Compatible) {
compileJava {
options.release = 8
}
} else {
sourceCompatibility = 8
}
test {
useJUnitPlatform()
systemProperties = [
avroVersion: compileAvroVersion,
gradleVersion: gradle.gradleVersion,
]
// finalizedBy jacocoTestReport // report is always generated after tests run
}
tasks.create(name: "testCompatibility", type: Test) {
description = "Test cross-compatibility of the plugin with Avro/Gradle"
group = "Verification"
useJUnitPlatform()
systemProperties = [
avroVersion: findProperty("avroVersion"),
gradleVersion: findProperty("gradleVersion"),
]
reports {
html.destination = file("$buildDir/reports/tests/compatibility")
junitXml.destination = file("$buildDir/reports/tests/compatibility")
}
}
//jacoco {
// // 0.8.7+ needed for Java 15 support
// // See https://www.jacoco.org/jacoco/trunk/doc/changes.html
// toolVersion = "0.8.7-SNAPSHOT"
//}
//jacocoTestReport {
// reports {
// html.enabled true
// xml.enabled true
// }
//}
tasks.withType(Test) {
jvmArgs "-Xss320k"
minHeapSize "120m"
maxHeapSize "280m"
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
}