Skip to content

Commit 71d407f

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 314890b commit 71d407f

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
@@ -338,14 +338,6 @@ gradle.projectsEvaluated {
338338
integTest.mustRunAfter test
339339
}
340340
configurations.all { Configuration configuration ->
341-
/*
342-
* The featureAwarePlugin configuration has a dependency on x-pack:plugin:core and x-pack:plugin:core has a dependency on the
343-
* featureAwarePlugin configuration. The below task ordering logic would force :x-pack:plugin:core:test
344-
* :x-pack:test:feature-aware:test to depend on each other circularly. We break that cycle here.
345-
*/
346-
if (configuration.name == "featureAwarePlugin") {
347-
return
348-
}
349341
dependencies.all { Dependency dep ->
350342
Project upstreamProject = dependencyToProject(dep)
351343
if (upstreamProject != null) {
@@ -357,7 +349,7 @@ gradle.projectsEvaluated {
357349
Task task = project.tasks.findByName(taskName)
358350
Task upstreamTask = upstreamProject.tasks.findByName(taskName)
359351
if (task != null && upstreamTask != null) {
360-
task.mustRunAfter(upstreamTask)
352+
task.shouldRunAfter(upstreamTask)
361353
}
362354
}
363355
}
@@ -382,21 +374,6 @@ allprojects {
382374
// also ignore other possible build dirs
383375
excludeDirs += file('build')
384376
excludeDirs += file('build-eclipse')
385-
386-
iml {
387-
// fix so that Gradle idea plugin properly generates support for resource folders
388-
// see also https://issues.gradle.org/browse/GRADLE-2975
389-
withXml {
390-
it.asNode().component.content.sourceFolder.findAll { it.@url == 'file://$MODULE_DIR$/src/main/resources' }.each {
391-
it.attributes().remove('isTestSource')
392-
it.attributes().put('type', 'java-resource')
393-
}
394-
it.asNode().component.content.sourceFolder.findAll { it.@url == 'file://$MODULE_DIR$/src/test/resources' }.each {
395-
it.attributes().remove('isTestSource')
396-
it.attributes().put('type', 'java-test-resource')
397-
}
398-
}
399-
}
400377
}
401378
}
402379

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

426395
// eclipse configuration
427396
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
@@ -136,6 +136,11 @@ dependencies {
136136
compileJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
137137
compileTestJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
138138

139+
processTestResources {
140+
from(project(xpackModule('core')).file('src/main/config'))
141+
from(project(xpackModule('core')).file('src/test/resources'))
142+
}
143+
139144
configurations {
140145
testArtifacts.extendsFrom testRuntime
141146
}
@@ -148,10 +153,7 @@ artifacts {
148153
archives jar
149154
testArtifacts testJar
150155
}
151-
sourceSets.test.resources {
152-
srcDir '../core/src/test/resources'
153-
srcDir '../core/src/main/config'
154-
}
156+
155157
dependencyLicenses {
156158
mapping from: /java-support|opensaml-.*/, to: 'shibboleth'
157159
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:-rawtypes,-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)