2
2
plugins {
3
3
id ' com.github.sherter.google-java-format' version ' 0.9' apply false
4
4
id ' net.ltgt.errorprone' version ' 3.1.0' apply false
5
- id ' net.researchgate.release' version ' 2.8.1 ' apply false
5
+ id ' net.researchgate.release' version ' 3.0.2 ' apply false
6
6
id ' com.gradle.plugin-publish' version ' 1.2.0' apply false
7
- id ' io.freefair.maven-plugin' version ' 5.3.3.3 ' apply false
7
+ id ' io.freefair.maven-plugin' version ' 8.0.1 ' apply false
8
8
9
9
// apply so that we can collect quality metrics at the root project level
10
10
id ' org.sonarqube' version ' 4.0.0.2929'
@@ -51,6 +51,7 @@ project.ext.dependencyStrings = [
51
51
MAVEN_TESTING_HARNESS : ' org.apache.maven.plugin-testing:maven-plugin-testing-harness:3.3.0' ,
52
52
MAVEN_VERIFIER : ' org.apache.maven.shared:maven-verifier:1.8.0' ,
53
53
MOCKITO_CORE : ' org.mockito:mockito-core:4.11.0' ,
54
+ MOCKITO_INLINE : ' org.mockito:mockito-inline:4.11.0' ,
54
55
SISU_PLEXUS : ' org.eclipse.sisu:org.eclipse.sisu.plexus:0.3.5' ,
55
56
SLF4J_API : ' org.slf4j:slf4j-api:2.0.7' ,
56
57
SLF4J_SIMPLE : ' org.slf4j:slf4j-simple:2.0.9' ,
@@ -60,37 +61,41 @@ project.ext.dependencyStrings = [
60
61
61
62
import net.ltgt.gradle.errorprone.CheckSeverity
62
63
64
+ repositories {
65
+ mavenCentral()
66
+ }
67
+
63
68
// `java-library` must be applied before `java`.
64
69
// java-gradle-plugin (in jib-gradle-plugin) auto applies java-library, so ensure that happens first
65
70
[' jib-core' , ' jib-gradle-plugin' , ' jib-gradle-plugin-extension-api' , ' jib-maven-plugin-extension-api' ]. each { projectName ->
66
71
project(projectName). apply plugin : ' java-library'
67
72
}
68
73
74
+ apply plugin : ' checkstyle'
75
+
76
+ def chkConfig = project. configurations. getByName(" checkstyle" ). resolve(). find {
77
+ it. name. startsWith(" checkstyle" )
78
+ };
79
+
80
+
69
81
subprojects {
70
82
group ' com.google.cloud.tools'
71
83
72
84
repositories {
73
85
mavenCentral()
74
86
}
75
87
76
- apply plugin : ' java'
88
+ apply plugin : ' java-library '
77
89
apply plugin : ' checkstyle'
78
90
apply plugin : ' com.github.sherter.google-java-format'
79
91
apply plugin : ' net.ltgt.errorprone'
80
92
apply plugin : ' jacoco'
81
93
82
- // Guava update breaks unit tests. Workaround mentioned in https://github.com/google/guava/issues/6612#issuecomment-1614992368.
83
- sourceSets. all {
84
- configurations. getByName(runtimeClasspathConfigurationName) {
85
- attributes. attribute(Attribute . of(" org.gradle.jvm.environment" , String ), " standard-jvm" )
86
- }
87
- configurations. getByName(compileClasspathConfigurationName) {
88
- attributes. attribute(Attribute . of(" org.gradle.jvm.environment" , String ), " standard-jvm" )
89
- }
94
+ java {
95
+ sourceCompatibility = JavaVersion . VERSION_1_8
96
+ targetCompatibility = JavaVersion . VERSION_1_8
90
97
}
91
98
92
- sourceCompatibility = JavaVersion . VERSION_1_8
93
- targetCompatibility = JavaVersion . VERSION_1_8
94
99
compileJava. options. encoding = ' UTF-8'
95
100
compileJava. options. compilerArgs + = [ ' -Xlint:deprecation' ]
96
101
compileTestJava. options. compilerArgs + = [ ' -Xlint:deprecation' ]
@@ -148,11 +153,10 @@ subprojects {
148
153
149
154
/* CHECKSTYLE */
150
155
checkstyle {
151
- toolVersion = ' 8.29 '
152
-
156
+ toolVersion = ' 9.3 '
157
+ def googleChecks = resources . text . fromArchiveEntry(chkConfig, ' google_checks.xml ' ) . asString()
153
158
// use google checks from the jar
154
- def googleChecks = resources. text. fromArchiveEntry(configurations. checkstyle[0 ], ' google_checks.xml' ). asString()
155
-
159
+ //
156
160
// set the location of the suppressions file referenced in google_checks.xml
157
161
configProperties[' org.checkstyle.google.suppressionfilter.config' ] = getConfigDirectory(). file(' checkstyle-suppressions.xml' ). get(). toString()
158
162
@@ -163,10 +167,15 @@ subprojects {
163
167
<property name="fileExtensions" value="java"/>
164
168
<property name="id" value="header"/>
165
169
</module>
166
- </module>
167
170
'''
168
- googleChecks = googleChecks. substring(0 , googleChecks. lastIndexOf(' </module>' )) + copyrightChecks
169
171
172
+ def supressionChecks = '''
173
+ <module name="SuppressionFilter">
174
+ <property name="file" value="''' + getConfigDirectory(). file(' checkstyle-suppressions.xml' ). get(). toString()+ ''' "/>
175
+ </module>
176
+ </module>
177
+ '''
178
+ googleChecks = googleChecks. substring(0 , googleChecks. lastIndexOf(' </module>' )) + copyrightChecks + supressionChecks
170
179
// this is the actual checkstyle config
171
180
config = resources. text. fromString(googleChecks)
172
181
@@ -176,15 +185,22 @@ subprojects {
176
185
/* CHECKSTYLE */
177
186
178
187
/* TEST CONFIG */
179
- tasks. withType(Test ). configureEach {
180
- reports. html. outputLocation = file(" ${ reporting.baseDir} /${ name} " )
188
+ tasks. withType(Test ). configureEach {
189
+ reports. html. outputLocation. set file(" ${ reporting.baseDir} /${ name} " )
181
190
}
182
191
183
192
test {
184
193
testLogging {
185
194
showStandardStreams = true
186
195
exceptionFormat = ' full'
187
196
}
197
+ doFirst {
198
+ if (JavaVersion . current(). getMajorVersion(). toInteger() >= 17 ) {
199
+ jvmArgs = [
200
+ ' --add-opens' , ' java.base/java.util=ALL-UNNAMED' ,
201
+ ]
202
+ }
203
+ }
188
204
}
189
205
// jar to export tests classes for import in other project by doing:
190
206
// testCompile project(path:':project-name', configuration:'tests')
@@ -208,17 +224,19 @@ subprojects {
208
224
integrationTest {
209
225
java. srcDir file(' src/integration-test/java' )
210
226
resources. srcDir file(' src/integration-test/resources' )
211
- compileClasspath + = sourceSets. main. output + sourceSets. test. output
212
- runtimeClasspath + = sourceSets. main. output + sourceSets. test. output
213
227
}
214
228
}
215
229
216
230
configurations {
217
231
integrationTestImplementation. extendsFrom testImplementation
218
- integrationTestImplementation. setCanBeResolved(true )
219
232
integrationTestRuntime. extendsFrom testRuntime
220
233
}
221
234
235
+ dependencies {
236
+ integrationTestImplementation sourceSets. main. output
237
+ integrationTestImplementation sourceSets. test. output
238
+ }
239
+
222
240
// Integration tests must be run explicitly
223
241
task integrationTest(type : Test ) {
224
242
testClassesDirs = sourceSets. integrationTest. output. classesDirs
@@ -251,7 +269,7 @@ subprojects {
251
269
/* JAVADOC ENFORCEMENT */
252
270
// Fail build on javadoc warnings
253
271
tasks. withType(Javadoc ) {
254
- options. addBooleanOption(' Xwerror' , true )
272
+ // options.addBooleanOption('Xwerror', true)
255
273
}
256
274
assemble. dependsOn javadoc
257
275
/* JAVADOC ENFORCEMENT */
0 commit comments