Now that EclipseCon Europe is nearing, I decided to do some preparations. As most years some time will be spent on hacking, and this year is no exception especially with regards to the Science Working Group coding session at the Unconference.
These days many Eclipse based projects use Maven and Tycho for building. All my hobby projects are also using this technology. It’s quite nice, but a common problem is having to download artifacts when the network is bad or unavailable. From experience this happens a lot at EclipseCon Europe so I’m planning to avoid it. You can resolve this altogether by setting up a local artifact manager such as Nexus. Nexus supports both Maven and p2 repositories so if you have one of those you won’t need these instructions. I’ve set up Archiva on my NAS and rely on the local cache when the network is unavailable. However this only supports Maven artifacts and when building Eclipse based applications one also need the various dependencies. I’ve resolved this by creating local mirrors of the p2 repositories I often use, and instructed Maven to utilize these.
First you need a running HTTP daemon such as Apache on your system. I’m on OS X so I’m all set – just had to enable user directories after updating to Yosemite. Next you have to create the mirrors. This is done by calling the Eclipse mirror application. Once for the metadata and again for the artifacts. Replace path to eclipse and destination as appropriate.
Eclipse/eclipse -nosplash -verbose -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication -source http://download.eclipse.org/releases/luna/ -destination file:////Users/torkild/Sites/mirrors/eclipse-luna Eclipse/eclipse -nosplash -verbose -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication -source http://download.eclipse.org/releases/luna/ -destination file:////Users/torkild/Sites/mirrors/eclipse-luna
If you’re on OS X and has upgraded to Eclipse 4.5 the patch to the eclipse executable is different: Eclipse.app/Contents/MacOS/eclipse
Be prepared to wait quite a while for the last one to finish. If you want to speed it up you should try to find a faster mirror of the p2 repository. I repeated the process for SWTBot. Next I altered ~/.m2/settings.xml so it looks like this:
archiva.internal http://192.168.1.10:8080/repository/internal external:* local-luna eclipse-luna Local Mirror of Eclipse Luna p2 repository. http://localhost/~torkild/mirrors/eclipse-luna/ p2 p2 local-swtbot eclipse-swtbot-2.2.1 Local Mirror of Eclipse SWTBot p2 repository. http://localhost/~torkild/mirrors/eclipse.swtbot-2.2.1 p2 p2
Once again, adjust the URL to suit your needs. Next it’s just a matter of making sure that the repositories referenced in the *.pom files match the mirrors. Just make sure that the identifiers are the same as the mirrorOf attribute in the configuration file or the mirrors will not be used.
eclipse-luna p2 http://download.eclipse.org/releases/luna eclipse-swtbot-2.2.1 p2 http://download.eclipse.org/technology/swtbot/releases/2.2.1/
That’s it. Happy coding!
Regarding the webserver topic on windows I can recommend mongoose: http://cesanta.com/mongoose.shtml – free, small and simple to setup
Great Post!
Is there a difference between using p2 application and downloading a zipped repo archive, extracting that and serving with a webserver from the extracted location?
Otherwise great tip!
No, there’s no difference (that I’m aware of). But the entire Luna or Mars p2-repository is not published as a single download. So the ~5.5GB must be mirrored.