使用Apache阴影插件合并.properties文件

时间:2015-05-20 09:58:08

标签: maven maven-shade-plugin

我尝试使用阴影插件合并我的一个OSGi包中的2个依赖项(openwebbeans-impl,openejb-core)中出现的openwebbeans.properties文件。 我按照阴影文档进行操作 我的配置如下https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#AppendingTransformer

   <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 clean install时失败并出现以下错误

[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上下文。但我仍然想知道合并属性文件的正确方法是什么。或者如何解决这个问题。

1 个答案:

答案 0 :(得分:1)

棘手的部分是我们有一个&#39; configuration.ordinal&#39;每个文件中的属性。这定义了信息以何种顺序合并&#39;。较高的序数值将在较低的序数配置之后应用。因此,来自更高序数配置的配置设置将会坚持。

https://struberg.wordpress.com/2010/09/21/flexible-configuration-for-modular-systems/

了解详情