0

Typical problem - I have x-1.0.jar, x-2.0.jar and y-1.0.jar. I want to use x-2.0.jar and y-1.0.jar but y-1.0.jar depends on x-1.0.jar.

There is a tool out there which allows you to bundle up dependencies into a single JAR and change the package names internally so it avoids conflict. For example, if "x" contains software in the package "com.foo", then it can change all classes in x-1.0.jar to be in package "old.com.foo", as well as any references in y-1.0.jar, so we could make a new JAR xy-1.0.jar; this JAR would not contain any publicly-exposed classes in the "com.foo" packages, so that we could feel free to use it alongside x-2.0.jar with no conflict.

The problem is, I have totally forgotten what the name of that tool is! We considered using it once in my company, but my management were concerned about doing binary-level modifications to classes. However now (several years later) we have a similar problem which only affects test code, so I want to propose it again. But I have totally forgotten the name!

Things I remember about it:

  • Open source hosted on Google Code
  • Based on ObjectWeb ASM underneath
  • I think the name may have been a pun of some description

Does anyone know what tool this might be? Please help me out!

Adam Burley
  • 5,551
  • 4
  • 51
  • 72
  • 1
    https://maven.apache.org/plugins/maven-shade-plugin/ – Jesper May 01 '15 at 13:10
  • @Jesper thanks, that looks really useful! I love Maven! – Adam Burley May 01 '15 at 13:16
  • @ChetanKinger I don't think it's the same as the one you have marked as a duplicate. That one is just about changing package names, whereas mine is specifically about resolving dependency hell. Also, "Hand Edit A Jar to Change Package Names" is not a question. – Adam Burley May 01 '15 at 13:18
  • @Kidburla Your question is titled `How do I change the package name of classes inside a JAR`. The answer you gave to your own question is `JarJar Links`. I fail to understand how a question that asks the same thing and has the exact same answer as another question on the site is not a duplicate? We can't have a new question just because the wordings and contents of an existing question don't live up to ones expectation. – Chetan Kinger May 01 '15 at 13:35
  • @ChetanKinger I don't think it asks the same thing. The "title" is a short title of the post, not the whole post itself. I could have titled my question "How do I re-package dependencies within a JAR so that classes only used by other dependencies do not cause a classpath conflict with later versions required by my application?" However this title is a bit too long to be a best-practice title on SO. Inevitably when you shorten titles, you will have two similar (and even identical, although not here) titles which are actually asking different things. – Adam Burley May 01 '15 at 15:06
  • @Kidburla This is what you said. `if "x" contains software in the package "com.foo", then it can change all classes in x-1.0.jar to be in package "old.com.foo", as well as any references in y-1.0.jar, so we could make a new JAR xy-1.0.jar`. I could be wrong but this seems to be the crux of your question.There is an answer in the proposed duplicate that says `Its primary use case is to embed external jars in your own jar, and to do that, it can re-name existing packages`. Can you explain how the linked question does not answer your question and how it's not a duplicate? – Chetan Kinger May 01 '15 at 15:31
  • @ChetanKinger, just because an answer item contains an answer to a different question doesn't mean that that different question is included in the question to which that answer relates. If I ask "Where can I buy apples?" and someone answers "You can buy them at Walmart, oh by the way you can also buy oranges there" - does that mean someone else can't come along later and ask "Where can I buy oranges?" without it being marked as a duplicate question? – Adam Burley May 01 '15 at 15:37
  • This is a programming site so let's stick to programming questions. If someone asks how to store a Set in a Map and someone else asks how to store a List in a Map, the questions can be marked as a duplicate because the process is exactly the same. If you want to add value, you could edit the question title and change it it `How to add a collection to a Map` and post your answer instead of creating a self wiki. I guess your question has been marked as a duplicate already so any further discussion on this would not be adding value to the site. – Chetan Kinger May 01 '15 at 15:44
  • I tried to think of a programming example but I couldn't come up with one, which is why I put a non-programming one. If the example you gave is truly an example of a duplicate question then I accept that my question is also a duplicate. Your last comment seems quite harshly worded so I just wanted to say that there are no hard feelings :) – Adam Burley May 01 '15 at 15:49

1 Answers1

1

I remembered it! The tool is called JarJar Links.

Adam Burley
  • 5,551
  • 4
  • 51
  • 72
  • 1
    Wow, it took you milliseconds to remember. Had you searched the site, you would not have the need to post the question in the first place. – Chetan Kinger May 01 '15 at 13:10
  • @ChetanKinger Just as I finished the question, I remembered the answer, so I ticked the "share your knowledge, Q&A style" checkbox. – Adam Burley May 01 '15 at 13:14
  • Nevertheless, it's a duplicate and you should have searched the site instead of creating a self wiki. It's the first answer that comes up when you Google "change package name in jar". Your post adds no value. – Chetan Kinger May 01 '15 at 13:15
  • @ChetanKinger I did search the site...that was the first thing I did. – Adam Burley May 01 '15 at 13:19
  • What was your search query? Just curious. Don't get me wrong. – Chetan Kinger May 01 '15 at 13:21
  • @ChetanKinger I searched Google for "rename binary jar packages" and didn't find any relevant results. – Adam Burley May 01 '15 at 13:22
  • I guess that's where the problem is then. The search string `rename binary jar packages` would mostly translate to renaming a jar file. – Chetan Kinger May 01 '15 at 13:36