Downloading Eclipse plug-in update sites for offline installation

Viewed 91362

A plug-in that I want to install provides an update site for installation. However, the Eclipse installation that I want to install it to is on a machine that is not connected to the Internet. Is there a way for me to access the site (HTTP, FTP, etc.) to download the files in it for offline installation?

8 Answers

Eclipse offers a way of mirroring these sites automatically, either through the command line or through ant tasks.

Mirror based on p2 information

$eclipse_home/eclipse -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication -source $1 -destination $2
$eclipse_home/eclipse -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication -source $1 -destination $2

Reference: Equinox p2 repository mirroring

Mirror based on site.xml information

java -jar $eclipse_home/plugins/org.eclipse.equinox.launcher_*.jar -application org.eclipse.update.core.standaloneUpdate -command mirror -from $from -to $to

Reference: Running the update manager from the command line

You can follow the evolution of these scripts in my script repository.

Eclipse plugins usually depend on other plugins. It's kind of hard to trace the dependencies. It's better to download all dependencies using update site once, and you can distribute to other Eclipse dropins. For Eclipse 3.4 or newer, you can use dropins which is an Eclipse feature. This way you don’t have to install plugin from update site every time you have to re-install your Eclipse. Read on http://michsan.web.id/content/how-install-eclipse-plugins-offline

If you can't see the web, I'll give you some description

Prepare directory for external plugins

Create special directory to hold our beloved plugins, e.g. in /home/ichsan/eclipse-dropins we will install Maven plugin: m2eclipse.

mkdir /home/ichsan/eclipse-dropins

For now on, we'll call this directory as DROPINS

Preparing sandbox

Next, by using Git we'll create an Eclipse sandbox. The point is to install one plugin on a fresh Eclipse. Instead of installing fresh Eclipse every time we want to install a new plugin, we'd better use Git to create new branch of fresh Eclipse.

First, extract/install new Eclipse to a directory e.g. /home/ichsan/eclipse-sandbox (so that we'll find /home/ichsan/eclipse-sandbox/eclipse.ini). We call the directory as ECLIPSE_SANDBOX.

Next, commit the fresh installation. This step should be done once only.

cd $ECLIPSE_SANDBOX
git init
git add .
git commit -am "Fresh Eclipse"

Install plugin on sandbox

Now is the interesting part. Supposed we have to install m2eclipse plugin. We will install this on new Git branch so that the master branch will stay clean or stay intact.

cd $ECLIPSE_SANDBOX
git checkout -b "m2eclipse"

Now, we start the Eclipse of the ECLIPSE_SANDBOX and download the plugin. Once we're done, we shut the Eclipse down and check what new directories or files have been created (using Git). Remember that, we only care about new plugins and features directories and the contents inside them. So, we won't copy the rest into dropins.

# Prepare the m2eclipse plugin directories
mkdir -p $DROPINS/m2eclipse/eclipse/plugins
mkdir -p $DROPINS/m2eclipse/eclipse/features

cd $ECLIPSE_SANDBOX
for f in $(git status | sed "s/#\t//g" | grep -P "^plugins" ); do cp -R $f $DROPINS/m2eclipse/eclipse/plugins; done
for f in $(git status | sed "s/#\t//g" | grep -P "^features"); do cp -R $f $DROPINS/m2eclipse/eclipse/features; done

# Make the directory read only
chmod -R -w $DROPINS/m2eclipse

# Commit changes
git add .
git add -u
git commit -am "M2Eclipse plugin installed"


# Back to master branch to make Eclipse clean again and ready for other plugin installations
git checkout master
Installing the plugin

Just copy the directory of DROPINS/m2eclipse into ECLIPSE_HOME/dropins or create a symbolic link. And we're done!

cd $ECLIPSE_HOME/dropins ln -s $DROPINS/m2eclipse

Another way is to backup differences between fresh-Eclipse commit and after-plugin-installation commit.

for i in `git diff hashFreshEclipse hashPluginInstall --name-only`;do 
  if [ -f $i ]; then
    tar -r -f m2e-android.tar $i
  fi
done
gzip m2e-android.tar

I just faced this issue and resolved it by following the instructions from this guide. In summary, run the following commands on your terminal in Eclipse folder:

  1. eclipsec.exe -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication -source $1 -destination $2

  2. eclipsec.exe -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication -source $1 -destination $2

Where $1 refers to the URL to the online repository and $2 refers to the path to the local folder. E.g. to download Vrapper on my Windows Desktop:

$1 = http://vrapper.sourceforge.net/update-site/stable/

$2 = C:/Users/foo/Desktop

Transfer the folder to the machine without Internet connection. Then, launch Eclipse -> Help > Install new software. Specify the local repository (i.e. the folder that you've just transferred) for the installation. That should work.

Related