Skip to content

Maven packaging

Pierre PINON edited this page Dec 7, 2017 · 12 revisions

Dependency

<dependencies>
  <dependency>
    <groupId>org.teknux</groupId>
    <artifactId>jetty-bootstrap</artifactId>
    <version>x.x.x</version>
  </dependency>
</dependencies>

One Jar (Jar with all dependencies)

You can use maven-shade-plugin :

<build>
  ...
  <plugins>
    ...
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-shade-plugin</artifactId>
      <version>2.0</version>
      <executions>
	<execution>
	  <phase>package</phase>
	  <goals>
	    <goal>shade</goal>
	  </goals>
	  <configuration>
	    <createDependencyReducedPom>false</createDependencyReducedPom>
	    <transformers>
	      <transformer
		implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
		<manifestEntries>
		  <Main-Class>org.example.Main</Main-Class>
		</manifestEntries>
	      </transformer>
	    </transformers>
	    <filters>
	      <filter>
		<artifact>*:*</artifact>
		<excludes>
		  <exclude>META-INF/*.SF</exclude>
		  <exclude>META-INF/*.DSA</exclude>
		  <exclude>META-INF/*.RSA</exclude>
		</excludes>
	      </filter>
	    </filters>
	  </configuration>
	</execution>
      </executions>
    </plugin>
    ...
  </plugins>
  ...
</build>

Add external War File in your Jar

You can copy a war file in your application by using copy-maven-plugin :

<build>
  ...
  <plugins>
    ...
    <plugin>
      <groupId>com.github.goldin</groupId>
      <artifactId>copy-maven-plugin</artifactId>
      <version>0.2.5</version>
      <executions>
	<execution>
	  <phase>prepare-package</phase>
	  <goals>
	    <goal>copy</goal>
	  </goals>
	  <configuration>
	    <resources>
	      <resource>
		<targetPath>${project.build.outputDirectory}/webapp</targetPath>
		<stripVersion>true</stripVersion>
		<dependencies>
		  <dependency>
		    <groupId>org.example</groupId>
		    <artifactId>myapp</artifactId>
		    <version>1.0.0-SNAPSHOT</version>
		    <type>war</type>
		  </dependency>
		</dependencies>
	      </resource>
	    </resources>
	  </configuration>
	</execution>
      </executions>
    </plugin>
    ...
  </plugins>
  ...
</build>

Add webapp resource directory (src/main/webapp) in your Jar

<build>
  ...
  <resources>
    <resource>
      <filtering>false</filtering>
      <directory>src/main/resources</directory>
    </resource>
    <resource>
      <directory>src/main/webapp</directory>
      <targetPath>webapp</targetPath>
      <includes>
	<include>**</include>
      </includes>
    </resource>
  </resources>
  ...
</build>

Add JSP Support [Since v1.0.1]

In v1.0.0, JSP Support is already include in jetty-bootstrap artifact

<build>
  ...
  <dependency>
    <groupId>org.teknux</groupId>
    <artifactId>jetty-bootstrap-jsp</artifactId>
    <version>x.x.x</version>
  </dependency>
  ...
</build>

Add Logs (Logback implementation) [Since v1.0.1]

In v1.0.0, Logs Support (Logback implementation) is already include in jetty-bootstrap artifact

<build>
  ...
  <dependency>
    <groupId>org.teknux</groupId>
    <artifactId>jetty-bootstrap-logs</artifactId>
    <version>x.x.x</version>
  </dependency>
  ...
</build>

Add Annotations support [Since v1.0.1]

<build>
  ...
  <dependency>
    <groupId>org.teknux</groupId>
    <artifactId>jetty-bootstrap-annotations</artifactId>
    <version>x.x.x</version>
  </dependency>
  ...
</build>

Use Jetty Bootstrap Standalone Server [Since v1.0.1]

<dependency>
  <groupId>org.teknux</groupId>
  <artifactId>jetty-bootstrap-standalone</artifactId>
  <version>x.x.x</version>
</dependency>

Add WebSocket support [Since v1.0.5]

<build>
  ...
  <dependency>
    <groupId>org.teknux</groupId>
    <artifactId>jetty-bootstrap-websocket</artifactId>
    <version>x.x.x</version>
  </dependency>
  ...
</build>

Add Servlets support [Since v1.0.12]

<build>
  ...
  <dependency>
    <groupId>org.teknux</groupId>
    <artifactId>jetty-bootstrap-servlets</artifactId>
    <version>x.x.x</version>
  </dependency>
  ...
</build>