码迷,mamicode.com
首页 > 其他好文 > 详细

Maven打包

时间:2015-11-16 10:57:12      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:


项目文件结构

技术分享

pom.xml


<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>com.test</groupId>
	<artifactId>port</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>port</name>
	<url>http://maven.apache.org</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
	</properties>

	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>
		
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
			<version>3.3.2</version>
		</dependency>
				
	</dependencies>

	<build>
		<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>
					<showDeprecation>true</showDeprecation>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-assembly-plugin</artifactId>
				<version>2.5.4</version>
				<executions>
					<execution>
						<goals>
							<goal>attached</goal>
						</goals>
						<phase>package</phase>
						<configuration>
							<finalName>port</finalName>
							<descriptorRefs>
								<descriptorRef>jar-with-dependencies</descriptorRef>
							</descriptorRefs>
							<archive>
								<manifest>
									<mainClass>com.test.port.Launcher</mainClass>
								</manifest>
							</archive>
						</configuration>
					</execution>
					<execution>
						<id>make-assembly</id>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<finalName>port-${maven.build.timestamp}</finalName>
							<appendAssemblyId>false</appendAssemblyId>
							<descriptors>
		                        <descriptor>assembly.xml</descriptor>
		                    </descriptors>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>



assembly.xml

<assembly
	xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
	
	<id>zip</id>
	<formats>
		<format>zip</format>
	</formats>
	<fileSets>
		<fileSet>
			<directory>${basedir}/bin</directory>
			<outputDirectory>/</outputDirectory>
			<includes>
				<include>**/*</include>
			</includes>
		</fileSet>
		<fileSet>
			<directory>${basedir}/target</directory>
			<outputDirectory>/</outputDirectory>
			<includes>
				<include>*-jar-with-dependencies.jar</include>
			</includes>
		</fileSet>
	</fileSets>
</assembly>



target文件夹路径下,输出打包文件

port-yyyy-MM-dd.zip

    |-- Furla.xlsx  // bin目录下文件

    |-- Instrument.txt // bin目录下文件

    \-- port-jar-with-dependencies.jar



Maven打包

标签:

原文地址:http://my.oschina.net/dexterman/blog/530690

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!