2015-01-10 48 views
0

我正在用Maven碰到一个奇怪的边缘用例&好奇它为什么表现得如此。Maven插件依赖不能使用父pom属性

我定义的属性在我父项目像这样:

<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:example:jar must be一个有效的版本,但是'$ {some.p roperty.version}”。 @ line 350,第16列

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

+0

第二个想法是,这可能是邮件列表中的最佳服务......稍后将通过来自Maven人员的反馈进行更新! – gordysc

回答

0

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

Hi,

This makes me wonder if the "right" parent is used, so please double check the groupId, artifactId and version. If both parent and module are part of the same multi-module, be sure that the relativePath is correct (defaults to ../pom.xml) You could also use "mvn org.apache.maven.plugins:maven-help-plugin:2.2:effective-pom" to verify that the property is really there with the expected value. If this is all as expected, then it seems to be a bug.

thanks, Robert

+1

thnx荣誉 –

+0

@RobertScholte将插件中的依赖关系由父项管理,我们可以在没有版本的情况下指定它,因为我们为项目依赖项指定它。 ch.qos.logback的''build.plugins.plugin [com.mysema.querydsl:querydsl-maven-plugin] .dependencies.dependency.version'时,插件依赖项未被解析:logback-classic:jar丢失。 @第95行,第18列' –

+0

在Maven开始构建之前,所有使用的插件必须完全解析。所以你不能使用项目依赖作为插件依赖,他们只是有不同的目的。 –