Skip to content

Commit

Permalink
Avoid sharing source directories as it breaks intellij (elastic#40877)
Browse files Browse the repository at this point in the history
(cherry picked from commit 71d407f)
  • Loading branch information
mark-vieira committed Apr 9, 2019
1 parent 0a88e7f commit aa923b0
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 87 deletions.
33 changes: 1 addition & 32 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,6 @@ gradle.projectsEvaluated {
integTest.mustRunAfter test
}
configurations.all { Configuration configuration ->
/*
* The featureAwarePlugin configuration has a dependency on x-pack:plugin:core and x-pack:plugin:core has a dependency on the
* featureAwarePlugin configuration. The below task ordering logic would force :x-pack:plugin:core:test
* :x-pack:test:feature-aware:test to depend on each other circularly. We break that cycle here.
*/
if (configuration.name == "featureAwarePlugin") {
return
}
dependencies.all { Dependency dep ->
Project upstreamProject = dependencyToProject(dep)
if (upstreamProject != null) {
Expand All @@ -379,7 +371,7 @@ gradle.projectsEvaluated {
Task task = project.tasks.findByName(taskName)
Task upstreamTask = upstreamProject.tasks.findByName(taskName)
if (task != null && upstreamTask != null) {
task.mustRunAfter(upstreamTask)
task.shouldRunAfter(upstreamTask)
}
}
}
Expand All @@ -404,21 +396,6 @@ allprojects {
// also ignore other possible build dirs
excludeDirs += file('build')
excludeDirs += file('build-eclipse')

iml {
// fix so that Gradle idea plugin properly generates support for resource folders
// see also https://issues.gradle.org/browse/GRADLE-2975
withXml {
it.asNode().component.content.sourceFolder.findAll { it.@url == 'file://$MODULE_DIR$/src/main/resources' }.each {
it.attributes().remove('isTestSource')
it.attributes().put('type', 'java-resource')
}
it.asNode().component.content.sourceFolder.findAll { it.@url == 'file://$MODULE_DIR$/src/test/resources' }.each {
it.attributes().remove('isTestSource')
it.attributes().put('type', 'java-test-resource')
}
}
}
}
}

Expand All @@ -436,14 +413,6 @@ idea {
vcs = 'Git'
}
}
// Make sure gradle idea was run before running anything in intellij (including import).
File ideaMarker = new File(projectDir, '.local-idea-is-configured')
tasks.idea.doLast {
ideaMarker.setText('', 'UTF-8')
}
if (System.getProperty('idea.active') != null && ideaMarker.exists() == false) {
throw new GradleException('You must run `gradle idea` from the root of elasticsearch before importing into IntelliJ')
}

// eclipse configuration
allprojects {
Expand Down
13 changes: 13 additions & 0 deletions qa/full-cluster-restart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,16 @@ task bwcTestSnapshots {
}

check.dependsOn(bwcTestSnapshots)

configurations {
testArtifacts.extendsFrom testRuntime
}

task testJar(type: Jar) {
appendix 'test'
from sourceSets.test.output
}

artifacts {
testArtifacts testJar
}
7 changes: 5 additions & 2 deletions x-pack/plugin/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ dependencies {
testCompile project(path: ':modules:reindex', configuration: 'runtime')
testCompile project(path: ':modules:parent-join', configuration: 'runtime')
testCompile project(path: ':modules:analysis-common', configuration: 'runtime')
testCompile(project(':x-pack:license-tools')) {
transitive = false
}
testCompile ("org.elasticsearch.client:elasticsearch-rest-high-level-client:${version}")
}

Expand Down Expand Up @@ -91,8 +94,8 @@ licenseHeaders {
}

// make LicenseSigner available for testing signed licenses
sourceSets.test.java {
srcDir '../../license-tools/src/main/java'
sourceSets.test.resources {
srcDir 'src/main/config'
}

unitTest {
Expand Down
12 changes: 5 additions & 7 deletions x-pack/plugin/security/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ dependencies {
compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"

processTestResources {
from(project(xpackModule('core')).file('src/main/config'))
from(project(xpackModule('core')).file('src/test/resources'))
}

configurations {
testArtifacts.extendsFrom testRuntime
}
Expand All @@ -144,13 +149,6 @@ processResources {
}
}

sourceSets.test.resources {
srcDir '../core/src/test/resources'
// this is required because audit logging tests (LoggingAuditTrailTests)
// parse the actual log4j2.properties config file to extract and test
// the log line pattern. These tests need access to the file as a resource.
srcDir '../core/src/main/config'
}
dependencyLicenses {
mapping from: /java-support|opensaml-.*/, to: 'shibboleth'
mapping from: /http.*/, to: 'httpclient'
Expand Down
12 changes: 7 additions & 5 deletions x-pack/plugin/sql/qa/security/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ subprojects {
// Use resources from the parent project in subprojects
sourceSets {
test {
java {
srcDirs = ["${mainProject.projectDir}/src/test/java"]
}
resources {
srcDirs = ["${mainProject.projectDir}/src/test/resources"]
mainProject.sourceSets.test.output.classesDirs.each { dir ->
output.addClassesDir { dir }
}
runtimeClasspath += mainProject.sourceSets.test.output
}
}

processTestResources {
from mainProject.file('src/test/resources')
}

dependencies {
testCompile "org.elasticsearch.plugin:x-pack-core:${version}"
}
Expand Down
26 changes: 8 additions & 18 deletions x-pack/qa/full-cluster-restart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies {
// This is total #$%, but the solution is to get the SAML realm (which uses guava) out of security proper
exclude group: "com.google.guava", module: "guava"
}
testCompile project(path: ':qa:full-cluster-restart', configuration: 'testArtifacts')
}

Closure waitWithAuth = { NodeInfo node, AntBuilder ant ->
Expand Down Expand Up @@ -72,15 +73,6 @@ Closure waitWithAuth = { NodeInfo node, AntBuilder ant ->

Project mainProject = project

String coreFullClusterRestartPath = project(':qa:full-cluster-restart').projectDir.toPath().resolve('src/test/java').toString()
sourceSets {
test {
java {
srcDirs += [coreFullClusterRestartPath]
}
}
}

licenseHeaders {
approvedLicenses << 'Apache'
}
Expand All @@ -90,7 +82,7 @@ forbiddenPatterns {
}

// tests are pushed down to subprojects
testingConventions.enabled = false
testingConventions.enabled = false

/**
* Subdirectories of this project are test rolling upgrades with various
Expand All @@ -105,15 +97,12 @@ subprojects {

apply plugin: 'elasticsearch.standalone-test'

// Use resources from the rolling-upgrade project in subdirectories
sourceSets {
test {
java {
srcDirs = ["${mainProject.projectDir}/src/test/java", coreFullClusterRestartPath]
}
resources {
srcDirs = ["${mainProject.projectDir}/src/test/resources"]
mainProject.sourceSets.test.output.classesDirs.each { dir ->
output.addClassesDir { dir }
}
runtimeClasspath += mainProject.sourceSets.test.output
}
}

Expand Down Expand Up @@ -194,7 +183,7 @@ subprojects {
extraConfigFile 'testnode.crt', new File(outputDir + '/testnode.crt')
extraConfigFile 'testnode.jks', new File(outputDir + '/testnode.jks')
if (version.before('5.1.2')) {
// Disable monitoring if version is before 5.1.2 because form 5.1.2 we changed how we get DocStats
// Disable monitoring if version is before 5.1.2 because form 5.1.2 we changed how we get DocStats
// and we can get a negative value which cannot because serialised by <5.1.2 as it writes VLongs
setting 'xpack.monitoring.enabled', 'false'
}
Expand Down Expand Up @@ -275,7 +264,7 @@ subprojects {
bwcTest.dependsOn(versionBwcTest)
}
}

unitTest.enabled = false // no unit tests for full cluster restarts, only the rest integration test

// basic integ tests includes testing bwc against the most recent version
Expand All @@ -295,6 +284,7 @@ subprojects {
testCompile project(path: xpackModule('watcher'), configuration: 'runtime')
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
testCompile project(path: xpackModule('security'), configuration: 'testArtifacts')
testCompile project(path: ':qa:full-cluster-restart', configuration: 'testArtifacts')
}

// copy x-pack plugin info so it is on the classpath and security manager has the right permissions
Expand Down
9 changes: 3 additions & 6 deletions x-pack/qa/rolling-upgrade/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,12 @@ subprojects {

apply plugin: 'elasticsearch.standalone-test'

// Use resources from the rolling-upgrade project in subdirectories
sourceSets {
test {
java {
srcDirs = ["${mainProject.projectDir}/src/test/java"]
}
resources {
srcDirs = ["${mainProject.projectDir}/src/test/resources"]
mainProject.sourceSets.test.output.classesDirs.each { dir ->
output.addClassesDir { dir }
}
runtimeClasspath += mainProject.sourceSets.test.output
}
}

Expand Down
4 changes: 3 additions & 1 deletion x-pack/qa/security-tools-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ dependencies {
}

// add test resources from security, so certificate tool tests can use example certs
sourceSets.test.resources.srcDirs(project(xpackModule('security')).sourceSets.test.resources.srcDirs)
processTestResources {
from(project(xpackModule('security')).sourceSets.test.resources.srcDirs)
}

// we have to repeate these patterns because the security test resources are effectively in the src of this project
forbiddenPatterns {
Expand Down
7 changes: 5 additions & 2 deletions x-pack/qa/third-party/active-directory/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ dependencies {
testFixtures.useFixture ":x-pack:test:smb-fixture"

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

compileTestJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"

// we have to repeat these patterns because the security test resources are effectively in the src of this project
forbiddenPatterns {
Expand Down
9 changes: 2 additions & 7 deletions x-pack/qa/tribe-tests-with-license/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,8 @@ unitTest {
include '**/*Tests.class'
}

String licensePath = xpackProject('license-tools').projectDir.toPath().resolve('src/test/resources').toString()
sourceSets {
test {
resources {
srcDirs += [licensePath]
}
}
processTestResources {
from xpackProject('license-tools').file('src/test/resources')
}

project.forbiddenPatterns {
Expand Down
9 changes: 2 additions & 7 deletions x-pack/qa/tribe-tests-with-security/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@ dependencies {

compileTestJava.options.compilerArgs << "-Xlint:-try"

String xpackPath = project(xpackModule('core')).projectDir.toPath().resolve('src/test/resources').toString()
sourceSets {
test {
resources {
srcDirs += [xpackPath]
}
}
processTestResources {
from project(xpackModule('core')).file('src/test/resources')
}

forbiddenPatterns {
Expand Down

0 comments on commit aa923b0

Please sign in to comment.