3

In Eclipse, I have a libs project. This project has a test.jar file.

I have 15 other projects in eclipse that use test.jar under Java Build Path/Libraries.

New versions of test.jar are made every month, and the name will change (test1.jar, test2.jar)

Once a new version is available, I remove the old one from the libs project and add the new one. My question is, how can I modify the 15 projects that use this jar file to reference the new one? I know how to do it one project at a time by configuring the build path for each project. Is there a way to make a mass change to all 15 projects at the same time?

TestRaptor
  • 1,305
  • 8
  • 24
  • 42

3 Answers3

4

To achieve the same follow the steps below.

  1. Open Eclipse, go to Windows > Preferences-> Java > Build Path -> User Library
  2. Now click on new button and give name like TEST_JAR and add after that just add the jar it could be test.jar or test.jar. see the below screen shot.

  1. Only one time task delete the entry from all 15 project from its build classpath as its set in global path.

  2. Whenever you will be build other project it will also bundle you User libraries.

Lii
  • 11,553
  • 8
  • 64
  • 88
prashant thakre
  • 5,061
  • 3
  • 26
  • 39
  • There is several disadvantages with this solution, because the dependency information is not longer stored in the projects: 1) Other people who import the projects into their Eclipse workspace must manually update this setting. 2) ALL projects in your workspace will have access to the jar dependency, not only the 15 projects that need it. – Lii Oct 11 '18 at 10:10
1

Or, you could just save all your new versions in a folder somewhere, copy and paste the latest version to the desired build path location, and change the name of said pasted jar to testcurr.jar. Then, change all the build paths to use testcurr.jar.

Now all you have to do when you have a new version is to save it somewhere, and copy/paste it with the name of testcurr.jar. Voila! All projects are using the same jar, the same time, and you never have to update the build paths again.

Aify
  • 3,543
  • 3
  • 24
  • 43
  • No he doesn't - He still has all the jars with version numbers somewhere in another place, and can refer to that when he needs to figure out what version he's using (just look for the newest one). However, this solution simplifies the build path problem into nothingness where all he has to do is replace one file with a newer version with the same name. – Aify Apr 01 '15 at 16:16
1

Eclipse maintains classpath in a simple file called .classpath in root directory. A global find-and-replace with regex can change all test(X).jar into test(X+1).jar

Community
  • 1
  • 1
KrishPrabakar
  • 2,824
  • 2
  • 31
  • 44