Maven Copy Dependencies

31 views
Skip to first unread message

Soham Ghosh

unread,
Jul 29, 2013, 6:44:56 AM7/29/13
to motec...@googlegroups.com
Hi Pawel,

We came across a strange behaviour in the Maven's copy dependencies task. Details below.

  1. Maven 3 deploys all snapshot versions with timestamps appended. For example there is no event-0.21-SNAPSHOT.jar (on nexus) but instead event-0.21-<timestamp>.jar. Every time a new snapshot is deployed a new jar with a new snapshot is deployed. Say, nexus has the following event module bundle: event-0.21-<timestamp-1>.jar.
  2. I deleted .m2 and .motech and installed a test module (outside platform) that depends on event 0.21 snapshot. What I observed is that event-0.21-<timestamp-1>.jar is copied to .m2. Also, a event-0.21-SNAPSHOT.jar is created in .m2 and the SNAPSHOT jar is same as event-0.21-<timestamp-1>.jar but renamed to SNAPSHOT jar. The SNAPSHOT jar was also copied to .motech/bundles by the copy-dependencies plugin.
  3. I deleted SNAPSHOT jar from .m2 and .motech. Run the deploy task, so now nexus have event-0.21-<timestamp-1>.jar and event-0.21-<timestamp-2>.jar, the latter being the latest. I then installed the test module with -U option. I observed that .m2 now contains event-0.21-<timestamp-1>.jar, event-0.21-<timestamp-2>.jar and event-0.21-SNAPSHOT.jar which is same as event-0.21-<timestamp-2>.jar but renamed. The SNAPSHOT jar was copied to .motech/bundles also.
Summary: mvn install renames the latest snapshot jar (identified by the timestamp) and renames it to SNAPSHOT.jar in .m2. Maven's copy dependencies copies that SNAPSHOT.jar to .motech/bundles.

When I executed the above steps for a platform module that depends on event, say scheduler, I observed the same behaviour for .m2 folder but .motech/bundles didn't have the event-0.21-SNAPSHOT.jar but event-0.21-<timestamp-N>.jar. I created a dummy module in the platform modules and observed the same behaviour.

Summary: If we run platform modules that depends on event event-0.21-<timestamp-N>.jar is copied to .motech/bundles. But if we run a module outside platform that depends on event event-0.21-SNAPSHOT.jar is copied to .motech/bundles.

(Note: I just took event as an example. It is true for any SNAPSHOT dependency)

Hence, often one may find both event-0.21-<timestamp-N>.jar and event-0.21-SNAPSHOT.jar in .motech/bundles. Both these bundles would have the same bundle symbolic name and version. This would not allow the server to startup. The work around would be to delete the duplicate bundles manually.

I have been trying to find out the issue but haven't had any luck yet. Let me know if you have any idea what is causing the problem.


-- Soham

Soham Ghosh

unread,
Jul 29, 2013, 7:59:04 AM7/29/13
to motec...@googlegroups.com
Observed that the following plugin causes the problem - maven-dependency-plugin. If that plugin is present maven copies the timestamped dependency (event-<timestamp>.jar) to .motech/bundle, whereas if the plugin is not there maven copies event-SNAPSHOT.jar to .motech/bundle.

-- Soham

Soham Ghosh

unread,
Jul 29, 2013, 8:07:55 AM7/29/13
to motec...@googlegroups.com
Correction: There are 2 maven-dependency-plugin, one to list dependencies, other copy dependencies. If both are present (which is the case in our platform code), maven copies the timestamped dependency (event-<timestamp>.jar) to .motech/bundle. Whereas if the plugin (list-dependencies) is not there maven copies event-SNAPSHOT.jar to .motech/bundle.

-- Soham

Paweł Gesek

unread,
Jul 29, 2013, 8:17:58 AM7/29/13
to motec...@googlegroups.com
Seems like aberrant behavior, I doubt that listing dependencies should impact resolution. Perhaps we should report this?

-- Paweł
--
You received this message because you are subscribed to the Google Groups "MoTeCH Developer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to motech-dev+...@googlegroups.com.
To post to this group, send email to motec...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/motech-dev/CADpU9EwkJXe-%3DXNXR3X8TXjbu8-ab_k8bez8EGr0eP2-ts4%3DkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Soham Ghosh

unread,
Jul 29, 2013, 8:19:22 AM7/29/13
to motec...@googlegroups.com
Yes looks like a bug. Trying to debug a bit more. 

-- Soham


Soham Ghosh

unread,
Aug 1, 2013, 1:05:16 AM8/1/13
to motec...@googlegroups.com, motech_care
Seems my observations were not completely correct. Created bug - https://trello.com/c/RgBoG3fB

-- Soham


---------- Forwarded message ----------
From: Ashok Kumar S <ash...@thoughtworks.com>
Date: Tue, Jul 30, 2013 at 1:50 PM
Subject: Re: Maven Copy Dependencies
To: Prakash Subramaniam <pr...@thoughtworks.com>
Cc: Soham Ghosh <soh...@thoughtworks.com>


Hi Prakash

The bundle which I was using is commcare-provider-sync: "g...@github.com:motech/commcare-provider-sync.git".
There is only one pom file. PFA the same.

On Tue, Jul 30, 2013 at 12:19 PM, Prakash Subramaniam <pr...@thoughtworks.com> wrote:
Ashok,

Can you please send us all your project pom files? Also, your project codebase url.


Regards,
Prakash



On Tue, Jul 30, 2013 at 12:02 PM, Ashok Kumar S <ash...@thoughtworks.com> wrote:
Hi Soham

One of our modules has maven dependencies plugin with both "list-dependencies" and "copy-dependecies" executions. But it still copies "event-0.21-SNAPSHOT.jar" and not "event-0.21-<timestamp>.jar". From pom.xml:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>list-dependencies</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>resolve</goal>
                        </goals>
                        <configuration>
                            <outputFile>target/dependencies.list</outputFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-osgi-dependencies</id>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeScope>compile</includeScope>
                            <overWriteIfNewer>true</overWriteIfNewer>
                            <outputDirectory>
                                ${user.home}/.motech/bundles
                            </outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

I tried installing this bundle after clearing .m2 repository and .motech directory. Just as a blind guess, tried changing the order of execution, but still it copies "*SNAPSHOT.jar" and not "*<timestamp>.jar".

Thanks
Ashok Kumar S

On Tue, Jul 30, 2013 at 11:48 AM, Prakash Subramaniam <pr...@thoughtworks.com> wrote:


pom.xml

Ashok Kumar S

unread,
Aug 5, 2013, 4:49:37 AM8/5/13
to Soham Ghosh, motec...@googlegroups.com, motech_care
Hi

It would be good if this bug is resolved on high priority. Otherwise, we have to build the entire platform everytime, instead of building only the modules which we need.

Thanks
Ashok Kumar S

Soham Ghosh

unread,
Aug 5, 2013, 8:59:15 AM8/5/13
to Ashok Kumar S, motec...@googlegroups.com, motech_care
From the logs it appears that maven-dependency-plugin version 2.5.1 is causing the problem, whereas version 2.1 is not causing any problem. I would upgrade the version of maven-dependency-plugin to the latest one in platform code and test further.

-- Soham

Soham Ghosh

unread,
Aug 6, 2013, 5:24:08 AM8/6/13
to Ashok Kumar S, motec...@googlegroups.com, motech_care
The fix is in the review queue. Please see the Trello card for the comments.

-- Soham
Reply all
Reply to author
Forward
0 new messages