Skip to content

Commit

Permalink
Remove deprecated usage of testCompile configuration (7.7 backport) (#…
Browse files Browse the repository at this point in the history
…58046)

* Remove deprecated usage of testCompile configuration (backport of #57921)
* Fix merge conflict
  • Loading branch information
breskeby authored Jun 14, 2020
1 parent 6b91f3f commit eddb9d1
Show file tree
Hide file tree
Showing 151 changed files with 438 additions and 412 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ known as "transitive" dependencies".</dd>
should not be shipped with the project because it is "provided" by the runtime
somehow. Elasticsearch plugins use this configuration to include dependencies
that are bundled with Elasticsearch's server.</dd>
<dt>`testCompile`</dt><dd>Code that is on the classpath for compiling tests
<dt>`testImplementation`</dt><dd>Code that is on the classpath for compiling tests
that are part of this project but not production code. The canonical example
of this is `junit`.</dd>
</dl>
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ dependencies {
compile 'org.apache.maven:maven-model:3.6.2'
compile 'com.networknt:json-schema-validator:1.0.36'
compileOnly "com.puppycrawl.tools:checkstyle:${props.getProperty('checkstyle')}"
testCompile "com.puppycrawl.tools:checkstyle:${props.getProperty('checkstyle')}"
testImplementation "com.puppycrawl.tools:checkstyle:${props.getProperty('checkstyle')}"
testFixturesApi "junit:junit:${props.getProperty('junit')}"
testFixturesApi "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
testFixturesApi gradleApi()
testFixturesApi gradleTestKit()
testCompile 'com.github.tomakehurst:wiremock-jre8-standalone:2.23.2'
testCompile 'org.mockito:mockito-core:1.9.5'
testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone:2.23.2'
testImplementation 'org.mockito:mockito-core:1.9.5'
minimumRuntimeCompile "junit:junit:${props.getProperty('junit')}"
minimumRuntimeCompile localGroovy()
minimumRuntimeCompile gradleApi()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ class PluginBuildPlugin implements Plugin<Project> {
project.dependencies {
if (BuildParams.internal) {
compileOnly project.project(':server')
testCompile project.project(':test:framework')
testImplementation project.project(':test:framework')
} else {
compileOnly "org.elasticsearch:elasticsearch:${project.versions.elasticsearch}"
testCompile "org.elasticsearch.test:framework:${project.versions.elasticsearch}"
testImplementation "org.elasticsearch.test:framework:${project.versions.elasticsearch}"
}
// we "upgrade" these optional deps to provided for plugins, since they will run
// with a full elasticsearch server that includes optional deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class StandaloneRestTestPlugin implements Plugin<Project> {

// create a compileOnly configuration as others might expect it
project.configurations.create("compileOnly")
project.dependencies.add('testCompile', project.project(':test:framework'))
project.dependencies.add('testImplementation', project.project(':test:framework'))

EclipseModel eclipse = project.extensions.getByType(EclipseModel)
eclipse.classpath.sourceSets = [testSourceSet]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TestWithDependenciesPlugin implements Plugin<Project> {
return
}

project.configurations.testCompile.dependencies.all { Dependency dep ->
project.configurations.testImplementation.dependencies.all { Dependency dep ->
// this closure is run every time a compile dependency is added
if (dep instanceof ProjectDependency && dep.dependencyProject.plugins.hasPlugin(PluginBuildPlugin)) {
project.gradle.projectsEvaluated {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.DependencySet;
import org.gradle.api.artifacts.ModuleDependency;
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.api.artifacts.ResolutionStrategy;
Expand Down Expand Up @@ -114,9 +115,24 @@ public void apply(Project project) {
public static void configureConfigurations(Project project) {
// we want to test compileOnly deps!
Configuration compileOnlyConfig = project.getConfigurations().getByName(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME);
Configuration testCompileConfig = project.getConfigurations().getByName(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME);
testCompileConfig.extendsFrom(compileOnlyConfig);

Configuration testImplementationConfig = project.getConfigurations().getByName(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME);
testImplementationConfig.extendsFrom(compileOnlyConfig);

// fail on using deprecated testCompile
project.getConfigurations().getByName(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME).withDependencies(new Action<DependencySet>() {
@Override
public void execute(DependencySet dependencies) {
if (dependencies.size() > 0) {
throw new GradleException(
"Usage of configuration "
+ JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME
+ " is no longer supported. Use "
+ JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME
+ " instead."
);
}
}
});
// we are not shipping these jars, we act like dumb consumers of these things
if (project.getPath().startsWith(":test:fixtures") || project.getPath().equals(":build-tools")) {
return;
Expand All @@ -130,7 +146,7 @@ public static void configureConfigurations(Project project) {
configuration.resolutionStrategy(ResolutionStrategy::failOnVersionConflict);
});

// force all dependencies added directly to compile/testCompile to be non-transitive, except for ES itself
// force all dependencies added directly to compile/testImplementation to be non-transitive, except for ES itself
Consumer<String> disableTransitiveDeps = configName -> {
Configuration config = project.getConfigurations().getByName(configName);
config.getDependencies().all(dep -> {
Expand All @@ -142,9 +158,9 @@ public static void configureConfigurations(Project project) {
});
};
disableTransitiveDeps.accept(JavaPlugin.COMPILE_CONFIGURATION_NAME);
disableTransitiveDeps.accept(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME);
disableTransitiveDeps.accept(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME);
disableTransitiveDeps.accept(JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME);
disableTransitiveDeps.accept(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME);
}

private static final Pattern LUCENE_SNAPSHOT_REGEX = Pattern.compile("\\w+-snapshot-([a-z0-9]+)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ private Set<String> runJdkJarHellCheck() throws IOException {
private Configuration getRuntimeConfiguration() {
Configuration runtime = getProject().getConfigurations().findByName("runtimeClasspath");
if (runtime == null) {
return getProject().getConfigurations().getByName("testCompile");
return getProject().getConfigurations().getByName("testCompileClasspath");
}
return runtime;
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/testKit/testingConventions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ allprojects {
jcenter()
}
dependencies {
testCompile "junit:junit:4.12"
testImplementation "junit:junit:4.12"
}

ext.licenseFile = file("$buildDir/dummy/license")
Expand Down
15 changes: 8 additions & 7 deletions client/rest-high-level/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,19 @@ dependencies {
compile project(':modules:rank-eval')
compile project(':modules:lang-mustache')

testCompile project(':client:test')
testCompile project(':test:framework')
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testCompile "junit:junit:${versions.junit}"

testImplementation project(':client:test')
testImplementation project(':test:framework')
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testImplementation "junit:junit:${versions.junit}"
//this is needed to make RestHighLevelClientTests#testApiNamingConventions work from IDEs
testCompile project(":rest-api-spec")
testImplementation project(":rest-api-spec")
// Needed for serialization tests:
// (In order to serialize a server side class to a client side class or the other way around)
testCompile(project(':x-pack:plugin:core')) {
testImplementation(project(':x-pack:plugin:core')) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-rest-high-level-client'
}
testCompile(project(':x-pack:plugin:eql'))
testImplementation(project(':x-pack:plugin:eql'))
}

processTestResources {
Expand Down
12 changes: 6 additions & 6 deletions client/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ dependencies {
compile "commons-codec:commons-codec:${versions.commonscodec}"
compile "commons-logging:commons-logging:${versions.commonslogging}"

testCompile project(":client:test")
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest:${versions.hamcrest}"
testCompile "org.elasticsearch:securemock:${versions.securemock}"
testCompile "org.elasticsearch:mocksocket:${versions.mocksocket}"
testImplementation project(":client:test")
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testImplementation "junit:junit:${versions.junit}"
testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}"
testImplementation "org.elasticsearch:securemock:${versions.securemock}"
testImplementation "org.elasticsearch:mocksocket:${versions.mocksocket}"
}

tasks.withType(CheckForbiddenApis) {
Expand Down
10 changes: 5 additions & 5 deletions client/sniffer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ dependencies {
compile "commons-logging:commons-logging:${versions.commonslogging}"
compile "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"

testCompile project(":client:test")
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testCompile "junit:junit:${versions.junit}"
testCompile "org.elasticsearch:securemock:${versions.securemock}"
testCompile "org.elasticsearch:mocksocket:${versions.mocksocket}"
testImplementation project(":client:test")
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testImplementation "junit:junit:${versions.junit}"
testImplementation "org.elasticsearch:securemock:${versions.securemock}"
testImplementation "org.elasticsearch:mocksocket:${versions.mocksocket}"
}

forbiddenApisMain {
Expand Down
6 changes: 3 additions & 3 deletions client/transport/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ dependencies {
compile project(":modules:percolator")
compile project(":modules:parent-join")
compile project(":modules:rank-eval")
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest:${versions.hamcrest}"
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testImplementation "junit:junit:${versions.junit}"
testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}"
}

dependencyLicenses {
Expand Down
6 changes: 3 additions & 3 deletions distribution/tools/launchers/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ apply plugin: 'elasticsearch.build'

dependencies {
compile parent.project('java-version-checker')
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest:${versions.hamcrest}"
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testImplementation "junit:junit:${versions.junit}"
testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}"
}

archivesBaseName = 'elasticsearch-launchers'
Expand Down
6 changes: 3 additions & 3 deletions distribution/tools/plugin-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ dependencies {
compileOnly project(":libs:elasticsearch-cli")
compile "org.bouncycastle:bcpg-fips:1.0.3"
compile "org.bouncycastle:bc-fips:1.0.1"
testCompile project(":test:framework")
testCompile 'com.google.jimfs:jimfs:1.1'
testCompile 'com.google.guava:guava:18.0'
testImplementation project(":test:framework")
testImplementation 'com.google.jimfs:jimfs:1.1'
testImplementation 'com.google.guava:guava:18.0'
}

dependencyLicenses {
Expand Down
8 changes: 4 additions & 4 deletions libs/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ dependencies {
// This dependency is used only by :libs:core for null-checking interop with other tools
compileOnly "com.google.code.findbugs:jsr305:3.0.2"

testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest:${versions.hamcrest}"
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testImplementation "junit:junit:${versions.junit}"
testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}"

if (!isEclipse) {
java9Compile sourceSets.main.output
}

testCompile(project(":test:framework")) {
testImplementation(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-core'
}
}
Expand Down
8 changes: 4 additions & 4 deletions libs/dissect/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/

dependencies {
testCompile(project(":test:framework")) {
testImplementation(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-dissect'
}
testCompile "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
testCompile "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
testCompile "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}"
testImplementation "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
testImplementation "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
testImplementation "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}"
}

forbiddenApisMain {
Expand Down
2 changes: 1 addition & 1 deletion libs/geo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ apply plugin: 'elasticsearch.build'
apply plugin: 'elasticsearch.publish'

dependencies {
testCompile(project(":test:framework")) {
testImplementation(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-geo'
}
}
Expand Down
2 changes: 1 addition & 1 deletion libs/grok/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {
// joni dependencies:
compile 'org.jruby.jcodings:jcodings:1.0.44'

testCompile(project(":test:framework")) {
testImplementation(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-grok'
}
}
Expand Down
8 changes: 4 additions & 4 deletions libs/nio/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ apply plugin: 'elasticsearch.publish'
dependencies {
compile project(':libs:elasticsearch-core')

testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest:${versions.hamcrest}"
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testImplementation "junit:junit:${versions.junit}"
testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}"

testCompile(project(":test:framework")) {
testImplementation(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-nio'
}
}
Expand Down
8 changes: 4 additions & 4 deletions libs/secure-sm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ apply plugin: 'elasticsearch.publish'
dependencies {
// do not add non-test compile dependencies to secure-sm without a good reason to do so

testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest:${versions.hamcrest}"
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testImplementation "junit:junit:${versions.junit}"
testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}"

testCompile(project(":test:framework")) {
testImplementation(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-secure-sm'
}
}
Expand Down
8 changes: 4 additions & 4 deletions libs/ssl-config/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ apply plugin: "elasticsearch.publish"
dependencies {
compile project(':libs:elasticsearch-core')

testCompile(project(":test:framework")) {
testImplementation(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-ssl-config'
}

testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest:${versions.hamcrest}"
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testImplementation "junit:junit:${versions.junit}"
testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}"
}


Expand Down
8 changes: 4 additions & 4 deletions libs/x-content/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ dependencies {
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.jackson}"
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}"

testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest:${versions.hamcrest}"
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testImplementation "junit:junit:${versions.junit}"
testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}"

testCompile(project(":test:framework")) {
testImplementation(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-x-content'
}

Expand Down
4 changes: 2 additions & 2 deletions modules/ingest-geoip/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {
compile("com.fasterxml.jackson.core:jackson-databind:${versions.jackson}")
compile('com.maxmind.db:maxmind-db:1.3.1')

testCompile 'org.elasticsearch:geolite2-databases:20191119'
testImplementation 'org.elasticsearch:geolite2-databases:20191119'
}

restResources {
Expand All @@ -41,7 +41,7 @@ restResources {
}

task copyDefaultGeoIp2DatabaseFiles(type: Copy) {
from { zipTree(configurations.testCompile.files.find { it.name.contains('geolite2-databases') }) }
from { zipTree(configurations.testCompileClasspath.files.find { it.name.contains('geolite2-databases') }) }
into "${project.buildDir}/ingest-geoip"
include "*.mmdb"
}
Expand Down
4 changes: 2 additions & 2 deletions modules/percolator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ esplugin {
}

dependencies {
testCompile project(path: ':modules:parent-join', configuration: 'runtime')
testImplementation project(path: ':modules:parent-join', configuration: 'runtime')
}

restResources {
restApi {
includeCore '_common', 'indices', 'index', 'search', 'msearch'
includeCore '_common', 'indices', 'index', 'search', 'msearch'
}
}
dependencyLicenses {
Expand Down
4 changes: 2 additions & 2 deletions modules/reindex/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ dependencies {
compile project(":client:rest")
compile project(":libs:elasticsearch-ssl-config")
// for http - testing reindex from remote
testCompile project(path: ':modules:transport-netty4', configuration: 'runtime')
testImplementation project(path: ':modules:transport-netty4', configuration: 'runtime')
// for parent/child testing
testCompile project(path: ':modules:parent-join', configuration: 'runtime')
testImplementation project(path: ':modules:parent-join', configuration: 'runtime')
}

restResources {
Expand Down
Loading

0 comments on commit eddb9d1

Please sign in to comment.