Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Commit

Permalink
update to ES 2.1.1, introducing gradle and integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jprante committed Dec 20, 2015
1 parent e505506 commit 01103e1
Show file tree
Hide file tree
Showing 29 changed files with 511 additions and 190 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
/.settings
/.classpath
/.project
/.gradle
/build
/plugins
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
sudo: false
language: java
jdk:
- oraclejdk8

cache:
directories:
- $HOME/.m2
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ zh-tw

| Elasticsearch | Plugin | Release date |
| -------------- | -------------- | ------------ |
| 2.1.1 | 2.1.1.0 | Dec 20, 2015 |
| 2.1.0 | 2.1.0.0 | Dec 15, 2015 |
| 2.0.1 | 2.0.1.0 | Dec 15, 2015 |
| 2.0.0 | 2.0.0.0 | Nov 12, 2015 |
Expand All @@ -95,13 +96,13 @@ zh-tw
| 1.2.1 | 1.2.1.1 | Jun 18, 2014 |


## Installation Elasticsearch 1.x
## Installation Elasticsearch 2.x

./bin/plugin -install langdetect -url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-langdetect/1.6.0.0/elasticsearch-langdetect-1.6.0.0-plugin.zip
./bin/plugin install http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-langdetect/2.1.1.0/elasticsearch-langdetect-2.1.1.0-plugin.zip

## Installation Elasticsearch 2.x
## Installation Elasticsearch 1.x

./bin/plugin install http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-langdetect/2.1.0.0/elasticsearch-langdetect-2.1.0.0-plugin.zip
./bin/plugin -install langdetect -url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-langdetect/1.6.0.0/elasticsearch-langdetect-1.6.0.0-plugin.zip

Do not forget to restart the node after installing.

Expand Down
168 changes: 168 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@

def xbibGroup = 'org.xbib.elasticsearch.plugin'
def xbibVersion = '2.1.1.0'

group = xbibGroup
version = xbibVersion

println "Current JVM: " + org.gradle.internal.jvm.Jvm.current()

ext {
pluginName = 'langdetect'
pluginClassname = 'org.xbib.elasticsearch.plugin.langdetect.LangdetectPlugin'
pluginDescription = 'Language detection for Elasticsearch'
versions = [
'log4j': '2.5',
'junit' : '4.12',
'elasticsearch' : '2.1.1',
'jackson': '2.6.2'
]
}

apply plugin: 'java'
apply plugin: 'maven'

repositories {
mavenCentral()
mavenLocal()
jcenter()
maven {
url "http://xbib.org/repository"
}
}

sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/java')
}
resources.srcDir file('src/integration-test/resources')
}
}
configurations {
providedCompile
releaseJars
wagon
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}

dependencies {
compile "org.elasticsearch:elasticsearch:${versions.elasticsearch}"
compile "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}"
releaseJars("com.fasterxml.jackson.core:jackson-databind:${versions.jackson}") {
exclude module: "jackson-core"
}
testCompile "junit:junit:${versions.junit}"
testCompile "org.apache.logging.log4j:log4j-slf4j-impl:${versions.log4j}"
testCompile "org.apache.logging.log4j:log4j-core:${versions.log4j}"
integrationTestCompile "junit:junit:${versions.junit}"
integrationTestCompile "org.elasticsearch:elasticsearch:${versions.elasticsearch}"
wagon 'org.apache.maven.wagon:wagon-ssh-external:2.10'
}

compileJava {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}

tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

test {
systemProperties['path.home'] = System.getProperty("user.dir")
testLogging {
showStandardStreams = false
exceptionFormat = 'full'
}
}

task makePluginDescriptor(type: Copy) {
from 'src/main/templates'
into 'build/tmp/plugin'
expand([
'descriptor': [
'name': pluginName,
'classname': pluginClassname,
'description': pluginDescription,
'jvm': true,
'site': false,
'isolated': true,
'version': project.property('version'),
'javaVersion': project.property('targetCompatibility'),
'elasticsearchVersion' : versions.elasticsearch
]
])
}

task buildPluginZip(type: Zip, dependsOn: [':jar', ':makePluginDescriptor']) {
from files(libsDir)
from configurations.releaseJars
from 'build/tmp/plugin'
classifier = 'plugin'
}

task unpackPlugin(type: Copy, dependsOn: [':buildPluginZip']) {
delete "plugins"
from files(libsDir)
from configurations.releaseJars
from 'build/tmp/plugin'
into "plugins/${pluginName}"
}

task integrationTest(type: Test, dependsOn: ['unpackPlugin']) {
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = configurations.integrationTestCompile
classpath += fileTree("plugins/${pluginName}").include('*.jar')
classpath += sourceSets.integrationTest.output
// without this trick to remove identical jars from classpath, an Elasticsearch bug whines about a "jar hell"
classpath -= configurations.releaseJars
outputs.upToDateWhen { false }
systemProperty 'path.home', projectDir.absolutePath
testLogging.showStandardStreams = false
}

integrationTest.mustRunAfter test
check.dependsOn integrationTest

clean {
delete "plugins"
}

task sourcesJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allSource
classifier 'sources'
}

artifacts {
archives sourcesJar
archives buildPluginZip
}

uploadArchives {
repositories {
if (project.hasProperty("xbibUsername")) {
mavenDeployer {
configuration = configurations.wagon
repository(
id: 'xbib.org',
url: uri('scpexe://xbib.org/repository'),
authentication: [userName: xbibUsername, privateKey: xbibPrivateKey]
)
pom.project {
inceptionYear '2012'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}
}
}
}
58 changes: 25 additions & 33 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

<groupId>org.xbib.elasticsearch.plugin</groupId>
<artifactId>elasticsearch-langdetect</artifactId>
<version>2.1.0.0</version>
<version>2.1.1.0</version>

<packaging>jar</packaging>

<name>elasticsearch-langdetect</name>
<description>ElasticSearch Language detection plugin</description>
<description>Language detection plugin for Elasticsearch</description>

<url>http://github.com/jprante/elasticsearch-langdetect</url>

Expand Down Expand Up @@ -68,9 +68,18 @@
<properties>
<github.global.server>github</github.global.server>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.compiler.version>1.7</java.compiler.version>
<elasticsearch.version>2.1.0</elasticsearch.version>
<java.version>1.7</java.version>
<elasticsearch.version>2.1.1</elasticsearch.version>
<jackson.version>2.6.2</jackson.version>
<descriptor.javaVersion>${java.version}</descriptor.javaVersion>
<descriptor.elasticsearchVersion>${elasticsearch.version}</descriptor.elasticsearchVersion>
<descriptor.classname>org.xbib.elasticsearch.plugin.langdetect.LangdetectPlugin</descriptor.classname>
<descriptor.name>langdetect</descriptor.name>
<descriptor.description>${project.description}</descriptor.description>
<descriptor.jvm>true</descriptor.jvm>
<descriptor.isolated>true</descriptor.isolated>
<descriptor.site>false</descriptor.site>
<descriptor.version>${project.version}</descriptor.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -110,14 +119,14 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.4.1</version>
<version>2.5</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.4.1</version>
<version>2.5</version>
<scope>test</scope>
</dependency>

Expand All @@ -128,19 +137,22 @@
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>2.9</version>
<version>2.10</version>
</extension>
</extensions>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
<resource>
<directory>${basedir}/src/main/templates</directory>
<filtering>true</filtering>
<includes>
<include>plugin-descriptor.properties</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<directory>${basedir}/src/main/templates</directory>
<filtering>false</filtering>
<excludes>
<exclude>plugin-descriptor.properties</exclude>
Expand All @@ -153,8 +165,8 @@
<version>3.3</version>
<configuration>
<encoding>UTF-8</encoding>
<source>${java.compiler.version}</source>
<target>${java.compiler.version}</target>
<source>${java.version}</source>
<target>${java.version}</target>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<compilerArgument>-Xlint:all,-serial,-path,-rawtypes,-unchecked</compilerArgument>
Expand All @@ -173,11 +185,8 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<version>2.19</version>
<configuration>
<includes>
<include>**/*Tests.java</include>
</includes>
<systemProperties>
<property>
<name>path.home</name>
Expand Down Expand Up @@ -223,23 +232,6 @@
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
</configuration>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
Expand Down Expand Up @@ -270,7 +262,7 @@
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.9</version>
<version>0.12</version>
<configuration>
<message>Building site for ${project.version}</message>
</configuration>
Expand Down Expand Up @@ -300,7 +292,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.18.1</version>
<version>2.19</version>
</plugin>
</plugins>
</reporting>
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'elasticsearch-langdetect'
28 changes: 28 additions & 0 deletions src/integration-test/java/org/elasticsearch/node/MockNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

package org.elasticsearch.node;

import org.elasticsearch.Version;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.plugins.Plugin;

import java.util.ArrayList;
import java.util.Collection;

public class MockNode extends Node {

public MockNode(Settings settings, Collection<Class<? extends Plugin>> classpathPlugins) {
super(InternalSettingsPreparer.prepareEnvironment(settings, null), Version.CURRENT, classpathPlugins);
}

public MockNode(Settings settings, Class<? extends Plugin> classpathPlugin) {
this(settings, list(classpathPlugin));
}

private static Collection<Class<? extends Plugin>> list(Class<? extends Plugin> classpathPlugin) {
Collection<Class<? extends Plugin>> list = new ArrayList<>();
list.add(classpathPlugin);
return list;
}

}
Loading

0 comments on commit 01103e1

Please sign in to comment.