I've noticed many projects put the org.jdt.core jar in a lib folder because it's not available in a maven repository. sbt, the build tool I'm using, can pull a dependency straight from a URL. However, I can't find any direct links to the jar on the eclipse downloads page. The closes I can find is a link to the entire jdt zip which includes many jar files. I don't believe sbt can extract a jar from a zip dependency. Is there a direct link, or some other workaround?
Depends whether the version you want is already in a repository or not.
For org.eclipse.jdt.core:
The tycho project seems to deploy some versions of org.eclipse.jdt.core
to central. See:
http://central.maven.org/maven2/org/eclipse/tycho/org.eclipse.jdt.core/
I found that using search.maven.org. One of those might be good enough for your needs. But they don't seem to have the 'official' binaries, just rebuilds of them.
(Note that there's also a maven.eclipse.org, which might be useful for some artifacts. But if doesn't seem to have anything to suit your particular problem.)
For the general case:
In general, though you can't find all the eclipse artifacts in maven repositories. So if you can't find what you want in a maven repo, you'll need to find it in the Eclipse p2 repositories yourself. Let's say you want the org.eclipse.jdt.core
for Eclipse 3.8.1…
The Eclipse Project Update Sites wiki page says the update site for 3.8.x is
http://download.eclipse.org/eclipse/updates/3.8
That's actually a 'composite' p2 repository for 3.8, 3.8.1, … So next we need to figure out the name of the 3.8.1 repository. The following fetches a jar file containing compositeArtifacts.xml
, which lists the child repositories, and greps for 3.8.1
:
curl -s http://download.eclipse.org/eclipse/updates/3.8/compositeArtifacts.jar | \
gunzip -c | \
grep '3\.8\.1'
The result?
<child location='R-3.8.1-201209141540'/>
That location is a relative path. It tells us the 3.8.1 repository is at
http://download.eclipse.org/eclipse/updates/3.8/R-3.8.1-201209141540/
Now to fetch the artifact index for that repository. Again, a single XML file in a jar. But this time, it's not a composite repository, so we just ask for artifacts.jar
:
curl -s http://download.eclipse.org/eclipse/updates/3.8/R-3.8.1-201209141540/artifacts.jar | \
gunzip -c | \
grep org.eclipse.jdt.core[\'\"] | \
sort -u
Result:
<artifact classifier='osgi.bundle' id='org.eclipse.jdt.core' version='3.8.2.v20120814-155456'>
(I'm not sure why org.eclipse.jdt.core
in 3.8.1 has a version beginning 3.8.2, but that's the way it is. Let's press on…)
So now we can stitch together the URL according to the <mappings>
element in the artifacts.xml we just fetched. Add 'plugins/' to the repository path; add the version to the plugin name, and then we can fetch it:
curl -Os http://download.eclipse.org/eclipse/updates/3.8/R-3.8.1-201209141540/plugins/org.eclipse.jdt.core_3.8.2.v20120814-155456.jar
If you find yourself needing more than just one or two jars, you might look into using Tycho, or the Eclipse p2 Ant tasks to resolve the artifacts you need into a lib folder before you run your sbt build.
© 2022 - 2024 — McMap. All rights reserved.