IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Embedding jar with dependencies
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Embedding jar with dependencies
editIf you want to create a single jar containing your application and all dependencies, you should not
use maven-assembly-plugin for that because it can not deal with META-INF/services structure which is
required by Lucene jars.
Instead, you can use maven-shade-plugin and configure it as follow:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>shade</goal></goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
Note that if you have a main class you want to automatically call when running java -jar yourjar.jar, just add
it to the transformers:
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.elasticsearch.demo.Generate</mainClass>
</transformer>