Skip to content

Commit 66354d4

Browse files
authored
Remove provided optional configs (#1452)
All previously referenced dependencies in these configurations have been updated to be listed under either api, implementation, or compileOnly.
1 parent 59a48c4 commit 66354d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2782
-137
lines changed

buildSrc/build.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ repositories {
5656
jcenter()
5757
mavenCentral()
5858

59-
// For resolving propdeps (provided/optional dependencies)
60-
maven { url 'https://repo.spring.io/plugins-release' }
61-
6259
// For Elasticsearch snapshots.
6360
if (localRepo) {
6461
// For some reason the root dirs all point to the buildSrc folder. The local Repo will be one above that.
@@ -72,10 +69,6 @@ dependencies {
7269
compile gradleApi()
7370
compile localGroovy()
7471

75-
// Provided/Optional Dependencies
76-
compile 'org.springframework.build.gradle:propdeps-plugin:0.0.7'
77-
implementation 'org.apache.logging.log4j:log4j-core:2.11.1'
78-
7972
if (localRepo) {
8073
compile name: "build-tools-${buildToolsVersion}"
8174
// Required for dependency licenses task (explicitly added in case of localRepo missing transitive dependencies)

buildSrc/src/main/groovy/org/elasticsearch/hadoop/gradle/BuildPlugin.groovy

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import org.gradle.api.attributes.Usage
2222
import org.gradle.api.file.CopySpec
2323
import org.gradle.api.file.FileCollection
2424
import org.gradle.api.java.archives.Manifest
25+
import org.gradle.api.plugins.JavaLibraryPlugin
2526
import org.gradle.api.plugins.JavaPlugin
2627
import org.gradle.api.plugins.MavenPlugin
2728
import org.gradle.api.plugins.MavenPluginConvention
@@ -37,10 +38,6 @@ import org.gradle.external.javadoc.JavadocOutputLevel
3738
import org.gradle.external.javadoc.MinimalJavadocOptions
3839
import org.gradle.plugins.ide.eclipse.EclipsePlugin
3940
import org.gradle.plugins.ide.idea.IdeaPlugin
40-
import org.springframework.build.gradle.propdep.PropDepsEclipsePlugin
41-
import org.springframework.build.gradle.propdep.PropDepsIdeaPlugin
42-
import org.springframework.build.gradle.propdep.PropDepsMavenPlugin
43-
import org.springframework.build.gradle.propdep.PropDepsPlugin
4441

4542
class BuildPlugin implements Plugin<Project> {
4643

@@ -66,20 +63,14 @@ class BuildPlugin implements Plugin<Project> {
6663
project.getPluginManager().apply(BaseBuildPlugin.class)
6764

6865
// BuildPlugin will continue to assume Java projects for the time being.
69-
project.getPluginManager().apply(JavaPlugin.class)
66+
project.getPluginManager().apply(JavaLibraryPlugin.class)
7067

7168
// IDE Support
7269
project.getPluginManager().apply(IdeaPlugin.class)
7370
project.getPluginManager().apply(EclipsePlugin.class)
7471

7572
// Maven Support
7673
project.getPluginManager().apply(MavenPlugin.class)
77-
78-
// Support for modeling provided/optional dependencies
79-
project.getPluginManager().apply(PropDepsPlugin.class)
80-
project.getPluginManager().apply(PropDepsIdeaPlugin.class)
81-
project.getPluginManager().apply(PropDepsEclipsePlugin.class)
82-
project.getPluginManager().apply(PropDepsMavenPlugin.class)
8374
}
8475

8576
/** Return the configuration name used for finding transitive deps of the given dependency. */
@@ -133,11 +124,10 @@ class BuildPlugin implements Plugin<Project> {
133124
}
134125
}
135126

136-
project.configurations.compile.dependencies.all(disableTransitiveDeps)
127+
project.configurations.api.dependencies.all(disableTransitiveDeps)
137128
project.configurations.implementation.dependencies.all(disableTransitiveDeps)
138-
project.configurations.provided.dependencies.all(disableTransitiveDeps)
139-
project.configurations.optional.dependencies.all(disableTransitiveDeps)
140129
project.configurations.compileOnly.dependencies.all(disableTransitiveDeps)
130+
project.configurations.runtimeOnly.dependencies.all(disableTransitiveDeps)
141131
}
142132

143133
/**
@@ -167,7 +157,6 @@ class BuildPlugin implements Plugin<Project> {
167157

168158
itestImplementation(project.sourceSets.main.output)
169159
itestImplementation(project.configurations.testImplementation)
170-
itestImplementation(project.configurations.provided)
171160
itestImplementation(project.sourceSets.test.output)
172161
itestImplementation(project.configurations.testRuntimeClasspath)
173162
}
@@ -403,17 +392,6 @@ class BuildPlugin implements Plugin<Project> {
403392
dep.scope == 'test' || dep.artifactId == 'elasticsearch-hadoop-mr'
404393
}
405394

406-
// Mark the optional dependencies to actually be optional
407-
generatedPom.dependencies.findAll { it.scope == 'optional' }.each {
408-
it.optional = "true"
409-
}
410-
411-
// By default propdeps models optional dependencies as compile/optional
412-
// for es-hadoop optional is best if these are modeled as provided/optional
413-
generatedPom.dependencies.findAll { it.optional == "true" }.each {
414-
it.scope = "provided"
415-
}
416-
417395
// Storm hosts their jars outside of maven central.
418396
boolean storm = generatedPom.dependencies.any { it.groupId == 'org.apache.storm' }
419397

buildSrc/src/main/groovy/org/elasticsearch/hadoop/gradle/IntegrationBuildPlugin.groovy

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,18 @@ class IntegrationBuildPlugin implements Plugin<Project> {
6565
*/
6666
private static void configureProjectZip(Project project) {
6767
// We do this after evaluation since the scala projects may change around what the final archive name is.
68+
// TODO: Swap this out with exposing those jars as artifacts to be consumed in a dist project.
6869
project.afterEvaluate {
6970
Zip rootDistZip = project.rootProject.getTasks().getByName('distZip') as Zip
7071
rootDistZip.dependsOn(project.getTasks().pack)
7172

72-
project.getTasks().withType(Jar.class).each { Jar jarTask ->
73+
project.getTasks().withType(Jar.class) { Jar jarTask ->
7374
// Add jar output under the dist directory
74-
rootDistZip.from(jarTask.archivePath) { CopySpec copySpecification ->
75-
copySpecification.into("${project.rootProject.ext.folderName}/dist")
76-
copySpecification.setDuplicatesStrategy(DuplicatesStrategy.WARN)
75+
if (jarTask.name != "itestJar") {
76+
rootDistZip.from(jarTask.archiveFile) { CopySpec copySpecification ->
77+
copySpecification.into("${project.rootProject.ext.folderName}/dist")
78+
copySpecification.setDuplicatesStrategy(DuplicatesStrategy.WARN)
79+
}
7780
}
7881
}
7982
}
@@ -84,36 +87,15 @@ class IntegrationBuildPlugin implements Plugin<Project> {
8487
* @param project to be configured
8588
*/
8689
private static void configureRootProjectDependencies(Project project) {
87-
// We do this in an after evaluate so that we pick up all dependencies set after the plugin was configured.
88-
// If this becomes a problem, we could see if there's a way to listen for new dependencies and add them
89-
// to root at the same time.
90-
project.afterEvaluate {
91-
project.getConfigurations().getByName('implementation').getAllDependencies()
92-
.withType(ExternalDependency.class)
93-
.each { Dependency dependency ->
94-
// Convert the scope to optional on the root project - it will have every integration in it, and
95-
// users may not need every dependency (except hadoop and jackson)
96-
String scope = (dependency.group in ['org.apache.hadoop', 'org.codehaus.jackson'] ? 'provided' : 'optional')
97-
project.rootProject.getDependencies().add(scope, dependency)
98-
}
99-
100-
project.getConfigurations().getByName('provided').getAllDependencies()
101-
.withType(ExternalDependency.class)
102-
.each { Dependency dependency ->
103-
// Convert the scope to optional on the root project - it will have every integration in it, and
104-
// users may not need every dependency (except hadoop and jackson)
105-
String scope = (dependency.group in ['org.apache.hadoop', 'org.codehaus.jackson'] ? 'provided' : 'optional')
106-
project.rootProject.getDependencies().add(scope, dependency)
90+
project.getConfigurations().getByName('api').getAllDependencies()
91+
.withType(ExternalDependency.class) { Dependency dependency ->
92+
// Set API dependencies as implementation in the uberjar so that not everything is compile scope
93+
project.rootProject.getDependencies().add('implementation', dependency)
10794
}
10895

109-
project.getConfigurations().getByName('optional').getAllDependencies()
110-
.withType(ExternalDependency.class)
111-
.each { Dependency dependency ->
112-
// Convert the scope to optional on the root project - it will have every integration in it, and
113-
// users may not need every dependency (except hadoop and jackson)
114-
String scope = (dependency.group in ['org.apache.hadoop', 'org.codehaus.jackson'] ? 'provided' : 'optional')
115-
project.rootProject.getDependencies().add(scope, dependency)
96+
project.getConfigurations().getByName('implementation').getAllDependencies()
97+
.withType(ExternalDependency.class) { Dependency dependency ->
98+
project.rootProject.getDependencies().add('implementation', dependency)
11699
}
117-
}
118100
}
119101
}

buildSrc/src/main/groovy/org/elasticsearch/hadoop/gradle/RootBuildPlugin.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ class RootBuildPlugin implements Plugin<Project> {
8787
// Copy master jar, sourceJar, and javadocJar to zip
8888
project.afterEvaluate {
8989
// Do not copy the hadoop testing jar
90-
project.getTasks().withType(Jar.class).findAll { it.name != 'hadoopTestingJar' }.each { Jar jarTask ->
91-
distZip.from(jarTask.archivePath) { CopySpec spec ->
90+
project.getTasks().withType(Jar.class) { Jar jarTask ->
91+
distZip.from(jarTask.archiveFile) { CopySpec spec ->
9292
spec.into("${project.rootProject.ext.folderName}/dist")
9393
}
9494
}

hive/build.gradle

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ configurations {
1818
dependencies {
1919
embedded(project(":elasticsearch-hadoop-mr"))
2020

21-
provided("org.apache.hive:hive-service:$hiveVersion") {
21+
implementation("org.apache.hive:hive-service:$hiveVersion") {
2222
exclude module: "log4j-slf4j-impl"
2323
}
24-
provided("org.apache.hive:hive-exec:$hiveVersion")
25-
provided("org.apache.hive:hive-metastore:$hiveVersion")
24+
implementation("org.apache.hive:hive-exec:$hiveVersion")
25+
implementation("org.apache.hive:hive-metastore:$hiveVersion")
26+
implementation("commons-logging:commons-logging:1.1.1")
27+
implementation("javax.xml.bind:jaxb-api:2.3.1")
2628

2729
testImplementation(project(":test:shared"))
2830

@@ -38,6 +40,7 @@ dependencies {
3840
}
3941

4042
jar {
43+
dependsOn(project.configurations.embedded)
4144
from(project.configurations.embedded.collect { it.isDirectory() ? it : zipTree(it)}) {
4245
include "org/elasticsearch/hadoop/**"
4346
include "esh-build.properties"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5043bfebc3db072ed80fbd362e7caf00e885d8ae

0 commit comments

Comments
 (0)