Skip to content

Commit ff7c7a6

Browse files
mark-vieiraalpar-t
authored andcommitted
Avoid sharing source directories as it breaks intellij (#40877)
* Avoid sharing source directories as it breaks intellij * Subprojects share main project output classes directory * Fix jar hell * Fix sql security with ssl integ tests * Relax dependency ordering rule so we don't explode on cycles
1 parent 4544b29 commit ff7c7a6

File tree

8 files changed

+39
-54
lines changed

8 files changed

+39
-54
lines changed

build.gradle

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,6 @@ gradle.projectsEvaluated {
337337
integTest.mustRunAfter test
338338
}
339339
configurations.all { Configuration configuration ->
340-
/*
341-
* The featureAwarePlugin configuration has a dependency on x-pack:plugin:core and x-pack:plugin:core has a dependency on the
342-
* featureAwarePlugin configuration. The below task ordering logic would force :x-pack:plugin:core:test
343-
* :x-pack:test:feature-aware:test to depend on each other circularly. We break that cycle here.
344-
*/
345-
if (configuration.name == "featureAwarePlugin") {
346-
return
347-
}
348340
dependencies.all { Dependency dep ->
349341
Project upstreamProject = dependencyToProject(dep)
350342
if (upstreamProject != null) {
@@ -356,7 +348,7 @@ gradle.projectsEvaluated {
356348
Task task = project.tasks.findByName(taskName)
357349
Task upstreamTask = upstreamProject.tasks.findByName(taskName)
358350
if (task != null && upstreamTask != null) {
359-
task.mustRunAfter(upstreamTask)
351+
task.shouldRunAfter(upstreamTask)
360352
}
361353
}
362354
}
@@ -381,21 +373,6 @@ allprojects {
381373
// also ignore other possible build dirs
382374
excludeDirs += file('build')
383375
excludeDirs += file('build-eclipse')
384-
385-
iml {
386-
// fix so that Gradle idea plugin properly generates support for resource folders
387-
// see also https://issues.gradle.org/browse/GRADLE-2975
388-
withXml {
389-
it.asNode().component.content.sourceFolder.findAll { it.@url == 'file://$MODULE_DIR$/src/main/resources' }.each {
390-
it.attributes().remove('isTestSource')
391-
it.attributes().put('type', 'java-resource')
392-
}
393-
it.asNode().component.content.sourceFolder.findAll { it.@url == 'file://$MODULE_DIR$/src/test/resources' }.each {
394-
it.attributes().remove('isTestSource')
395-
it.attributes().put('type', 'java-test-resource')
396-
}
397-
}
398-
}
399376
}
400377
}
401378

@@ -413,14 +390,6 @@ idea {
413390
vcs = 'Git'
414391
}
415392
}
416-
// Make sure gradle idea was run before running anything in intellij (including import).
417-
File ideaMarker = new File(projectDir, '.local-idea-is-configured')
418-
tasks.idea.doLast {
419-
ideaMarker.setText('', 'UTF-8')
420-
}
421-
if (System.getProperty('idea.active') != null && ideaMarker.exists() == false) {
422-
throw new GradleException('You must run `./gradlew idea` from the root of elasticsearch before importing into IntelliJ')
423-
}
424393

425394
// eclipse configuration
426395
allprojects {

qa/full-cluster-restart/build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,15 @@ task bwcTestSnapshots {
105105

106106
check.dependsOn(bwcTestSnapshots)
107107

108+
configurations {
109+
testArtifacts.extendsFrom testRuntime
110+
}
111+
112+
task testJar(type: Jar) {
113+
appendix 'test'
114+
from sourceSets.test.output
115+
}
116+
117+
artifacts {
118+
testArtifacts testJar
119+
}

x-pack/plugin/core/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ dependencies {
4848
testCompile project(path: ':modules:reindex', configuration: 'runtime')
4949
testCompile project(path: ':modules:parent-join', configuration: 'runtime')
5050
testCompile project(path: ':modules:analysis-common', configuration: 'runtime')
51+
testCompile(project(':x-pack:license-tools')) {
52+
transitive = false
53+
}
5154
testCompile ("org.elasticsearch.client:elasticsearch-rest-high-level-client:${version}")
5255
}
5356

@@ -95,8 +98,8 @@ licenseHeaders {
9598
}
9699

97100
// make LicenseSigner available for testing signed licenses
98-
sourceSets.test.java {
99-
srcDir '../../license-tools/src/main/java'
101+
sourceSets.test.resources {
102+
srcDir 'src/main/config'
100103
}
101104

102105
unitTest {

x-pack/plugin/security/build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ dependencies {
126126
compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
127127
compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
128128

129+
processTestResources {
130+
from(project(xpackModule('core')).file('src/main/config'))
131+
from(project(xpackModule('core')).file('src/test/resources'))
132+
}
133+
129134
configurations {
130135
testArtifacts.extendsFrom testRuntime
131136
}
@@ -138,10 +143,7 @@ artifacts {
138143
archives jar
139144
testArtifacts testJar
140145
}
141-
sourceSets.test.resources {
142-
srcDir '../core/src/test/resources'
143-
srcDir '../core/src/main/config'
144-
}
146+
145147
dependencyLicenses {
146148
mapping from: /java-support|opensaml-.*/, to: 'shibboleth'
147149
mapping from: /http.*/, to: 'httpclient'

x-pack/plugin/sql/qa/security/build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ subprojects {
1313
// Use resources from the parent project in subprojects
1414
sourceSets {
1515
test {
16-
java {
17-
srcDirs = ["${mainProject.projectDir}/src/test/java"]
18-
}
19-
resources {
20-
srcDirs = ["${mainProject.projectDir}/src/test/resources"]
16+
mainProject.sourceSets.test.output.classesDirs.each { dir ->
17+
output.addClassesDir { dir }
2118
}
19+
runtimeClasspath += mainProject.sourceSets.test.output
2220
}
2321
}
2422

23+
processTestResources {
24+
from mainProject.file('src/test/resources')
25+
}
26+
2527
dependencies {
2628
testCompile "org.elasticsearch.plugin:x-pack-core:${version}"
2729
}

x-pack/qa/full-cluster-restart/build.gradle

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ dependencies {
2525
// This is total #$%, but the solution is to get the SAML realm (which uses guava) out of security proper
2626
exclude group: "com.google.guava", module: "guava"
2727
}
28+
testCompile project(path: ':qa:full-cluster-restart', configuration: 'testArtifacts')
2829
}
2930

3031
Closure waitWithAuth = { NodeInfo node, AntBuilder ant ->
@@ -70,15 +71,6 @@ Closure waitWithAuth = { NodeInfo node, AntBuilder ant ->
7071
return tmpFile.exists()
7172
}
7273

73-
String coreFullClusterRestartPath = project(':qa:full-cluster-restart').projectDir.toPath().resolve('src/test/java').toString()
74-
sourceSets {
75-
test {
76-
java {
77-
srcDirs += [coreFullClusterRestartPath]
78-
}
79-
}
80-
}
81-
8274
licenseHeaders {
8375
approvedLicenses << 'Apache'
8476
}

x-pack/qa/security-tools-tests/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ dependencies {
88
}
99

1010
// add test resources from security, so certificate tool tests can use example certs
11-
sourceSets.test.resources.srcDirs(project(xpackModule('security')).sourceSets.test.resources.srcDirs)
11+
processTestResources {
12+
from(project(xpackModule('security')).sourceSets.test.resources.srcDirs)
13+
}
1214

1315
// we have to repeate these patterns because the security test resources are effectively in the src of this project
1416
forbiddenPatterns {

x-pack/qa/third-party/active-directory/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ dependencies {
99
testFixtures.useFixture ":x-pack:test:smb-fixture"
1010

1111
// add test resources from security, so tests can use example certs
12-
sourceSets.test.resources.srcDirs(project(xpackModule('security')).sourceSets.test.resources.srcDirs)
12+
processTestResources {
13+
from(project(xpackModule('security')).sourceSets.test.resources.srcDirs)
14+
}
15+
1316
compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
1417

1518
// we have to repeat these patterns because the security test resources are effectively in the src of this project

0 commit comments

Comments
 (0)