2015-05-20 31 views
0

我想在使用遮罩插件的OSGi包之一中合併openwebbeans.properties文件,這些文件出現在2個依賴項(openwebbeans-impl,openejb-core)中。 我按照色調文檔上 我的配置如下:https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#AppendingTransformer使用Apache遮罩插件合併.properties文件

<plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-shade-plugin</artifactId> 
     <version>2.3</version> 
     <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>shade</goal> 
        </goals> 
        <configuration> 
         <transformers> 
          <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> 
            <resource>META-INF/openwebbeans/openwebbeans.properties</resource> 
          </transformer> 
         </transformers> 
        </configuration> 
       </execution> 
      </executions> 
    </plugin> 

但是當我嘗試MVN乾淨安裝失敗,以下錯誤

[INFO] --- maven-shade-plugin:2.3:shade (default) @ tomee --- 
[ERROR] The project main artifact does not exist. This could have the following 
[ERROR] reasons: 
[ERROR] - You have invoked the goal directly from the command line. This is not 
[ERROR] supported. Please add the goal to the default lifecycle via an 
[ERROR] <execution> element in your POM and use "mvn package" to have it run. 
[ERROR] - You have bound the goal to a lifecycle phase before "package". Please 
[ERROR] remove this binding from your POM such that the goal will be run in 
[ERROR] the proper phase. 
[ERROR] - You removed the configuration of the maven-jar-plugin that produces the main artifact. 
[INFO] ------------------------------------------------------------------------ 

有人能告訴我有什麼錯誤,在我組態? 這是做什麼的正確方法?

編輯

據struberg它提供的答案似乎是我的嘗試是不適用於openwebebans上下文。但是我仍然想知道合併屬性文件的正確方式是什麼。或者如何解決這個問題。

+0

我的猜測:陰影插件在打包插件之前調用。解決這個問題的最好方法是在''部分提及插件,在這裏你首先提到包裝插件,然後是陰影插件。當插件綁定到同一階段時,Maven會自上而下評估它們。 –

+0

@RobertScholte它是pom中的最後一個插件。我甚至改變了順序並把它放在第一位。但沒有運氣 –

回答

1

棘手的部分是我們在每個文件中都有一個'configuration.ordinal'屬性。這定義了信息以何種順序被「合併」。較高的序數值將稍後應用於較低的序號配置。因此,來自更高序號配置的配置設置將保持不變。

閱讀更多在https://struberg.wordpress.com/2010/09/21/flexible-configuration-for-modular-systems/

+0

那篇文章解釋它非常好。所以我認爲雖然我的問題仍然有效,但它不適用於openwebbeans環境。非常感謝鏈接。我UPVOTED答案:)我也編輯了這個問題。 –

+1

也許可以創建一個自己的陰影轉換器並使用PropertyLoader.getProperties(..)並將結果寫入新文件? – struberg

+0

這是一個很好的建議。 –