Search code examples
eclipseupdate-site

Automatic redirect for Eclipse Update Site from old URL to new URL


I have an Update Site with has some users, e.g. www.foo.com/oldupdatesite. I want to release new versions of the Update Site at a new location. For instance, the new location could be www.bar.com/newupdatesite. It would be optimal if I could push new releases only at the new location and existing users of the old Update Site will still get the new stuff without re-configuration.

For web browsers it is well known that one can redirect to another address using HTML or JS, e.g. as explained here.

I wonder if a similar mechanism exists for Eclipse Update Sites. Is it possible to create a dummy Update Site such that the "Install New Software..." dialog in Eclipse will go to the new Update Site instead?


Solution

  • You can use a composite repository with a single child repository pointing to the new location.

    The p2 touchpoint actions addRepository and removeRepository can be used to update the Window > Preferences: Install/Update > Available Software Sites preferences on install/update of a feature/product.

    EDIT

    After trying out the Composite Repository feature linked above, I found that putting the following XML files in the old Update Site location is sufficient to redirect to the new Update Site. Actually, for me it also worked with either file. However, I guess it does not harm to create both files.

    compositeContent.xml

    <?xml version='1.0' encoding='UTF-8'?>
    <?compositeMetadataRepository version='1.0.0'?>
    <repository name='"Open Editors Eclipse Plugin Update Site Redirect"'
        type='org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository'
        version='1.0.0'>
      <children size='1'>
        <child location='https://bar.com/newupdatesite'/>
      </children>
    </repository>
    

    compositeArtifacts.xml

    <?xml version='1.0' encoding='UTF-8'?>
    <?compositeArtifactRepository version='1.0.0'?>
    <repository name='"Open Editors Eclipse Plugin Update Site Redirect"'
        type='org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository'
        version='1.0.0'>
      <children size='1'>
        <child location='https://bar.com/newupdatesite'/>
      </children>
    </repository>