From 30fe74b5df2cf9f94fc62eb6a90cf15e74f897b2 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Sat, 28 Nov 2015 16:54:51 -0800 Subject: [PATCH] Build: Setup standalone tests to compile in intellij This adds the standalone tests so they will compile (and thus can be modified with import completion) within IntelliJ. It also explicitly sets up buildSrc as a module. Note that this does *not* mean eg evil-tests can be run from intellij. These are special tests that require special settings (eg disabling security manager). They need to be run from the command line. closes #15075 --- build.gradle | 6 ++++++ .../gradle/test/StandaloneTestBasePlugin.groovy | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 785db7ec0c4c6..20976eff2bd44 100644 --- a/build.gradle +++ b/build.gradle @@ -177,6 +177,12 @@ tasks.idea.doLast { 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') } +// add buildSrc itself as a groovy project +task buildSrcIdea(type: GradleBuild) { + buildFile = 'buildSrc/build.gradle' + tasks = ['cleanIdea', 'ideaModule'] +} +tasks.idea.dependsOn(buildSrcIdea) // eclipse configuration diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/StandaloneTestBasePlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/StandaloneTestBasePlugin.groovy index 271bc5e58be35..c6edc87b9a78f 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/StandaloneTestBasePlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/StandaloneTestBasePlugin.groovy @@ -39,9 +39,6 @@ class StandaloneTestBasePlugin implements Plugin { BuildPlugin.globalBuildInfo(project) BuildPlugin.configureRepositories(project) - // remove some unnecessary tasks for a qa test - project.tasks.removeAll { it.name in ['assemble', 'buildDependents'] } - // only setup tests to build project.sourceSets { test @@ -56,6 +53,12 @@ class StandaloneTestBasePlugin implements Plugin { plusConfigurations = [project.configurations.testRuntime] } } + project.idea { + module { + testSourceDirs += project.sourceSets.test.java.srcDirs + scopes['TEST'] = [plus: [project.configurations.testRuntime]] + } + } PrecommitTasks.configure(project) } }