replacing run.bat and run.sh with gradle run

run.sh and run.bat were calling out to the old maven build system.
This is no longer in place, so we've created new gradle tasks to
start an elasticsearch node from the current codebase.

fixed #14423
This commit is contained in:
andrejserafim 2015-11-02 20:14:45 +00:00
parent 28015d9e03
commit 2bd353d72d
9 changed files with 29 additions and 17 deletions

View File

@ -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.

View File

@ -199,3 +199,5 @@ task buildSrcEclipse(type: GradleBuild) {
}
tasks.eclipse.dependsOn(buildSrcEclipse)
task run(dependsOn: ':distribution:run')

View File

@ -36,6 +36,9 @@ class ClusterConfiguration {
@Input
int transportPort = 9500
@Input
boolean daemonize = true
@Input
String jvmArgs = System.getProperty('tests.jvm.argline', '')

View File

@ -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')
}
}
}

View File

@ -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)
}
}

View File

@ -136,4 +136,3 @@ if (isEclipse == false || project.path == "${projectsPrefix}:core-tests") {
Task copyRestSpec = RestSpecHack.configureTask(project, true)
integTest.dependsOn copyRestSpec
}

View File

@ -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){}

View File

@ -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

6
run.sh
View File

@ -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