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

Maven打tar包

时间:2015-06-04 13:57:54      阅读:631      评论:0      收藏:0      [点我收藏+]

标签:

根目录下创建assembly.xml

<assembly>
    <id>1.0.0.1</id>
    <formats>
        <!-- zip,tar,tar.gz,tar.bz2,jar,dir,war -->
        <format>tar</format>
    </formats>
    <dependencySets>
        <dependencySet>
            <outputDirectory>/lib</outputDirectory>
        </dependencySet>
    </dependencySets>
    <!-- 需要打包的文件集 -->
    <fileSets>
        <fileSet>
            <directory>src/main/scripts</directory>
            <outputDirectory>../</outputDirectory>
        </fileSet>
        <fileSet>
            <directory>${project.build.directory}</directory>
            <outputDirectory>../</outputDirectory>
            <includes>
                <include>ssoProvider.jar</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>

在pom文件下:

<build>
    <finalName>ssoProvider</finalName>
    <sourceDirectory>src/main/java</sourceDirectory>
   <resources>
 <!--     控制资源文件的拷贝-->
        <resource>
            <directory>src/main/resources</directory>
        </resource>
       <resource>
            <directory>src/main/scripts</directory>
            <targetPath>${project.build.directory}/scripts</targetPath>
        </resource>
    </resources>
    <plugins>
        <!-- 设置源文件编码方式 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib/</classpathPrefix>
                        <mainClass>com.heli.sso.Main</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <!-- 解决资源文件的编码问题 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <!-- 打包source文件为jar文件 -->
        <plugin>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <attach>true</attach>
            </configuration>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <descriptors>
                    <descriptor>assembly.xml</descriptor>
                </descriptors>
            </configuration>
            <executions>
                <!-- 当执行mvn package时才会打包 -->
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>


Maven打tar包

标签:

原文地址:http://my.oschina.net/u/1792430/blog/424692

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