0

I'm trying to merge openwebbeans.properties files which are appeared in 2 of the dependencies(openwebbeans-impl, openejb-core) in one of my OSGi bundle using the shades plugin. I follow the shades doc on My configuration is as follows 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>

But when I try mvn clean install it fails with following error

[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] ------------------------------------------------------------------------

Could someone tell me is there any errors in my configuration? What is the correct way to do this?

Edited

According to the answer provided by struberg it seems that my attempt is not applicable for the openwebebans context. But still I'm wonder what is the correct way of merging properties file. Or how to fix this issue.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • My guess: the shade plugin is called before the packaging plugin. The best way to solve this is to mention both plugins in the ``-section, where you first mention the packaging-plugin, followed by shade-plugin. Maven will evaluate them top-down when plugins are bound to the same phase. – Robert Scholte May 20 '15 at 10:27
  • @RobertScholte it is the last plugin in the pom. I even change the order and put it first. But no luck – Thusitha Thilina Dayaratne May 20 '15 at 11:08

1 Answers1

1

The tricky part is that we have a 'configuration.ordinal' property in each file. This defines in which order the information gets 'merged'. Higher ordinal values will get applied later on top of lower ordinal configuration. Thus the config settings from a higher ordinal config will stick.

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

struberg
  • 730
  • 5
  • 12
  • That article explain it really nice. So I think though my question is still valid it is not applicable in the openwebbeans context. Thanks a lot for the link. I UPVOTED the answer :) And I have edited the question as well. – Thusitha Thilina Dayaratne May 22 '15 at 16:13
  • 1
    It might be possible to create an own shade transformer and use PropertyLoader.getProperties(..) and write the result to a new file? – struberg May 22 '15 at 16:22