为pom依赖设置project.version

时间:2012-09-19 14:59:08

标签: maven

我需要设置project.version的值。对${project.version}的引用将位于其依赖关系管理部分中的一个依赖项的pom中。换句话说,依赖项org.apache.gora:gora-core:0.2.1已参数化其依赖项的版本。只是我将gora-core包含为一个简单的依赖项并没有设置project.version,因此我的构建中没有包含这些间接依赖项。

maven文档没有多大帮助。

1 个答案:

答案 0 :(得分:1)

适用于Maven 3.0.4

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>a</groupId>
  <artifactId>b</artifactId>
  <version>1-SNAPSHOT</version>
  <dependencies>
    <dependency>
      <groupId>org.apache.gora</groupId>
      <artifactId>gora-core</artifactId>
      <version>0.2.1</version>
    </dependency>
  </dependencies>
</project>

当我问Maven时,它的依赖性是什么:

$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building b 1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ b ---
[INFO] a:b:jar:1-SNAPSHOT
[INFO] \- org.apache.gora:gora-core:jar:0.2.1:compile
[INFO]    +- org.apache.hadoop:hadoop-core:jar:1.0.1:compile
[INFO]    |  +- commons-cli:commons-cli:jar:1.2:compile
[INFO]    |  +- xmlenc:xmlenc:jar:0.52:compile
[INFO]    |  +- commons-httpclient:commons-httpclient:jar:3.0.1:compile
[INFO]    |  |  +- junit:junit:jar:3.8.1:compile
[INFO]    |  |  \- commons-logging:commons-logging:jar:1.0.3:compile
[INFO]    |  +- commons-codec:commons-codec:jar:1.4:compile
[INFO]    |  +- org.apache.commons:commons-math:jar:2.1:compile
[INFO]    |  +- commons-configuration:commons-configuration:jar:1.6:compile
[INFO]    |  |  +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO]    |  |  +- commons-digester:commons-digester:jar:1.8:compile
[INFO]    |  |  |  \- commons-beanutils:commons-beanutils:jar:1.7.0:compile
[INFO]    |  |  \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
[INFO]    |  +- commons-net:commons-net:jar:1.4.1:compile
[INFO]    |  +- org.mortbay.jetty:jetty:jar:6.1.26:compile
[INFO]    |  |  \- org.mortbay.jetty:servlet-api:jar:2.5-20081211:compile
[INFO]    |  +- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
[INFO]    |  +- tomcat:jasper-runtime:jar:5.5.12:compile
[INFO]    |  +- tomcat:jasper-compiler:jar:5.5.12:compile
[INFO]    |  +- org.mortbay.jetty:jsp-api-2.1:jar:6.1.14:compile
[INFO]    |  |  \- org.mortbay.jetty:servlet-api-2.5:jar:6.1.14:compile
[INFO]    |  +- org.mortbay.jetty:jsp-2.1:jar:6.1.14:compile
[INFO]    |  |  \- ant:ant:jar:1.6.5:compile
[INFO]    |  +- commons-el:commons-el:jar:1.0:compile
[INFO]    |  +- net.sf.kosmosfs:kfs:jar:0.3:compile
[INFO]    |  \- oro:oro:jar:2.0.8:compile
[INFO]    +- org.apache.cxf:cxf-rt-frontend-jaxrs:jar:2.5.2:compile
[INFO]    |  +- org.apache.cxf:cxf-common-utilities:jar:2.5.2:compile
[INFO]    |  |  +- org.apache.ws.xmlschema:xmlschema-core:jar:2.0.1:compile
[INFO]    |  |  \- org.codehaus.woodstox:woodstox-core-asl:jar:4.1.1:runtime
[INFO]    |  |     \- org.codehaus.woodstox:stax2-api:jar:3.1.1:runtime
[INFO]    |  +- org.apache.cxf:cxf-api:jar:2.5.2:compile
[INFO]    |  |  +- org.apache.neethi:neethi:jar:3.0.1:compile
[INFO]    |  |  \- wsdl4j:wsdl4j:jar:1.6.2:compile
[INFO]    |  +- org.apache.cxf:cxf-rt-core:jar:2.5.2:compile
[INFO]    |  |  +- com.sun.xml.bind:jaxb-impl:jar:2.1.13:compile
[INFO]    |  |  \- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:compile
[INFO]    |  +- org.springframework:spring-core:jar:3.0.6.RELEASE:compile
[INFO]    |  |  \- org.springframework:spring-asm:jar:3.0.6.RELEASE:compile
[INFO]    |  +- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO]    |  +- org.apache.cxf:cxf-rt-bindings-xml:jar:2.5.2:compile
[INFO]    |  +- org.apache.cxf:cxf-rt-transports-http:jar:2.5.2:compile
[INFO]    |  |  +- org.apache.cxf:cxf-rt-transports-common:jar:2.5.2:compile
[INFO]    |  |  \- org.springframework:spring-web:jar:3.0.6.RELEASE:compile
[INFO]    |  |     +- aopalliance:aopalliance:jar:1.0:compile
[INFO]    |  |     +- org.springframework:spring-beans:jar:3.0.6.RELEASE:compile
[INFO]    |  |     \- org.springframework:spring-context:jar:3.0.6.RELEASE:compile
[INFO]    |  |        +- org.springframework:spring-aop:jar:3.0.6.RELEASE:compile
[INFO]    |  |        \- org.springframework:spring-expression:jar:3.0.6.RELEASE:compile
[INFO]    |  \- org.codehaus.jettison:jettison:jar:1.3.1:compile
[INFO]    +- org.apache.hadoop:avro:jar:1.3.3:compile
[INFO]    |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.4.2:compile
[INFO]    |  |  \- org.codehaus.jackson:jackson-core-asl:jar:1.4.2:compile
[INFO]    |  +- org.slf4j:slf4j-api:jar:1.5.11:compile
[INFO]    |  +- com.thoughtworks.paranamer:paranamer:jar:2.2:compile
[INFO]    |  \- com.thoughtworks.paranamer:paranamer-ant:jar:2.2:compile
[INFO]    |     +- com.thoughtworks.paranamer:paranamer-generator:jar:2.2:compile
[INFO]    |     |  +- com.thoughtworks.qdox:qdox:jar:1.10.1:compile
[INFO]    |     |  \- asm:asm:jar:3.2:compile
[INFO]    |     \- org.apache.ant:ant:jar:1.7.1:compile
[INFO]    |        \- org.apache.ant:ant-launcher:jar:1.7.1:compile
[INFO]    +- commons-lang:commons-lang:jar:2.6:compile
[INFO]    \- log4j:log4j:jar:1.2.16:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.301s
[INFO] Finished at: Wed Sep 19 19:10:04 IST 2012
[INFO] Final Memory: 8M/81M
[INFO] ------------------------------------------------------------------------

所有被拉得很好