Skip to content

Commit f56434a

Browse files
author
AJRaffles
committed
Initial commit of template plugin
0 parents  commit f56434a

File tree

7 files changed

+217
-0
lines changed

7 files changed

+217
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/target/*
2+
**/.idea/*
3+
*.iml

pom.xml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>uk.co.ctdev</groupId>
8+
<artifactId>tidy-elastic</artifactId>
9+
<version>0.0.1</version>
10+
<name>elastic-tidy</name>
11+
<description>Plugin to delete indices when required</description>
12+
13+
14+
<properties>
15+
<elasticsearch.version>5.0.0-alpha5</elasticsearch.version>
16+
</properties>
17+
18+
<build>
19+
<resources>
20+
<resource>
21+
<directory>src/main/resources</directory>
22+
<filtering>false</filtering>
23+
<excludes>
24+
<exclude>*.properties</exclude>
25+
</excludes>
26+
</resource>
27+
</resources>
28+
29+
<plugins>
30+
<plugin>
31+
<groupId>org.apache.maven.plugins</groupId>
32+
<artifactId>maven-assembly-plugin</artifactId>
33+
<version>2.6</version>
34+
<configuration>
35+
<appendAssemblyId>false</appendAssemblyId>
36+
<outputDirectory>${project.build.directory}/releases/</outputDirectory>
37+
<descriptors>
38+
<descriptor>${basedir}/src/main/assemblies/plugin.xml</descriptor>
39+
</descriptors>
40+
</configuration>
41+
<executions>
42+
<execution>
43+
<phase>package</phase>
44+
<goals>
45+
<goal>single</goal>
46+
</goals>
47+
</execution>
48+
</executions>
49+
</plugin>
50+
<plugin>
51+
<groupId>org.apache.maven.plugins</groupId>
52+
<artifactId>maven-compiler-plugin</artifactId>
53+
<version>3.3</version>
54+
<configuration>
55+
<source>1.8</source>
56+
<target>1.8</target>
57+
</configuration>
58+
</plugin>
59+
<plugin>
60+
<!-- we skip surefire to work with randomized testing above -->
61+
<groupId>org.apache.maven.plugins</groupId>
62+
<artifactId>maven-surefire-plugin</artifactId>
63+
<version>2.9</version>
64+
<configuration>
65+
<skipTests>true</skipTests>
66+
</configuration>
67+
</plugin>
68+
<plugin>
69+
<groupId>com.carrotsearch.randomizedtesting</groupId>
70+
<artifactId>junit4-maven-plugin</artifactId>
71+
<version>2.3.3</version>
72+
73+
<configuration>
74+
<assertions enableSystemAssertions="false">
75+
<enable/>
76+
</assertions>
77+
78+
<listeners>
79+
<report-text />
80+
</listeners>
81+
</configuration>
82+
83+
<executions>
84+
<execution>
85+
<id>unit-tests</id>
86+
<phase>test</phase>
87+
<goals>
88+
<goal>junit4</goal>
89+
</goals>
90+
</execution>
91+
</executions>
92+
</plugin>
93+
</plugins>
94+
</build>
95+
96+
<dependencies>
97+
<dependency>
98+
<groupId>org.elasticsearch</groupId>
99+
<artifactId>elasticsearch</artifactId>
100+
<version>${elasticsearch.version}</version>
101+
<scope>provided</scope>
102+
</dependency>
103+
104+
<dependency>
105+
<groupId>org.elasticsearch.test</groupId>
106+
<artifactId>framework</artifactId>
107+
<version>${elasticsearch.version}</version>
108+
<scope>test</scope>
109+
</dependency>
110+
<dependency>
111+
<groupId>net.java.dev.jna</groupId>
112+
<artifactId>jna</artifactId>
113+
<version>4.1.0</version>
114+
<scope>test</scope>
115+
</dependency>
116+
<dependency>
117+
<groupId>log4j</groupId>
118+
<artifactId>log4j</artifactId>
119+
<version>1.2.17</version>
120+
<scope>test</scope>
121+
</dependency>
122+
</dependencies>
123+
124+
</project>

src/main/assemblies/plugin.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0"?>
2+
<assembly>
3+
<id>plugin</id>
4+
<formats>
5+
<format>zip</format>
6+
</formats>
7+
<includeBaseDirectory>false</includeBaseDirectory>
8+
<files>
9+
<file>
10+
<source>${project.basedir}/src/main/resources/plugin-descriptor.properties</source>
11+
<outputDirectory>elasticsearch</outputDirectory>
12+
<filtered>true</filtered>
13+
</file>
14+
</files>
15+
<dependencySets>
16+
<dependencySet>
17+
<outputDirectory>elasticsearch</outputDirectory>
18+
<useProjectArtifact>true</useProjectArtifact>
19+
<useTransitiveFiltering>true</useTransitiveFiltering>
20+
</dependencySet>
21+
</dependencySets>
22+
</assembly>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package co.uk.ctdev.tidyelastic;
2+
3+
import org.elasticsearch.plugins.Plugin;
4+
5+
/**
6+
* TidyPlugin.
7+
*/
8+
public class TidyPlugin extends Plugin {
9+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
description=${project.description}.
2+
version=${project.version}
3+
name=${project.artifactId}
4+
classname=org.elasticsearch.ingest.bano.IngestBanoPlugin
5+
java.version=1.8
6+
elasticsearch.version=${elasticsearch.version}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package co.uk.ctdev.tidyelastic;
2+
3+
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
4+
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
5+
import org.elasticsearch.plugins.Plugin;
6+
import org.elasticsearch.plugins.PluginInfo;
7+
import org.elasticsearch.test.ESIntegTestCase;
8+
9+
import java.util.Collection;
10+
import java.util.Collections;
11+
12+
import static org.hamcrest.Matchers.is;
13+
14+
/**
15+
* TidyPluginTest.
16+
*/
17+
public class TidyPluginTest extends ESIntegTestCase {
18+
19+
@Override
20+
protected Collection<Class<? extends Plugin>> nodePlugins() {
21+
return Collections.singleton(TidyPlugin.class);
22+
}
23+
24+
public void testPluginIsLoaded() throws Exception {
25+
NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get();
26+
for (NodeInfo nodeInfo : response.getNodes()) {
27+
boolean pluginFound = false;
28+
for (PluginInfo pluginInfo : nodeInfo.getPlugins().getPluginInfos()) {
29+
if (pluginInfo.getName().equals(TidyPlugin.class.getName())) {
30+
pluginFound = true;
31+
break;
32+
}
33+
}
34+
assertThat(pluginFound, is(true));
35+
}
36+
}
37+
}

src/test/resources/log4j.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3+
<log4j:configuration>
4+
5+
<appender name="console" class="org.apache.log4j.ConsoleAppender">
6+
<layout class="org.apache.log4j.PatternLayout">
7+
<param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%-25c] %m%n"/>
8+
</layout>
9+
</appender>
10+
11+
<root>
12+
<level value="INFO"/>
13+
<appender-ref ref="console"/>
14+
</root>
15+
16+
</log4j:configuration>

0 commit comments

Comments
 (0)