Re: Setting jar order in maven.compile.classpath
A work-around for this problem which I've previously mentioned is roughly: 1. Figure out which classes are the problem 2. Figure out which jars contain those classes 3. Figure out which version of those classes you want to keep 4. Extract and re-jar the others problem jars minus the offending classes 5. Distribute those updated jars to the rest of your team via Corporate Repo or similar This is perhaps not ideal but it does allow you to get past the problem. If your problem jars are being supplied by a vendor, complain to them and perhaps they will adopt a better policy regarding their Jars. If your problem jars are being supplied by another dev team in your organization, you should be able to get them to change the way they do things or at least provide you with proper bundles that won't give you problems like this. Wayne On 7/26/07, jaxzin [EMAIL PROTECTED] wrote: Thanks Manos, What I've found so far by looking at the source is that its dependent on how the Set that MavenProject.getArtifacts() orders itself. I still haven't found which impl of Set is used. That would tell us how predictable the order is. My guess is its a HashSet and so the order will be determined by the hashCode of the the Artifact object. Brian Manos Batsis wrote: Come on guys let us not give too much attention to eachother :-) I dont think Maven's behaviour regarding the order of JARs in the classpath is random; that would be impossible. My guess is the order is predictable and based on the dependencies configuration and the algorithm that goes over it. Something like 1) Scan explicit deps 2) (Recursive?) Either 2.A) For each one add it's deps and move to the next depth level OR 2.B) Add each one, then process the next depth level of deps 3) Remove the overridden versions This is pretty rough but you get the point. My bet is you will always get the same classpath in a project whose POM does not change. This of course may not provide an easy solution to the OPs prob, but the code is OS after all so anyone is free to modify it as needed and post patches in the JIRA or whatever :-) Cheers, Manos - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Setting-jar-order-in-maven.compile.classpath-tf4111876s177.html#a11811974 Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Setting jar order in maven.compile.classpath
Thanks Manos, What I've found so far by looking at the source is that its dependent on how the Set that MavenProject.getArtifacts() orders itself. I still haven't found which impl of Set is used. That would tell us how predictable the order is. My guess is its a HashSet and so the order will be determined by the hashCode of the the Artifact object. Brian Manos Batsis wrote: Come on guys let us not give too much attention to eachother :-) I dont think Maven's behaviour regarding the order of JARs in the classpath is random; that would be impossible. My guess is the order is predictable and based on the dependencies configuration and the algorithm that goes over it. Something like 1) Scan explicit deps 2) (Recursive?) Either 2.A) For each one add it's deps and move to the next depth level OR 2.B) Add each one, then process the next depth level of deps 3) Remove the overridden versions This is pretty rough but you get the point. My bet is you will always get the same classpath in a project whose POM does not change. This of course may not provide an easy solution to the OPs prob, but the code is OS after all so anyone is free to modify it as needed and post patches in the JIRA or whatever :-) Cheers, Manos - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Setting-jar-order-in-maven.compile.classpath-tf4111876s177.html#a11811974 Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Setting jar order in maven.compile.classpath
Come on guys let us not give too much attention to eachother :-) I dont think Maven's behaviour regarding the order of JARs in the classpath is random; that would be impossible. My guess is the order is predictable and based on the dependencies configuration and the algorithm that goes over it. Something like 1) Scan explicit deps 2) (Recursive?) Either 2.A) For each one add it's deps and move to the next depth level OR 2.B) Add each one, then process the next depth level of deps 3) Remove the overridden versions This is pretty rough but you get the point. My bet is you will always get the same classpath in a project whose POM does not change. This of course may not provide an easy solution to the OPs prob, but the code is OS after all so anyone is free to modify it as needed and post patches in the JIRA or whatever :-) Cheers, Manos - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Setting jar order in maven.compile.classpath
My bad. I didn't realize that a predictable classpath order vs. random classpath order would shake the Maven project to the core of its very being and betray the very objectives it has set out to achieve. But on a more serious note, I've been using Maven for years and don't plan to stop anytime soon. I'm in the process of moving ESPN to using Maven and I'm encountering issues like these which I'll need to work through. Answers like yours are condescending and unhelpful for people looking for help instead of ridicule. Wayne, ya gotta lighten up a little, please? Wayne Fay wrote: I can only refer you to the What Is Maven page [1]: Maven does encourage best practices, but we realise that some projects may not fit with these ideals for historical reasons. While Maven is designed to be flexible, to an extent, in these situations and to the needs of different projects, it can not cater to every situation without making compromises to the integrity of its objectives. If you decide to use Maven, and have an unusual build structure that you cannot reorganise, you may have to forgo some features or the use of Maven altogether. Good news -- no one (on this list, at least) is forcing you to use Maven! And its open source, so if you need this feature, you can go in and add it yourself. [1] http://maven.apache.org/what-is-maven.html Wayne On 7/25/07, jaxzin [EMAIL PROTECTED] wrote: That's such a cop-out. I've got legacy jars that my project depends on that happen to have some overlap in the classes. What's so wrong with AT LEAST obeying the declared order of the dependencies in the POM instead of the random order that currently exists? Wayne Fay wrote: You can't. Set the order of jars means you're duplicating code, which is generally a bad idea. Eliminate the duplication (make one depend on the other). Wayne On 7/19/07, Roger Huang (rchuang) [EMAIL PROTECTED] wrote: How can I specify the order of jars in maven.compile.classpath? I have two jars generated as part of my build that I need to explicitly set the order of in maven.compile.classpath. thanks, Roger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Setting-jar-order-in-maven.compile.classpath-tf4111876s177.html#a11800428 Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Setting-jar-order-in-maven.compile.classpath-tf4111876s177.html#a11811553 Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Setting jar order in maven.compile.classpath
That's such a cop-out. I've got legacy jars that my project depends on that happen to have some overlap in the classes. What's so wrong with AT LEAST obeying the declared order of the dependencies in the POM instead of the random order that currently exists? Wayne Fay wrote: You can't. Set the order of jars means you're duplicating code, which is generally a bad idea. Eliminate the duplication (make one depend on the other). Wayne On 7/19/07, Roger Huang (rchuang) [EMAIL PROTECTED] wrote: How can I specify the order of jars in maven.compile.classpath? I have two jars generated as part of my build that I need to explicitly set the order of in maven.compile.classpath. thanks, Roger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Setting-jar-order-in-maven.compile.classpath-tf4111876s177.html#a11800428 Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Setting jar order in maven.compile.classpath
I can only refer you to the What Is Maven page [1]: Maven does encourage best practices, but we realise that some projects may not fit with these ideals for historical reasons. While Maven is designed to be flexible, to an extent, in these situations and to the needs of different projects, it can not cater to every situation without making compromises to the integrity of its objectives. If you decide to use Maven, and have an unusual build structure that you cannot reorganise, you may have to forgo some features or the use of Maven altogether. Good news -- no one (on this list, at least) is forcing you to use Maven! And its open source, so if you need this feature, you can go in and add it yourself. [1] http://maven.apache.org/what-is-maven.html Wayne On 7/25/07, jaxzin [EMAIL PROTECTED] wrote: That's such a cop-out. I've got legacy jars that my project depends on that happen to have some overlap in the classes. What's so wrong with AT LEAST obeying the declared order of the dependencies in the POM instead of the random order that currently exists? Wayne Fay wrote: You can't. Set the order of jars means you're duplicating code, which is generally a bad idea. Eliminate the duplication (make one depend on the other). Wayne On 7/19/07, Roger Huang (rchuang) [EMAIL PROTECTED] wrote: How can I specify the order of jars in maven.compile.classpath? I have two jars generated as part of my build that I need to explicitly set the order of in maven.compile.classpath. thanks, Roger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Setting-jar-order-in-maven.compile.classpath-tf4111876s177.html#a11800428 Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Setting jar order in maven.compile.classpath
How can I specify the order of jars in maven.compile.classpath? I have two jars generated as part of my build that I need to explicitly set the order of in maven.compile.classpath. thanks, Roger
Re: Setting jar order in maven.compile.classpath
You can't. Set the order of jars means you're duplicating code, which is generally a bad idea. Eliminate the duplication (make one depend on the other). Wayne On 7/19/07, Roger Huang (rchuang) [EMAIL PROTECTED] wrote: How can I specify the order of jars in maven.compile.classpath? I have two jars generated as part of my build that I need to explicitly set the order of in maven.compile.classpath. thanks, Roger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]