Sunday, December 19, 2010

Mirroring an Eclipse Update Site to a Local p2 Repository

Installing or updating Eclipse plugins/features is easy using Eclipse p2 Update Sites. However, since it requires downloading from the Internet the process is often very slow.

Some projects provide an archived update site (.zip file) but the rest do not provide them. When installing or updating features for multiple Eclipse IDE or RCP Application installations, downloading the same files multiple times from the Internet can get annoying. Not to mention it definitely wastes precious time AND bandwidth.

Thankfully there is a way to create a local p2 repository that acts as a mirror site to the original Eclipse p2 Update Sites.

This is useful for making available a full Eclipse release or a set of Eclipse features/plugins to internal corporate users, for example, reducing the bandwidth normally used with dozens of users downloading the same bits from external Eclipse p2 Update sites.

Documentation


First, you need to mirror the site (or a particular feature), so take a look at the mirror command described here:
Running Update Manager from Command Line

then create a site policy (a type of redirection) as described here:
Controlling the Eclipse Update Policy

Command Examples


You can start the update manager in a standalone mode to create a mirror of an update site by using
this command:

java -Dhttp.proxyHost=yourProxy -Dhttp.proxyPort=yourProxyPort \
  -jar plugins/org.eclipse.equinox.launcher_<version>.jar \
  -application org.eclipse.update.core.standaloneUpdate -command mirror \
  -from %updateSiteToMirror% -mirrorUrl %urlOfYourUpdateSite% \
  -to %fileLocationToMirrorTo%

Run this command from Eclipse install directory (i.e. where startup.jar is).
Replace %fileLocationToMirrorTo% with the local directory where the update site contents will be copied to, and %urlOfYourUpdateSite% with a URL which will point to the directory you informed.

Of course you will need to install a local web server, like Apache HTTPD and configure it according the directory/URL you specified before.

It even supports to create one mirror-site of multiple sites if you specify the same location for multiple sites it will append them to the site.xml giving you one big (and messy) update site.

An easy way to use this is use a dos or bash scipt ofcourse. For example the following script to mirror the relevant update sites:

set LAUNCHER=C:\opt\springsource-2.1\sts-2.1.0.RELEASE\plugins/plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar

call updateSite http://subclipse.tigris.org/update_1.6.x subclipse
call updateSite http://pmd.sourceforge.net/eclipse pmd
call updateSite http://m2eclipse.sonatype.org/update/ m2eclipse
call updateSite http://findbugs.cs.umd.edu/eclipse/  findbugs
call updateSite http://moreunit.sourceforge.net/org.moreunit.updatesite/  moreunit
call updateSite http://www.springsource.com/update/e3.5 sprinsource-e35
call updateSite http://eclipse-cs.sf.net/update checkstyle
call updateSite http://update.atlassian.com/atlassian-eclipse-plugin atlassian
call updateSite http://commonclipse.sourceforge.net commonclipse
call updateSite https://ajax.dev.java.net/eclipse glassfish
call updateSite http://andrei.gmxhome.de/eclipse/ gmx-plugins
call updateSite http://regex-util.sourceforge.net/update/ regex
call updateSite http://ucdetector.sourceforge.net/update/ ucdetector

goto:eof

:updateSite
java -Dhttp.proxyHost=yourProxy -Dhttp.proxyPort=yourProxyPort -jar %LAUNCHER% -application org.eclipse.update.core.standaloneUpdate -command mirror -from %1 -mirrorUrl http://server/eclipseupdatesite/%2 -to Y:\%2 &goto:eof
goto:eof
This gives us multiple update sites under http://server/eclipseupdatesite/ like http://server/eclipseupdatesite/m2eclipse etc. Of course you still need 1 computer to have unrestricted/fast internet access, but you can always create those sites at home.

Aggregating Specific Features

You can also aggregate several features from other update sites to your own, using either p2.mirror, p2 Composite Repositories, b3, or Nexus Pro.

See http://stackoverflow.com/questions/4378112/p2-repositories-aggregator


Sources:

  1. http://dev.eclipse.org/newslists/news.eclipse.platform/msg29529.html
  2. http://stackoverflow.com/questions/4378112/p2-repositories-aggregator
  3. http://www.willianmitsuda.com/2007/03/09/mirroring-callisto-update-site/
  4. http://www.denoo.info/2009/09/mirroring-eclipse-update-sites/

No comments:

Post a Comment