Maven插件依赖项不能使用父pom属性

时间:2015-01-10 09:44:00

标签: maven maven-3 maven-plugin

我正在使用Maven& amp;好奇为什么它的行为方式如此。

我在我的父项目中定义了一个属性,如下所示:

  <properties>
      <some.property.version>1.0.0.0</some.property.version>
  </properties>

现在,在一个模块中,我为插件设置了一个依赖版本,如下所示:

  <build>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>bob</artifactId>
              <version>1.0.0.0</version>
              <dependencies>
                  <dependency>
                      <groupId>org.example</groupId>
                      <artifactId>example</artifactId>
                      <version>${some.property.version}</artifactId>
                  </dependency>
              </dependencies>
          </plugin>
      </plugins>
  </build>

这会导致Maven吐出错误:

[错误]'build.plugins.plugin [org.apache.maven.plugins:bob] .dependencies.dependency.version'for org.example:示例:jar必须是有效版本,但是'$ {some。 property.version}”。 @第350行,第16栏

对我来说奇怪的是,如果我将被定义的属性移动到模块本身,Maven编译就好了。这是一个错误吗?或者对模块的插件中的父pom属性的可见性有限制吗?

1 个答案:

答案 0 :(得分:1)

来自Apache Maven的分发列表的快速响应!父pom已被重构,模块指向陈旧的父亲的artifactId。感谢罗伯特!

  

您好,

     

这让我想知道&#34;对&#34;使用父母,所以请加倍   检查groupId,artifactId和version。如果父和模块都有   是同一个多模块的一部分,请确保relativePath是   正确(默认为../pom.xml)您也可以使用&#34; mvn   org.apache.maven.plugins:行家的帮助-插件:2.2:有效-POM&#34;至   验证该属性是否确实存在预期值。如果   这一切都符合预期,那似乎是一个错误。

     

谢谢,罗伯特