mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-08 22:14:59 +00:00
Merge pull request #14791 from rjernst/run_away
Build: Make run command work within plugins
This commit is contained in:
commit
e837140385
@ -171,5 +171,9 @@ task clean(type: GradleBuild) {
|
|||||||
tasks = ['clean']
|
tasks = ['clean']
|
||||||
}
|
}
|
||||||
|
|
||||||
task run(dependsOn: ':distribution:run')
|
task run() {
|
||||||
|
dependsOn ':distribution:run'
|
||||||
|
description = 'Runs elasticsearch in the foreground'
|
||||||
|
group = 'Verification'
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.elasticsearch.gradle.plugin
|
package org.elasticsearch.gradle.plugin
|
||||||
|
|
||||||
import nebula.plugin.extraconfigurations.ProvidedBasePlugin
|
|
||||||
import org.elasticsearch.gradle.BuildPlugin
|
import org.elasticsearch.gradle.BuildPlugin
|
||||||
import org.elasticsearch.gradle.test.RestIntegTestTask
|
import org.elasticsearch.gradle.test.RestIntegTestTask
|
||||||
|
import org.elasticsearch.gradle.test.RunTask
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.tasks.bundling.Zip
|
import org.gradle.api.tasks.bundling.Zip
|
||||||
@ -33,26 +33,21 @@ class PluginBuildPlugin extends BuildPlugin {
|
|||||||
@Override
|
@Override
|
||||||
void apply(Project project) {
|
void apply(Project project) {
|
||||||
super.apply(project)
|
super.apply(project)
|
||||||
// TODO: add target compatibility (java version) to elasticsearch properties and set for the project
|
|
||||||
configureDependencies(project)
|
configureDependencies(project)
|
||||||
// this afterEvaluate must happen before the afterEvaluate added by integTest configure,
|
// this afterEvaluate must happen before the afterEvaluate added by integTest configure,
|
||||||
// so that the file name resolution for installing the plugin will be setup
|
// so that the file name resolution for installing the plugin will be setup
|
||||||
project.afterEvaluate {
|
project.afterEvaluate {
|
||||||
project.jar.configure {
|
String name = project.pluginProperties.extension.name
|
||||||
baseName project.pluginProperties.extension.name
|
project.jar.baseName = name
|
||||||
|
project.bundlePlugin.baseName = name
|
||||||
|
project.integTest.dependsOn(project.bundlePlugin)
|
||||||
|
project.integTest.clusterConfig.plugin(name, project.bundlePlugin.outputs.files)
|
||||||
|
project.tasks.run.dependsOn(project.bundlePlugin)
|
||||||
|
project.tasks.run.clusterConfig.plugin(name, project.bundlePlugin.outputs.files)
|
||||||
}
|
}
|
||||||
project.bundlePlugin.configure {
|
|
||||||
baseName project.pluginProperties.extension.name
|
|
||||||
}
|
|
||||||
project.integTest.configure {
|
|
||||||
dependsOn project.bundlePlugin
|
|
||||||
cluster {
|
|
||||||
plugin project.pluginProperties.extension.name, project.bundlePlugin.outputs.files
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Task bundle = configureBundleTask(project)
|
|
||||||
RestIntegTestTask.configure(project)
|
RestIntegTestTask.configure(project)
|
||||||
|
RunTask.configure(project)
|
||||||
|
Task bundle = configureBundleTask(project)
|
||||||
project.configurations.archives.artifacts.removeAll { it.archiveTask.is project.jar }
|
project.configurations.archives.artifacts.removeAll { it.archiveTask.is project.jar }
|
||||||
project.configurations.getByName('default').extendsFrom = []
|
project.configurations.getByName('default').extendsFrom = []
|
||||||
project.artifacts {
|
project.artifacts {
|
||||||
|
@ -102,7 +102,7 @@ class ClusterFormationTasks {
|
|||||||
String camelName = plugin.getKey().replaceAll(/-(\w)/) { _, c -> c.toUpperCase(Locale.ROOT) }
|
String camelName = plugin.getKey().replaceAll(/-(\w)/) { _, c -> c.toUpperCase(Locale.ROOT) }
|
||||||
String taskName = "${task.name}#install${camelName[0].toUpperCase(Locale.ROOT) + camelName.substring(1)}Plugin"
|
String taskName = "${task.name}#install${camelName[0].toUpperCase(Locale.ROOT) + camelName.substring(1)}Plugin"
|
||||||
// delay reading the file location until execution time by wrapping in a closure within a GString
|
// delay reading the file location until execution time by wrapping in a closure within a GString
|
||||||
String file = "${ -> new File(pluginsTmpDir, plugin.getValue().singleFile.getName()).toURI().toURL().toString() }"
|
String file = "${-> new File(pluginsTmpDir, plugin.getValue().singleFile.getName()).toURI().toURL().toString()}"
|
||||||
Object[] args = [new File(home, 'bin/plugin'), 'install', file]
|
Object[] args = [new File(home, 'bin/plugin'), 'install', file]
|
||||||
setup = configureExecTask(taskName, project, setup, cwd, args)
|
setup = configureExecTask(taskName, project, setup, cwd, args)
|
||||||
}
|
}
|
||||||
@ -115,9 +115,12 @@ class ClusterFormationTasks {
|
|||||||
Task start = configureStartTask("${task.name}#start", project, setup, cwd, config, clusterName, pidFile, home)
|
Task start = configureStartTask("${task.name}#start", project, setup, cwd, config, clusterName, pidFile, home)
|
||||||
task.dependsOn(start)
|
task.dependsOn(start)
|
||||||
|
|
||||||
|
if (config.daemonize) {
|
||||||
|
// if we are running in the background, make sure to stop the server when the task completes
|
||||||
Task stop = configureStopTask("${task.name}#stop", project, [], pidFile)
|
Task stop = configureStopTask("${task.name}#stop", project, [], pidFile)
|
||||||
task.finalizedBy(stop)
|
task.finalizedBy(stop)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Adds a task to extract the elasticsearch distribution */
|
/** Adds a task to extract the elasticsearch distribution */
|
||||||
static Task configureExtractTask(String name, Project project, Task setup, File baseDir, String distro) {
|
static Task configureExtractTask(String name, Project project, Task setup, File baseDir, String distro) {
|
||||||
|
@ -1,12 +1,23 @@
|
|||||||
package org.elasticsearch.gradle.test
|
package org.elasticsearch.gradle.test
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.Project
|
||||||
|
|
||||||
class RunTask extends DefaultTask {
|
class RunTask extends DefaultTask {
|
||||||
|
|
||||||
ClusterConfiguration clusterConfig = new ClusterConfiguration(httpPort: 9200, transportPort: 9300, daemonize: false)
|
ClusterConfiguration clusterConfig = new ClusterConfiguration(httpPort: 9200, transportPort: 9300, daemonize: false)
|
||||||
|
|
||||||
RunTask() {
|
RunTask() {
|
||||||
|
project.afterEvaluate {
|
||||||
ClusterFormationTasks.setup(project, this, clusterConfig)
|
ClusterFormationTasks.setup(project, this, clusterConfig)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void configure(Project project) {
|
||||||
|
RunTask task = project.tasks.create(
|
||||||
|
name: 'run',
|
||||||
|
type: RunTask,
|
||||||
|
description: "Runs elasticsearch with '${project.path}'",
|
||||||
|
group: 'Verification')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import org.apache.tools.ant.filters.FixCrLfFilter
|
import org.apache.tools.ant.filters.FixCrLfFilter
|
||||||
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
|
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
|
||||||
|
import org.elasticsearch.gradle.test.RunTask
|
||||||
import org.elasticsearch.gradle.MavenFilteringHack
|
import org.elasticsearch.gradle.MavenFilteringHack
|
||||||
|
|
||||||
// for deb/rpm
|
// for deb/rpm
|
||||||
@ -196,4 +197,5 @@ DependencyLicensesTask.configure(project) {
|
|||||||
mapping from: /jackson-.*/, to: 'jackson'
|
mapping from: /jackson-.*/, to: 'jackson'
|
||||||
}
|
}
|
||||||
|
|
||||||
task run(type:org.elasticsearch.gradle.test.RunTask){}
|
RunTask.configure(project)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user