lvjian700
10/10/2012 - 2:51 AM

Using Maven create java web app with jetty plugin

Using Maven create java web app with jetty plugin

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>lv.site.wb</groupId>
  <artifactId>wb</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>wb Maven Webapp</name>
  <url>http://maven.apache.org</url>
  
  
	<properties>
		<junit.version>4.7</junit.version>
		
		<nexus.url>192.168.1.6:8081</nexus.url>
		
	</properties>
	<profiles>
		<profile>
			<id>strict</id>
			<properties>
				<maven.test.failure.ignore>false</maven.test.failure.ignore>
			</properties>
		</profile>
	</profiles>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
  		<finalName>wb</finalName>
  		<pluginManagement>
  			<plugins>
  				<plugin>
  					<groupId>com.springsource.bundlor</groupId>
  					<artifactId>com.springsource.bundlor.maven</artifactId>
  					<version>1.0.0.M1B</version>
  				</plugin>
  				<plugin>
  					<artifactId>maven-assembly-plugin</artifactId>
  					<inherited>false</inherited>
  					<configuration>
  						<descriptorRefs>
  							<descriptorRef>project</descriptorRef>
  						</descriptorRefs>
  					</configuration>
                  </plugin>
  			</plugins>
  		</pluginManagement>
  		<plugins>
  			<plugin>
  				<groupId>org.apache.maven.plugins</groupId>
  				<artifactId>maven-compiler-plugin</artifactId>
  				<configuration>
  					<source>1.6</source>
  					<target>1.6</target>
  					<encoding>utf-8</encoding>
  				</configuration>
  			</plugin>
			
			
  			<plugin>
  				<groupId>org.apache.maven.plugins</groupId>
  				<artifactId>maven-surefire-plugin</artifactId>
  				<configuration>
  					<!--forkMode>pertest</forkMode-->
  					<includes>
  						<include>**/*Test.java</include>
  					</includes>
  					<excludes>
  						<exclude>**/EnvironmentTest.java</exclude>
  						<exclude>**/Abstract*.java</exclude>
  					</excludes>
  				</configuration>
  			</plugin>
  			<plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-surefire-plugin</artifactId>
                  <configuration>
                      <skip>true</skip>
                  </configuration>
                  <executions>
                      <execution>
                          <id>surefire-it</id>
                          <phase>integration-test</phase>
                          <goals>
                              <goal>test</goal>
                          </goals>
                          <configuration>
                              <skip>false</skip>
                          </configuration>
                      </execution>
                  </executions>
              </plugin>
            
              <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-deploy-plugin</artifactId>
                  <configuration>
                      <skip>true</skip>
                  </configuration>
              </plugin>
            
              <!-- jetty plugin -->
              <plugin>
                  <groupId>org.mortbay.jetty</groupId>
                  <artifactId>maven-jetty-plugin</artifactId>
                  <version>6.1.15</version>
                  <configuration>
                      <!-- By default the artifactId is taken, override it with something simple -->
                      <contextPath>/</contextPath>
                      <scanIntervalSeconds>2</scanIntervalSeconds>
                      <stopKey>foo</stopKey>
                      <stopPort>9999</stopPort>
                      <connectors>
                          <connector
                                  implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                              <port>9095</port>
                              <maxIdleTime>60000</maxIdleTime>
                          </connector>
                      </connectors>
                  </configuration>
                  <executions>
                      <execution>
                          <id>start-jetty</id>
                          <phase>pre-integration-test</phase>
                          <goals>
                              <goal>run</goal>
                          </goals>
                          <configuration>
                              <scanIntervalSeconds>0</scanIntervalSeconds>
                              <daemon>true</daemon>
                          </configuration>
                      </execution>
                      <execution>
                          <id>stop-jetty</id>
                          <phase>post-integration-test</phase>
                          <goals>
                              <goal>stop</goal>
                          </goals>
                      </execution>
                  </executions>
              </plugin>
            
  		</plugins>
  	</build>
  <repositories>
		
  		<repository>
              <id>java.net</id>
              <url>http://download.java.net/maven/1/</url>
              <layout>legacy</layout>
          </repository>
          <repository>
              <id>maven repo</id>
              <name>maven repo</name>
              <url>http://repo1.maven.org/maven2/</url>
          </repository>
          <repository>
              <id>jboss</id>
              <name>jboss repo</name>
              <url>http://repository.jboss.org/nexus/content/groups/public/</url>
          </repository>
      </repositories>
	
  	<pluginRepositories>
  		<pluginRepository>
  			<id>Codehaus</id>
  			<url>http://repository.codehaus.org/</url>
  			<snapshots>
  				<enabled>false</enabled>
  			</snapshots>
  		</pluginRepository>
  	</pluginRepositories>
	
  	<distributionManagement>
          <repository>
              <id>nexus-releases</id>
              <name>Nexus Release Repository</name>
              <url>http://${nexus.url}/nexus/content/repositories/releases/</url>  
          </repository>
          <snapshotRepository>
              <id>nexus-snapshots</id>
              <name>Nexus Snapshot Repository</name>
              <url>http://${nexus.url}/nexus/content/repositories/snapshots/</url>  
          </snapshotRepository>
      </distributionManagement>
</project>
mvn archetype:create -DgroupId=lv.site.wb -DartifactId=wb -DarchetypeArtifactId=maven-archetype-webapp