首页 > 其他 > 详细

maven parent pom

时间:2014-10-20 11:44:49      阅读:233      评论:0      收藏:0      [点我收藏+]
parent pom:全局定义项目模型,子pom继承父pom的配置

主要配置:
           定义项目基本信息:比如license
<licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

 定义公司统一仓库位置:比如jardeploy位置
    <!-- 发布位置配置 -->
    <distributionManagement>
        <repository>
            <id>nexus-releases</id>
            <name>Internal Release Repository</name>
            <url>http://nexus.xxx.com/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus-snapshots</id>
            <name>Internal Snapshot Repository</name>
        </snapshotRepository>
    </distributionManagement>


定义全局插件:比如built方式
<plugins>
            <plugin>
                <inherited>true</inherited>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <optimize>true</optimize>
                    <debug>true</debug>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <!-- 发布源代码jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1.2</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>deploy</phase>
                    </execution>
                </executions>
            </plugin>

            <!-- 发布javadoc -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.8.1</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

统一管理jar版本:子项目在引入jar时不需要加入version 和scope属性:例如
<!--管理jar包版本-->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.peaceful</groupId>
                <artifactId>nuggets-peaceful-utils</artifactId>
                <version>1.0-SNAPSHOT</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

          
定义公司统一jar包依赖:这样所有通过配置parent的项目都可以把下面jar依赖到自己项目里,例如
             <dependencies>
       <!--  JUNIT DEPENDENCY FOR TESTING -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

总结parent pom主要是用来全局描述项目模型

maven parent pom

原文:http://blog.csdn.net/wangjuntytl/article/details/40297871

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!