diff --git a/.gitignore b/.gitignore
index 6d851a6..9533848 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,8 @@
.DS_Store
*.iml
/.project
-/.classpath
/.settings
-.local-execution-hints.log
+/.classpath
+/plugin_tools
+/.local-execution-hints.log
+/.local-*-execution-hints.log
diff --git a/README.md b/README.md
index a5120e6..285487a 100644
--- a/README.md
+++ b/README.md
@@ -3,15 +3,11 @@ JavaScript lang Plugin for Elasticsearch
The JavaScript language plugin allows to have `javascript` (or `js`) as the language of scripts to execute.
-In order to install the plugin, simply run: `bin/plugin -install elasticsearch/elasticsearch-lang-javascript/2.0.0.RC1`.
+## Version 2.7.1-SNAPSHOT for Elasticsearch: 1.7
-* For 1.0.x elasticsearch versions, look at [master branch](https://github.com/elasticsearch/elasticsearch-lang-javascript/tree/master).
-* For 0.90.x elasticsearch versions, look at [1.x branch](https://github.com/elasticsearch/elasticsearch-lang-javascript/tree/1.x).
+If you are looking for another version documentation, please refer to the
+[compatibility matrix](http://github.com/elasticsearch/elasticsearch-lang-javascript#javascript-lang-plugin-for-elasticsearch).
-| JavaScript Lang Plugin | elasticsearch | rhino | Release date |
-|-----------------------------|---------------------|----------|:------------:|
-| 2.0.0-SNAPSHOT | 1.0.0.RC1 -> master | 1.7R4 | XXXX-XX-XX |
-| 2.0.0.RC1 | 1.0.0.RC1 -> master | 1.7R4 | 2014-01-15 |
Using javascript with function_score
------------------------------------
diff --git a/dev-tools/build_release.py b/dev-tools/build_release.py
deleted file mode 100755
index 74acd8c..0000000
--- a/dev-tools/build_release.py
+++ /dev/null
@@ -1,693 +0,0 @@
-# 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.
-
-import re
-import tempfile
-import shutil
-import os
-import datetime
-import argparse
-import github3
-import smtplib
-
-from email.mime.multipart import MIMEMultipart
-from email.mime.text import MIMEText
-
-from os.path import dirname, abspath
-
-"""
- This tool builds a release from the a given elasticsearch plugin branch.
- In order to execute it go in the top level directory and run:
- $ python3 dev_tools/build_release.py --branch master --publish --remote origin
-
- By default this script runs in 'dry' mode which essentially simulates a release. If the
- '--publish' option is set the actual release is done.
- If not in 'dry' mode, a mail will be automatically sent to the mailing list.
- You can disable it with the option '--disable_mail'
-
- $ python3 dev_tools/build_release.py --publish --remote origin --disable_mail
-
- The script takes over almost all
- steps necessary for a release from a high level point of view it does the following things:
-
- - run prerequisite checks ie. check for S3 credentials available as env variables
- - detect the version to release from the specified branch (--branch) or the current branch
- - creates a release branch & updates pom.xml and README.md to point to a release version rather than a snapshot
- - builds the artifacts
- - commits the new version and merges the release branch into the source branch
- - creates a tag and pushes the commit to the specified origin (--remote)
- - publishes the releases to sonatype and S3
- - send a mail based on github issues fixed by this version
-
-Once it's done it will print all the remaining steps.
-
- Prerequisites:
- - Python 3k for script execution
- - Boto for S3 Upload ($ apt-get install python-boto or pip-3.3 install boto)
- - github3 module (pip-3.3 install github3.py)
- - S3 keys exported via ENV Variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
- - GITHUB (login/password) or key exported via ENV Variables (GITHUB_LOGIN, GITHUB_PASSWORD or GITHUB_KEY)
- (see https://github.com/settings/applications#personal-access-tokens) - Optional: default to no authentication
- - SMTP_HOST - Optional: default to localhost
- - MAIL_SENDER - Optional: default to 'david@pilato.fr': must be authorized to send emails to elasticsearch mailing list
- - MAIL_TO - Optional: default to 'elasticsearch@googlegroups.com'
-"""
-env = os.environ
-
-LOG = env.get('ES_RELEASE_LOG', '/tmp/elasticsearch_release.log')
-ROOT_DIR = os.path.join(abspath(dirname(__file__)), '../')
-README_FILE = ROOT_DIR + 'README.md'
-POM_FILE = ROOT_DIR + 'pom.xml'
-
-def log(msg):
- log_plain('\n%s' % msg)
-
-def log_plain(msg):
- f = open(LOG, mode='ab')
- f.write(msg.encode('utf-8'))
- f.close()
-
-def run(command, quiet=False):
- log('%s: RUN: %s\n' % (datetime.datetime.now(), command))
- if os.system('%s >> %s 2>&1' % (command, LOG)):
- msg = ' FAILED: %s [see log %s]' % (command, LOG)
- if not quiet:
- print(msg)
- raise RuntimeError(msg)
-
-try:
- JAVA_HOME = env['JAVA_HOME']
-except KeyError:
- raise RuntimeError("""
- Please set JAVA_HOME in the env before running release tool
- On OSX use: export JAVA_HOME=`/usr/libexec/java_home -v '1.6*'`""")
-
-try:
- MVN='mvn'
- # make sure mvn3 is used if mvn3 is available
- # some systems use maven 2 as default
- run('mvn3 --version', quiet=True)
- MVN='mvn3'
-except RuntimeError:
- pass
-
-
-def java_exe():
- path = JAVA_HOME
- return 'export JAVA_HOME="%s" PATH="%s/bin:$PATH" JAVACMD="%s/bin/java"' % (path, path, path)
-
-# Returns the hash of the current git HEAD revision
-def get_head_hash():
- return os.popen(' git rev-parse --verify HEAD 2>&1').read().strip()
-
-# Returns the hash of the given tag revision
-def get_tag_hash(tag):
- return os.popen('git show-ref --tags %s --hash 2>&1' % (tag)).read().strip()
-
-# Returns the name of the current branch
-def get_current_branch():
- return os.popen('git rev-parse --abbrev-ref HEAD 2>&1').read().strip()
-
-# Utility that returns the name of the release branch for a given version
-def release_branch(version):
- return 'release_branch_%s' % version
-
-# runs get fetch on the given remote
-def fetch(remote):
- run('git fetch %s' % remote)
-
-# Creates a new release branch from the given source branch
-# and rebases the source branch from the remote before creating
-# the release branch. Note: This fails if the source branch
-# doesn't exist on the provided remote.
-def create_release_branch(remote, src_branch, release):
- run('git checkout %s' % src_branch)
- run('git pull --rebase %s %s' % (remote, src_branch))
- run('git checkout -b %s' % (release_branch(release)))
-
-
-# Reads the given file and applies the
-# callback to it. If the callback changed
-# a line the given file is replaced with
-# the modified input.
-def process_file(file_path, line_callback):
- fh, abs_path = tempfile.mkstemp()
- modified = False
- with open(abs_path,'w', encoding='utf-8') as new_file:
- with open(file_path, encoding='utf-8') as old_file:
- for line in old_file:
- new_line = line_callback(line)
- modified = modified or (new_line != line)
- new_file.write(new_line)
- os.close(fh)
- if modified:
- #Remove original file
- os.remove(file_path)
- #Move new file
- shutil.move(abs_path, file_path)
- return True
- else:
- # nothing to do - just remove the tmp file
- os.remove(abs_path)
- return False
-
-# Guess the next snapshot version number (increment second digit)
-def guess_snapshot(version):
- digits=list(map(int, re.findall(r'\d+', version)))
- source='%s.%s' % (digits[0], digits[1])
- destination='%s.%s' % (digits[0], digits[1]+1)
- return version.replace(source, destination)
-
-# Moves the pom.xml file from a snapshot to a release
-def remove_maven_snapshot(pom, release):
- pattern = '%s-SNAPSHOT' % release
- replacement = '%s' % release
- def callback(line):
- return line.replace(pattern, replacement)
- process_file(pom, callback)
-
-# Moves the README.md file from a snapshot to a release
-def remove_version_snapshot(readme_file, release):
- pattern = '%s-SNAPSHOT' % release
- replacement = '%s ' % release
- def callback(line):
- return line.replace(pattern, replacement)
- process_file(readme_file, callback)
-
-# Moves the pom.xml file to the next snapshot
-def add_maven_snapshot(pom, release, snapshot):
- pattern = '%s' % release
- replacement = '%s-SNAPSHOT' % snapshot
- def callback(line):
- return line.replace(pattern, replacement)
- process_file(pom, callback)
-
-# Add in README.md file the next snapshot
-def add_version_snapshot(readme_file, release, snapshot):
- pattern = '| %s ' % release
- replacement = '| %s-SNAPSHOT' % snapshot
- def callback(line):
- # If we find pattern, we copy the line and replace its content
- if line.find(pattern) >= 0:
- return line.replace(pattern, replacement).replace('%s' % (datetime.datetime.now().strftime("%Y-%m-%d")),
- 'XXXX-XX-XX')+line
- else:
- return line
- process_file(readme_file, callback)
-
-
-# Set release date in README.md file
-def set_date(readme_file):
- pattern = 'XXXX-XX-XX'
- replacement = '%s' % (datetime.datetime.now().strftime("%Y-%m-%d"))
- def callback(line):
- return line.replace(pattern, replacement)
- process_file(readme_file, callback)
-
-# Update installation instructions in README.md file
-def set_install_instructions(readme_file, artifact_name, release):
- pattern = '`bin/plugin -install elasticsearch/%s/.+`' % artifact_name
- replacement = '`bin/plugin -install elasticsearch/%s/%s`' % (artifact_name, release)
- def callback(line):
- return re.sub(pattern, replacement, line)
- process_file(readme_file, callback)
-
-
-# Stages the given files for the next git commit
-def add_pending_files(*files):
- for file in files:
- run('git add %s' % file)
-
-# Executes a git commit with 'release [version]' as the commit message
-def commit_release(artifact_id, release):
- run('git commit -m "prepare release %s-%s"' % (artifact_id, release))
-
-def commit_snapshot():
- run('git commit -m "prepare for next development iteration"')
-
-def tag_release(release):
- run('git tag -a v%s -m "Tag release version %s"' % (release, release))
-
-def run_mvn(*cmd):
- for c in cmd:
- run('%s; %s -f %s %s' % (java_exe(), MVN, POM_FILE, c))
-
-def build_release(run_tests=False, dry_run=True):
- target = 'deploy'
- if dry_run:
- target = 'package'
- if run_tests:
- run_mvn('clean test')
- run_mvn('clean %s -DskipTests' %(target))
-
-# Checks the pom.xml for the release version. 2.0.0-SNAPSHOT
-# This method fails if the pom file has no SNAPSHOT version set ie.
-# if the version is already on a release version we fail.
-# Returns the next version string ie. 0.90.7
-def find_release_version(src_branch):
- run('git checkout %s' % src_branch)
- with open(POM_FILE, encoding='utf-8') as file:
- for line in file:
- match = re.search(r'(.+)-SNAPSHOT', line)
- if match:
- return match.group(1)
- raise RuntimeError('Could not find release version in branch %s' % src_branch)
-
-# extract a value from pom.xml
-def find_from_pom(tag):
- with open(POM_FILE, encoding='utf-8') as file:
- for line in file:
- match = re.search(r'<%s>(.+)%s>' % (tag, tag), line)
- if match:
- return match.group(1)
- raise RuntimeError('Could not find <%s> in pom.xml file' % (tag))
-
-def get_artifacts(artifact_id, release):
- artifact_path = ROOT_DIR + 'target/releases/%s-%s.zip' % (artifact_id, release)
- print(' Path %s' % (artifact_path))
- if not os.path.isfile(artifact_path):
- raise RuntimeError('Could not find required artifact at %s' % (artifact_path))
- return artifact_path
-
-# Generates sha1 for a file
-# and returns the checksum files as well
-# as the given files in a list
-def generate_checksums(release_file):
- res = []
- directory = os.path.dirname(release_file)
- file = os.path.basename(release_file)
- checksum_file = '%s.sha1.txt' % file
-
- if os.system('cd %s; shasum %s > %s' % (directory, file, checksum_file)):
- raise RuntimeError('Failed to generate checksum for file %s' % release_file)
- res = res + [os.path.join(directory, checksum_file), release_file]
- return res
-
-def git_merge(src_branch, release_version):
- run('git checkout %s' % src_branch)
- run('git merge %s' % release_branch(release_version))
-
-def git_push(remote, src_branch, release_version, dry_run):
- if not dry_run:
- run('git push %s %s' % (remote, src_branch)) # push the commit
- run('git push %s v%s' % (remote, release_version)) # push the tag
- else:
- print(' dryrun [True] -- skipping push to remote %s' % remote)
-
-def publish_artifacts(artifacts, base='elasticsearch/elasticsearch', dry_run=True):
- location = os.path.dirname(os.path.realpath(__file__))
- for artifact in artifacts:
- if dry_run:
- print('Skip Uploading %s to Amazon S3 in %s' % (artifact, base))
- else:
- print('Uploading %s to Amazon S3' % artifact)
- # requires boto to be installed but it is not available on python3k yet so we use a dedicated tool
- run('python %s/upload-s3.py --file %s --path %s' % (location, os.path.abspath(artifact), base))
-
-
-#################
-##
-##
-## Email and Github Management
-##
-##
-#################
-def format_issues_plain(issues, title='Fix'):
- response = ""
-
- if len(issues) > 0:
- response += '%s:\n' % title
- for issue in issues:
- response += ' * [%s] - %s (%s)\n' % (issue.number, issue.title, issue.html_url)
-
- return response
-
-def format_issues_html(issues, title='Fix'):
- response = ""
-
- if len(issues) > 0:
- response += '
%s
\n
\n' % title
- for issue in issues:
- response += '