当前位置:编程学习 > html/css >>

一些常用的Maven Plugin配置

Maven是一个常用的Java build Manager, 使用Maven可以很好的对Java Project的dependency进行管理. 这里我记录几个比较常用的Plugin配置. 
 
生成JAR打包文件:
[html] 
<plugin>  
                <groupId>org.apache.maven.plugins</groupId>  
                <artifactId>maven-jar-plugin</artifactId>  
                <configuration>  
                    <archive>  
                        <manifestEntries>  
                            <Class-Path>.</Class-Path>  
                        </manifestEntries>  
                    </archive>  
                    <excludes>  
                        <exclude>*.xml</exclude>  
                    </excludes>  
                </configuration>  
            </plugin>  
 
 
这个打包文件将不会把一般的XML配置文件也打包, 这样, 我们可以在不修改JAR文件的情况下对配置文件进行修改.
拷贝XML配置文件:
[html]  
<plugin>  
                <artifactId>maven-resources-plugin</artifactId>  
                <executions>  
                    <execution>  
                        <id>copy-resources</id>  
                        <phase>package</phase>  
                        <goals>  
                            <goal>copy-resources</goal>  
                        </goals>  
                        <configuration>  
                            <outputDirectory>target</outputDirectory>  
                            <resources>  
                                <resource>  
                                    <directory>src/main/resources</directory>  
                                    <filtering>true</filtering>  
                                </resource>  
                            </resources>  
                        </configuration>  
                    </execution>  
                </executions>  
            </plugin>  
这个plugin配置将把在src/main/resources文件夹下的配置文件都拷贝到target文件夹. 这种文件夹配置是IntelliJ下的默认配制.
拷贝所有的Dependency JARs:
[html]  
<plugin>  
                <groupId>org.apache.maven.plugins</groupId>  
                <artifactId>maven-dependency-plugin</artifactId>  
                <executions>  
                    <execution>  
                        <id>copy-dependencies</id>  
                        <phase>package</phase>  
                        <goals>  
                            <goal>copy-dependencies</goal>  
                        </goals>  
                        <configuration>  
                            <outputDirectory>target/libs</outputDirectory>  
                            <overWriteReleases>false</overWriteReleases>  
                            <overWriteSnapshots>false</overWriteSnapshots>  
                            <overWriteIfNewer>true</overWriteIfNewer>  
                        </configuration>  
                    </execution>  
                </executions>  
            </plugin>  
这个plugin将拷贝所有的Dependency JARs到target/libs文件夹下, 这样只要添加这个目录到classpath下, 我们就可以在没有IDE的环境的情况下直接运行我们的程序. 
生成运行文件:
[html]  
<plugin>  
                <groupId>org.apache.maven.plugins</groupId>  
                <artifactId>maven-antrun-plugin</artifactId>  
                <executions>  
                    <execution>  
                        <id>manifest&
补充:web前端 , HTML/CSS  ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,