Skip to content

Commit 6b75e05

Browse files
committed
Fix deprecation warning in ThirdpartyAuditTask (#57123)
1 parent fdac9e9 commit 6b75e05

30 files changed

+124
-36
lines changed

buildSrc/build.gradle

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@ import org.gradle.util.GradleVersion
2323
plugins {
2424
id 'java-gradle-plugin'
2525
id 'groovy'
26+
id 'java-test-fixtures'
2627
}
2728

2829
group = 'org.elasticsearch.gradle'
2930

31+
String minimumGradleVersion = file('src/main/resources/minimumGradleVersion').text.trim()
32+
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
33+
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch")
34+
}
35+
3036
if (project == rootProject) {
3137
// change the build dir used during build init, so that doing a clean
3238
// won't wipe out the buildscript jar
@@ -64,6 +70,11 @@ if (JavaVersion.current() < JavaVersion.VERSION_11) {
6470
sourceSets {
6571
// We have a few classes that need to be compiled for older java versions
6672
minimumRuntime {}
73+
74+
integTest {
75+
compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
76+
runtimeClasspath += output + compileClasspath
77+
}
6778
}
6879

6980
configurations {
@@ -117,8 +128,10 @@ dependencies {
117128
compile 'com.networknt:json-schema-validator:1.0.36'
118129
compileOnly "com.puppycrawl.tools:checkstyle:${props.getProperty('checkstyle')}"
119130
testCompile "com.puppycrawl.tools:checkstyle:${props.getProperty('checkstyle')}"
120-
testCompile "junit:junit:${props.getProperty('junit')}"
121-
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
131+
testFixturesApi "junit:junit:${props.getProperty('junit')}"
132+
testFixturesApi "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
133+
testFixturesApi gradleApi()
134+
testFixturesApi gradleTestKit()
122135
testCompile 'com.github.tomakehurst:wiremock-jre8-standalone:2.23.2'
123136
testCompile 'org.mockito:mockito-core:1.9.5'
124137
minimumRuntimeCompile "junit:junit:${props.getProperty('junit')}"
@@ -165,10 +178,11 @@ if (project != rootProject) {
165178
// build-tools is not ready for primetime with these...
166179
dependencyLicenses.enabled = false
167180
dependenciesInfo.enabled = false
168-
disableTasks('forbiddenApisMain', 'forbiddenApisMinimumRuntime', 'forbiddenApisTest')
181+
disableTasks('forbiddenApisMain', 'forbiddenApisMinimumRuntime',
182+
'forbiddenApisTest', 'forbiddenApisIntegTest', 'forbiddenApisTestFixtures')
169183
jarHell.enabled = false
170184
thirdPartyAudit.enabled = false
171-
if (Boolean.parseBoolean(System.getProperty("tests.fips.enabled"))){
185+
if (Boolean.parseBoolean(System.getProperty("tests.fips.enabled"))) {
172186
test.enabled = false
173187
}
174188

@@ -237,6 +251,8 @@ if (project != rootProject) {
237251
systemProperty 'test.version_under_test', version
238252
onlyIf { org.elasticsearch.gradle.info.BuildParams.inFipsJvm == false }
239253
maxParallelForks = System.getProperty('tests.jvms', org.elasticsearch.gradle.info.BuildParams.defaultParallel.toString()) as Integer
254+
testClassesDirs = sourceSets.integTest.output.classesDirs
255+
classpath = sourceSets.integTest.runtimeClasspath
240256
}
241257
check.dependsOn("integTest")
242258

@@ -252,6 +268,11 @@ if (project != rootProject) {
252268
afterEvaluate {
253269
generatePomFileForPluginMavenPublication.enabled = false
254270
}
271+
272+
publishing.publications.named("nebula").configure {
273+
suppressPomMetadataWarningsFor("testFixturesApiElements")
274+
suppressPomMetadataWarningsFor("testFixturesRuntimeElements")
275+
}
255276
}
256277

257278
// Define this here because we need it early.

buildSrc/src/test/java/org/elasticsearch/gradle/AdoptOpenJdkDownloadPluginIT.java renamed to buildSrc/src/integTest/java/org/elasticsearch/gradle/AdoptOpenJdkDownloadPluginIT.java

File renamed without changes.

buildSrc/src/test/java/org/elasticsearch/gradle/BuildPluginIT.java renamed to buildSrc/src/integTest/java/org/elasticsearch/gradle/BuildPluginIT.java

File renamed without changes.

buildSrc/src/test/java/org/elasticsearch/gradle/DistributionDownloadPluginIT.java renamed to buildSrc/src/integTest/java/org/elasticsearch/gradle/DistributionDownloadPluginIT.java

File renamed without changes.

buildSrc/src/test/java/org/elasticsearch/gradle/ExportElasticsearchBuildResourcesTaskIT.java renamed to buildSrc/src/integTest/java/org/elasticsearch/gradle/ExportElasticsearchBuildResourcesTaskIT.java

File renamed without changes.

buildSrc/src/test/java/org/elasticsearch/gradle/JdkDownloadPluginIT.java renamed to buildSrc/src/integTest/java/org/elasticsearch/gradle/JdkDownloadPluginIT.java

File renamed without changes.

buildSrc/src/test/java/org/elasticsearch/gradle/OpenJdkDownloadPluginIT.java renamed to buildSrc/src/integTest/java/org/elasticsearch/gradle/OpenJdkDownloadPluginIT.java

File renamed without changes.

buildSrc/src/test/java/org/elasticsearch/gradle/ReaperPluginIT.java renamed to buildSrc/src/integTest/java/org/elasticsearch/gradle/ReaperPluginIT.java

File renamed without changes.

buildSrc/src/test/java/org/elasticsearch/gradle/precommit/TestingConventionsTasksIT.java renamed to buildSrc/src/integTest/java/org/elasticsearch/gradle/precommit/TestingConventionsTasksIT.java

File renamed without changes.

buildSrc/src/test/java/org/elasticsearch/gradle/precommit/ThirdPartyAuditTaskIT.java renamed to buildSrc/src/integTest/java/org/elasticsearch/gradle/precommit/ThirdPartyAuditTaskIT.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
package org.elasticsearch.gradle.precommit;
2-
3-
import org.elasticsearch.gradle.test.GradleIntegrationTestCase;
4-
import org.gradle.testkit.runner.BuildResult;
5-
import org.junit.Before;
6-
71
/*
82
* Licensed to Elasticsearch under one or more contributor
93
* license agreements. See the NOTICE file distributed with
@@ -13,7 +7,7 @@
137
* not use this file except in compliance with the License.
148
* You may obtain a copy of the License at
159
*
16-
* http://www.apache.org/licenses/LICENSE-2.0
10+
* http://www.apache.org/licenses/LICENSE-2.0
1711
*
1812
* Unless required by applicable law or agreed to in writing,
1913
* software distributed under the License is distributed on an
@@ -22,6 +16,13 @@
2216
* specific language governing permissions and limitations
2317
* under the License.
2418
*/
19+
20+
package org.elasticsearch.gradle.precommit;
21+
22+
import org.elasticsearch.gradle.test.GradleIntegrationTestCase;
23+
import org.gradle.testkit.runner.BuildResult;
24+
import org.junit.Before;
25+
2526
public class ThirdPartyAuditTaskIT extends GradleIntegrationTestCase {
2627

2728
@Before
@@ -41,6 +42,7 @@ public void testElasticsearchIgnored() {
4142
"-PcompileVersion=0.0.1"
4243
).build();
4344
assertTaskNoSource(result, ":empty");
45+
assertNoDeprecationWarning(result);
4446
}
4547

4648
public void testWithEmptyRules() {
@@ -69,6 +71,7 @@ public void testViolationFoundAndCompileOnlyIgnored() {
6971
assertTaskFailed(result, ":absurd");
7072
assertOutputContains(result.getOutput(), "Classes with violations:", " * TestingIO", "> Audit of third party dependencies failed");
7173
assertOutputDoesNotContain(result.getOutput(), "Missing classes:");
74+
assertNoDeprecationWarning(result);
7275
}
7376

7477
public void testClassNotFoundAndCompileOnlyIgnored() {
@@ -90,6 +93,7 @@ public void testClassNotFoundAndCompileOnlyIgnored() {
9093
"> Audit of third party dependencies failed"
9194
);
9295
assertOutputDoesNotContain(result.getOutput(), "Classes with violations:");
96+
assertNoDeprecationWarning(result);
9397
}
9498

9599
public void testJarHellWithJDK() {
@@ -111,6 +115,7 @@ public void testJarHellWithJDK() {
111115
" * java.lang.String"
112116
);
113117
assertOutputDoesNotContain(result.getOutput(), "Classes with violations:");
118+
assertNoDeprecationWarning(result);
114119
}
115120

116121
public void testElasticsearchIgnoredWithViolations() {
@@ -124,6 +129,7 @@ public void testElasticsearchIgnoredWithViolations() {
124129
"-PcompileVersion=0.0.1"
125130
).build();
126131
assertTaskNoSource(result, ":absurd");
132+
assertNoDeprecationWarning(result);
127133
}
128134

129135
}

0 commit comments

Comments
 (0)