2015-12-09 19:32:37 -05:00
|
|
|
/*
|
|
|
|
* Licensed to Elasticsearch under one or more contributor
|
|
|
|
* license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright
|
|
|
|
* ownership. Elasticsearch licenses this file to you under
|
|
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
2020-04-22 15:14:03 -04:00
|
|
|
|
2019-10-08 07:39:58 -04:00
|
|
|
import org.elasticsearch.gradle.testclusters.DefaultTestClustersTask;
|
2020-04-22 15:14:03 -04:00
|
|
|
apply plugin: 'elasticsearch.validate-rest-spec'
|
2019-11-14 06:01:23 -05:00
|
|
|
|
2015-12-09 19:32:37 -05:00
|
|
|
esplugin {
|
|
|
|
description 'An easy, safe and fast scripting language for Elasticsearch'
|
2016-01-27 13:37:34 -05:00
|
|
|
classname 'org.elasticsearch.painless.PainlessPlugin'
|
2015-12-09 19:32:37 -05:00
|
|
|
}
|
|
|
|
|
2019-04-04 04:41:38 -04:00
|
|
|
testClusters.integTest {
|
2020-04-13 11:53:35 -04:00
|
|
|
module project(':modules:mapper-extras').tasks.bundlePlugin.archiveFile
|
2018-08-09 08:32:36 -04:00
|
|
|
systemProperty 'es.scripting.update.ctx_in_params', 'false'
|
2019-08-16 12:40:04 -04:00
|
|
|
// TODO: remove this once cname is prepended to transport.publish_address by default in 8.0
|
|
|
|
systemProperty 'es.transport.cname_in_publish_address', 'true'
|
2017-09-13 11:58:53 -04:00
|
|
|
}
|
|
|
|
|
2015-12-09 19:32:37 -05:00
|
|
|
dependencies {
|
2017-10-27 14:07:49 -04:00
|
|
|
compile 'org.antlr:antlr4-runtime:4.5.3'
|
2019-11-20 10:07:33 -05:00
|
|
|
compile 'org.ow2.asm:asm-util:7.2'
|
|
|
|
compile 'org.ow2.asm:asm-tree:7.2'
|
|
|
|
compile 'org.ow2.asm:asm-commons:7.2'
|
|
|
|
compile 'org.ow2.asm:asm-analysis:7.2'
|
|
|
|
compile 'org.ow2.asm:asm:7.2'
|
2018-01-18 22:16:26 -05:00
|
|
|
compile project('spi')
|
2015-12-28 22:38:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencyLicenses {
|
|
|
|
mapping from: /asm-.*/, to: 'asm'
|
2015-12-09 19:32:37 -05:00
|
|
|
}
|
|
|
|
|
2020-03-19 13:28:59 -04:00
|
|
|
restResources {
|
|
|
|
restApi {
|
2020-04-13 11:53:35 -04:00
|
|
|
includeCore '_common', 'cluster', 'nodes', 'indices', 'index', 'search', 'get', 'bulk', 'update',
|
2020-03-19 13:28:59 -04:00
|
|
|
'scripts_painless_execute', 'put_script', 'delete_script'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-09 14:52:50 -04:00
|
|
|
test {
|
2019-07-24 03:04:00 -04:00
|
|
|
// in WhenThingsGoWrongTests we intentionally generate an out of memory error, this prevents the heap from being dumped to disk
|
|
|
|
jvmArgs '-XX:-OmitStackTraceInFastThrow', '-XX:-HeapDumpOnOutOfMemoryError'
|
2017-05-04 13:11:09 -04:00
|
|
|
}
|
|
|
|
|
2017-01-26 10:39:19 -05:00
|
|
|
/* Build Javadoc for the Java classes in Painless's public API that are in the
|
|
|
|
* Painless plugin */
|
2017-01-23 17:16:20 -05:00
|
|
|
task apiJavadoc(type: Javadoc) {
|
|
|
|
source = sourceSets.main.allJava
|
2017-08-23 01:15:15 -04:00
|
|
|
classpath = sourceSets.main.runtimeClasspath
|
2017-01-23 17:16:20 -05:00
|
|
|
include '**/org/elasticsearch/painless/api/'
|
|
|
|
destinationDir = new File(docsDir, 'apiJavadoc')
|
|
|
|
}
|
2019-04-23 12:10:47 -04:00
|
|
|
|
2017-01-23 17:16:20 -05:00
|
|
|
task apiJavadocJar(type: Jar) {
|
|
|
|
classifier = 'apiJavadoc'
|
|
|
|
from apiJavadoc
|
|
|
|
}
|
2019-04-23 12:10:47 -04:00
|
|
|
|
2017-01-23 17:16:20 -05:00
|
|
|
assemble.dependsOn apiJavadocJar
|
2017-01-26 10:39:19 -05:00
|
|
|
|
2019-04-23 12:10:47 -04:00
|
|
|
/**********************************************
|
|
|
|
* Context API Generation *
|
|
|
|
**********************************************/
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
doc
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2019-06-04 16:50:23 -04:00
|
|
|
docCompile project(':server')
|
2019-04-23 12:10:47 -04:00
|
|
|
docCompile project(':modules:lang-painless')
|
|
|
|
}
|
|
|
|
|
2019-10-08 07:39:58 -04:00
|
|
|
testClusters {
|
|
|
|
generateContextCluster {
|
2019-11-14 06:01:23 -05:00
|
|
|
testDistribution = 'DEFAULT'
|
2019-10-08 07:39:58 -04:00
|
|
|
}
|
2019-04-23 12:10:47 -04:00
|
|
|
}
|
|
|
|
|
2019-10-08 07:39:58 -04:00
|
|
|
task generateContextDoc(type: DefaultTestClustersTask) {
|
2019-11-14 06:01:23 -05:00
|
|
|
useCluster testClusters.generateContextCluster
|
2019-10-08 07:39:58 -04:00
|
|
|
doFirst {
|
|
|
|
project.javaexec {
|
|
|
|
main = 'org.elasticsearch.painless.ContextDocGenerator'
|
|
|
|
classpath = sourceSets.doc.runtimeClasspath
|
|
|
|
systemProperty "cluster.uri", "${-> testClusters.generateContextCluster.singleNode().getAllHttpSocketURI()}"
|
|
|
|
}.assertNormalExitValue()
|
|
|
|
}
|
2017-01-26 10:39:19 -05:00
|
|
|
}
|
2017-03-24 12:44:53 -04:00
|
|
|
|
|
|
|
/**********************************************
|
|
|
|
* Parser regeneration *
|
|
|
|
**********************************************/
|
|
|
|
|
|
|
|
configurations {
|
|
|
|
regenerate
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2017-10-27 14:07:49 -04:00
|
|
|
regenerate 'org.antlr:antlr4:4.5.3'
|
2017-03-24 12:44:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
String grammarPath = 'src/main/antlr'
|
|
|
|
String outputPath = 'src/main/java/org/elasticsearch/painless/antlr'
|
|
|
|
|
|
|
|
task cleanGenerated(type: Delete) {
|
|
|
|
delete fileTree(grammarPath) {
|
|
|
|
include '*.tokens'
|
|
|
|
}
|
|
|
|
delete fileTree(outputPath) {
|
|
|
|
include 'Painless*.java'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task regenLexer(type: JavaExec) {
|
|
|
|
dependsOn cleanGenerated
|
|
|
|
main = 'org.antlr.v4.Tool'
|
|
|
|
classpath = configurations.regenerate
|
|
|
|
systemProperty 'file.encoding', 'UTF-8'
|
|
|
|
systemProperty 'user.language', 'en'
|
|
|
|
systemProperty 'user.country', 'US'
|
|
|
|
systemProperty 'user.variant', ''
|
|
|
|
args '-Werror',
|
2019-11-14 06:01:23 -05:00
|
|
|
'-package', 'org.elasticsearch.painless.antlr',
|
|
|
|
'-o', outputPath,
|
|
|
|
"${file(grammarPath)}/PainlessLexer.g4"
|
2017-03-24 12:44:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
task regenParser(type: JavaExec) {
|
|
|
|
dependsOn regenLexer
|
|
|
|
main = 'org.antlr.v4.Tool'
|
|
|
|
classpath = configurations.regenerate
|
|
|
|
systemProperty 'file.encoding', 'UTF-8'
|
|
|
|
systemProperty 'user.language', 'en'
|
|
|
|
systemProperty 'user.country', 'US'
|
|
|
|
systemProperty 'user.variant', ''
|
|
|
|
args '-Werror',
|
2019-11-14 06:01:23 -05:00
|
|
|
'-package', 'org.elasticsearch.painless.antlr',
|
|
|
|
'-no-listener',
|
|
|
|
'-visitor',
|
|
|
|
// '-Xlog',
|
|
|
|
'-o', outputPath,
|
|
|
|
"${file(grammarPath)}/PainlessParser.g4"
|
2017-03-24 12:44:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
task regen {
|
|
|
|
dependsOn regenParser
|
|
|
|
doLast {
|
|
|
|
// moves token files to grammar directory for use with IDE's
|
|
|
|
ant.move(file: "${outputPath}/PainlessLexer.tokens", toDir: grammarPath)
|
|
|
|
ant.move(file: "${outputPath}/PainlessParser.tokens", toDir: grammarPath)
|
|
|
|
// make the generated classes package private
|
|
|
|
ant.replaceregexp(match: 'public ((interface|class) \\QPainless\\E\\w+)',
|
2019-11-14 06:01:23 -05:00
|
|
|
replace: '\\1',
|
|
|
|
encoding: 'UTF-8') {
|
2017-03-24 12:44:53 -04:00
|
|
|
fileset(dir: outputPath, includes: 'Painless*.java')
|
|
|
|
}
|
|
|
|
// make the lexer abstract
|
|
|
|
ant.replaceregexp(match: '(class \\QPainless\\ELexer)',
|
2019-11-14 06:01:23 -05:00
|
|
|
replace: 'abstract \\1',
|
|
|
|
encoding: 'UTF-8') {
|
2017-03-24 12:44:53 -04:00
|
|
|
fileset(dir: outputPath, includes: 'PainlessLexer.java')
|
|
|
|
}
|
|
|
|
// nuke timestamps/filenames in generated files
|
|
|
|
ant.replaceregexp(match: '\\Q// Generated from \\E.*',
|
2019-11-14 06:01:23 -05:00
|
|
|
replace: '\\/\\/ ANTLR GENERATED CODE: DO NOT EDIT',
|
|
|
|
encoding: 'UTF-8') {
|
2017-03-24 12:44:53 -04:00
|
|
|
fileset(dir: outputPath, includes: 'Painless*.java')
|
|
|
|
}
|
|
|
|
// remove tabs in antlr generated files
|
|
|
|
ant.replaceregexp(match: '\t', flags: 'g', replace: ' ', encoding: 'UTF-8') {
|
|
|
|
fileset(dir: outputPath, includes: 'Painless*.java')
|
|
|
|
}
|
|
|
|
// fix line endings
|
2017-10-06 16:44:03 -04:00
|
|
|
ant.fixcrlf(srcdir: outputPath, eol: 'lf') {
|
2017-03-24 12:44:53 -04:00
|
|
|
patternset(includes: 'Painless*.java')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-22 15:14:03 -04:00
|
|
|
|
|
|
|
validateRestSpec {
|
|
|
|
ignore 'scripts_painless_context.json'
|
|
|
|
}
|