Skip to content

Instantly share code, notes, and snippets.

@jrs53
Created July 18, 2019 14:30
Show Gist options
  • Save jrs53/dc9c14e383e814c5e2b95e439152f83e to your computer and use it in GitHub Desktop.
Save jrs53/dc9c14e383e814c5e2b95e439152f83e to your computer and use it in GitHub Desktop.
Maven & Jetty issues
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>omitted</groupId>
<artifactId>omitted</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cxf-version>3.3.2</cxf-version>
<swagger-ui-version>1.5.22</swagger-ui-version>
<jakarta-version>2.1.5</jakarta-version>
<jackson-jaxrs-version>2.9.9</jackson-jaxrs-version>
<spring-version>5.1.8.RELEASE</spring-version>
<beanvalidation-version>1.1.0.Final</beanvalidation-version>
<swagger-ui-version>3.22.2</swagger-ui-version>
<jetty-version>9.4.19.v20190610</jetty-version>
<!--
<junit-version>4.12</junit-version>
<servlet-api-version>2.5</servlet-api-version>
-->
</properties>
<dependencies>
<!-- From description-swagger2-web -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>3.23.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description-swagger</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>${jakarta-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-jaxrs-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${beanvalidation-version}</version>
</dependency>
<!-- Trial and error -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description</artifactId>
<version>${cxf-version}</version>
</dependency>
<!-- Compile dependencies -->
<!--
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description-swagger</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-policy</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-wsdl</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-jaxrs-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson-jaxrs-version}</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>${swagger-ui-version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${beanvalidation-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>${cxf-version}</version>
<scope>test</scope>
</dependency>
-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/the-den-apis/the-den-api.yaml</inputSpec>
<language>jaxrs-cxf</language>
<modelPackage>omitted.model</modelPackage>
<apiPackage>omitted.api</apiPackage>
<generateApis>true</generateApis>
<generateApiTests>true</generateApiTests>
<generateApiDocumentation>true</generateApiDocumentation>
<generateModels>true</generateModels>
<generateModelTests>true</generateModelTests>
<generateModelDocumentation>true</generateModelDocumentation>
<generateSupportingFiles>true</generateSupportingFiles> <!-- Generate these e.g. pom.xml but then manually compare -->
<configOptions>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
<useSwaggerUI>true</useSwaggerUI>
<useBeanValidation>true</useBeanValidation>
<useBeanValidationFeature>true</useBeanValidationFeature>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/swagger/src/gen</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Force clean to ensure generated-sources regenerate each time -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- For integration tests -->
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.6</version>
<!-- Trying (and failing) to eliminate embedded Jetty warnings about scanning jars from multiple locations -->
<configuration>
<useManifestOnlyJar>false</useManifestOnlyJar>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- For unit tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
<!-- For integration tests -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-version}</version>
<configuration>
<webApp>
<contextPath>/</contextPath>
</webApp>
<webAppConfig>
<allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>
</webAppConfig>
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
<stopPort>8079</stopPort>
<stopKey>stopit</stopKey>
<httpConnector>
<port>8080</port>
<idleTimeout>60000</idleTimeout>
</httpConnector>
<daemon>true</daemon>
<scanClassesPattern>
<excludes>
<!-- Don't scan jars from local Maven repository. Works for mvn install -->
<exclude>**/.m2/**</exclude>
</excludes>
</scanClassesPattern>
<scanTestClassesPattern>
<excludes>
<!-- Don't scan jars from local Maven repository. Works for mvn install -->
<exclude>**/.m2/**</exclude>
</excludes>
</scanTestClassesPattern>
<scanTargetPatterns>
<scanTargetPattern>
<directory>${settings.localRepository}</directory>
<excludes>
<exclude>**/**</exclude>
</excludes>
</scanTargetPattern>
</scanTargetPatterns>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<scanClassesPattern>
<excludes>
<!-- Don't scan jars from local Maven repository -->
<exclude>**/.m2/**</exclude>
</excludes>
</scanClassesPattern>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Build war file -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment