diff --git a/TESTING.asciidoc b/TESTING.asciidoc index 68740c2b42e..c1b17e7b31a 100644 --- a/TESTING.asciidoc +++ b/TESTING.asciidoc @@ -44,7 +44,7 @@ In order to run Elasticsearch from source without building a package, you can run it using Maven: ------------------------------------- -./run.sh +gradle run ------------------------------------- === Test case filtering. @@ -455,5 +455,5 @@ mvn -Dtests.coverage verify jacoco:report == Debugging from an IDE -If you want to run elasticsearch from your IDE, you should execute ./run.sh +If you want to run elasticsearch from your IDE, you should execute gradle run It opens a remote debugging port that you can connect with your IDE. diff --git a/build.gradle b/build.gradle index 49189482e6b..5f01cdb4af8 100644 --- a/build.gradle +++ b/build.gradle @@ -199,3 +199,5 @@ task buildSrcEclipse(type: GradleBuild) { } tasks.eclipse.dependsOn(buildSrcEclipse) +task run(dependsOn: ':distribution:run') + diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy index 088d6c854ba..b4b08bf4160 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy @@ -36,6 +36,9 @@ class ClusterConfiguration { @Input int transportPort = 9500 + @Input + boolean daemonize = true + @Input String jvmArgs = System.getProperty('tests.jvm.argline', '') diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index 0b835872ec1..8f9ccc0718b 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -244,17 +244,22 @@ class ClusterFormationTasks { // elasticsearch.bat is spawned as it has no daemon mode return project.tasks.create(name: name, type: DefaultTask, dependsOn: setup) << { // Fall back to Ant exec task as Gradle Exec task does not support spawning yet - ant.exec(executable: 'cmd', spawn: true, dir: cwd) { + ant.exec(executable: 'cmd', spawn: config.daemonize, dir: cwd) { esEnv.each { key, value -> env(key: key, value: value) } (['/C', 'call', esScript] + esProps).each { arg(value: it) } } esPostStartActions(ant, logger) } } else { + List esExecutable = [esScript] + if(config.daemonize) { + esExecutable.add("-d") + } + return project.tasks.create(name: name, type: Exec, dependsOn: setup) { workingDir cwd executable 'sh' - args esScript, '-d' // daemonize! + args esExecutable args esProps environment esEnv errorOutput = new ByteArrayOutputStream() @@ -336,4 +341,4 @@ class ClusterFormationTasks { static File pidFile(File dir) { return new File(dir, 'es.pid') } -} \ No newline at end of file +} diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RunTask.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RunTask.groovy new file mode 100644 index 00000000000..ad14dfe8672 --- /dev/null +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RunTask.groovy @@ -0,0 +1,12 @@ +package org.elasticsearch.gradle.test + +import org.gradle.api.DefaultTask +import org.gradle.api.tasks.TaskAction + +class RunTask extends DefaultTask { + ClusterConfiguration clusterConfig = new ClusterConfiguration(httpPort: 9200, transportPort: 9300, daemonize: false) + + RunTask() { + ClusterFormationTasks.setup(project, this, clusterConfig) + } +} diff --git a/core/build.gradle b/core/build.gradle index 101f555374b..a7fcda9ca00 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -136,4 +136,3 @@ if (isEclipse == false || project.path == "${projectsPrefix}:core-tests") { Task copyRestSpec = RestSpecHack.configureTask(project, true) integTest.dependsOn copyRestSpec } - diff --git a/distribution/build.gradle b/distribution/build.gradle index 7770c0d98ab..f2aca91cb86 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -195,3 +195,5 @@ DependencyLicensesTask.configure(project) { mapping from: /lucene-.*/, to: 'lucene' mapping from: /jackson-.*/, to: 'jackson' } + +task run(type:org.elasticsearch.gradle.test.RunTask){} \ No newline at end of file diff --git a/run.bat b/run.bat deleted file mode 100755 index b0cc48a88ab..00000000000 --- a/run.bat +++ /dev/null @@ -1,5 +0,0 @@ -:: -:: build zip package, but ensuring its from the current source -:: turn off tests and other validation to speed it up -:: TODO: can be sped up more, if shading is moved out of core/ -CALL mvn -am -pl dev-tools,distribution/zip package -DskipTests -Drun -Pdev diff --git a/run.sh b/run.sh deleted file mode 100755 index 16871065918..00000000000 --- a/run.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# -# build zip package, but ensuring its from the current source -# turn off tests and other validation to speed it up -# TODO: can be sped up more, if shading is moved out of core/ -mvn -am -pl dev-tools,distribution/zip package -DskipTests -Drun -Pdev