2015-01-10 46 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開始構建之前,所有使用的插件必須完全解析。所以你不能使用項目依賴作爲插件依賴,他們只是有不同的目的。 –