POM

来源:互联网 发布:图像分水岭算法 编辑:程序博客网 时间:2024/05/21 03:25

依赖关系  
<project>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.0</version>
            <type>jar</type>
            <scope>test</scope>
            <optional>true</optional>
            <exclusions>
                <exclusion>
                    <groupId>*</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
</project>

依赖范围
compile(编译依赖范围)(默认的)
test(测试依赖范围)
provided(已提供依赖范围)
runtime(运行时依赖范围)
system(系统依赖范围)
import(导入依赖范围)
===================================================================================================================================
Inheritance   继承关系

哪些element会被继承下来?
groupId:项目 组ID,项目坐标的核心元素。-------------重要
version:项目版本,项目坐标的核心元素。-------------重要
description:项目的描述信息。
organization:项目的组织信息。
inceptionYear:项目的创建年份。
url:项目的URL地址。
developers:项目的开发者信息。
contributors:项目的贡献者信息。
distributionManagement:项目的发布,部署信息
issueManagement:项目的权限跟踪系统信息
ciManagement:项目的持续集成系统信息
scm:项目的版本控制系统信息
mailingLists:项目的邮件列表信息
properties:自定义的maven属性-------------重要
dependencies:项目的依赖配置-------------重要
dependencyManagement:项目的依赖管理配置。-------------重要
repositories:项目的仓库配置
build:包括项目的源码目录配置、输出目录配置、插件配置,插件管理配置-------------重要
reporting:包括项目的报告输出目录配置、报告插件配置等-------------重要

plugin lists
reports lists
plugin executions with matching ids
plugin configuration



举例
<project>
    <parent>
        <groupId></groupId>
        <artifactId></artifactId>
        <version></version>
        <relativePath></relativePath>
    </parent>
</project>

====================================================================================================================================
聚合关系


====================================================================================================================================
<build>...</build>   // 注意,这个build,即“project build”

声明project的目录结构,管理plugin
<build>
    <defaultGoal>install</defaultGoal>
    
</build>
====================================================================================================================================
<reporting>...</reporting>


====================================================================================================================================
<profiles>
    <profile>
        <id>test</test>
        <activation>...</activiation>
        <build>...</build>               //  注意,这里也有个build,即"profile build"
        <modules>...</modules>
        <repositiories>...</repositories>
        <pluginRepositories>...</pluginRepositories>
        <dependencies>...</dependencies>
        <reporting>...</reporting>
        <denpendencyManagement>...</denpendencyManagement>
        <distributionManagement>...</distributionManagement>
    </profile>
</profiles>


1. activation
   在某些场景下,使用这个profile。activation就是来描述场景的。
   <activation>
       <activeByDefault>false</activeByDefault>
       <jdk>1.5</jdk>
       <os>
           <name>Windows XP</name>
           <family>Windows</family>
           <arch>x86</arch>
           <version>5.1.2600</version>
       </os>
       <property>
           <name>sparrow-type</name>
           <value>African</value>
       </property>
       <file>
           <exists></exists>
       </file>
   </activation>
   
   
====================================================================================================================================
project下的properites  和  profile下的properties 中,可以定义property,例如
<project>
   <properties>
       <myProp>hello world</myProp>
   </properties>
</project>

maven 在构建时,会用“hello world”替换resource文件中出现${myProp}。


另一种方式:
  在profile中指出属性文件的路径(当然,不同的profile,代表不同的环境,可以指定不同的属性文件)
  然后在build的resource中,把这个路径也包括进来。
 
  这样不同环境下的属性文件,就以资源的形式被打包到生成物中了。
 
 
====================================================================================================================================

0 0
原创粉丝点击