or... if you REALLY want to cheat the system (yes, this is terrible, but we do have a certain use case for it). We put some jar files inside a zip file so that we could make the zip a dependency and it wouldn't be added to the classpath of the application. These jars are used by an ant process to interpolate variables on the target host to match values expected for the environment (port and IP for example).
I am also morally obligated to warn you that including both versions is hazardous to your health. You can't exactly specify the order in which they are resolved on the classpath -- and so you never know which class definition will really be resolved first. If this is to resolve an issue where a dependency of yours needs a newer version, but you use an older version -- I would say that you either have to use a version of the dependency that uses that older version, or you need to update your code to handle the newer version. It's pretty dangerous to just stick both versions in and cross your fingers. Disclaimer aside, here is what we do: <dependency> <groupId>com.companyname</groupId> <artifactId>antdeploymentjars</artifactId> <version>01</version> <type>zip</type> </dependency> <dependencySet> <includes> <include>com.companyname:antdeploymentjars:zip:01</include> </includes> <outputDirectory>deployment/Ant</outputDirectory> <unpack>true</unpack> </dependencySet> -----Original Message----- From: Stephen Connolly [mailto:stephen.alan.conno...@gmail.com] Sent: Friday, February 17, 2012 2:28 AM To: Maven Users List Subject: Re: Copy two versions of same jar Alternatively, if you just need a copy of the jar, and not the jar on the classpath, ie you are writing some app that builds its own classpath, some parts of the app use one version and other parts use the other version, and you have fancy code that sets up the class loaders correctly, this would be an ideal illustration of why dependency:copy can be needed sometimes (ie dependency:copy-dependencies does not fit this use-case) Though IMHO I would rather wrap the code that needs the older version in a separate jar that uses maven-shade-plugin to remove the need for class loader trickery, if you have your own plugin framework, that might not be tractable... Having said all that, 99% chance is that none of the above apply to your case, and you are just fighting maven because you think you can win... Well you won't win. On Friday, 17 February 2012, Wayne Fay <wayne...@gmail.com> wrote: >> <dependencies> >> <dependency> >> <groupId>test</groupId> >> <artifactId>castor</artifactId> >> <version>0.9.5</version> >> </dependency> >> <dependency> >> <groupId>test</groupId> >> <artifactId>castor</artifactId> >> <version>1.0.4</version> >> </dependency> >> </dependencies> > ... >> But this copies only one version and it ignores the other one.. >> Please provide a solution for copying both the versions. > > Why do you want to do this? As you've already discovered, Maven will > generally "collapse" two such dependencies into a single element and > pick one version over the other. > > If you have any ability to control the GA coordinates or to add a C > (classifier) to one of the artifacts, you should do so as that would > be the easiest possible solution. Then Maven would consider them as > "different" and you could bring in both versions very easily. > > Wayne > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org