views:

29

answers:

1

There is an article in the Eclipse wiki how to configure user's p2 default repositories of an RCP application by adding a static conf file to your product:

Equinox/p2/Adding Self-Update to an RCP Application - Configuring the user's default repositories

I want to do the same programmatically in a Java class when the user changes some configuration details. I could not find appropriate p2 API documentation for that.

A: 

I found a solution. It's easy - unfortunately there is no documentation...

    // from bundle org.eclipse.equinox.p2.console
    import org.eclipse.equinox.internal.p2.console.ProvisioningHelper;

    URI repoUri = new URI(UPDATE_SITE_URL);
    try {
        ProvisioningHelper.addMetadataRepository(repoUri);         
    } catch( Exception e ) {
        LOG.warn("Can not add update repository: " + repoUri);           
    }
    try {
        ProvisioningHelper.addArtifactRepository(repoUri);          
    } catch( Exception e ) {
        LOG.warn("Can not add update repository: " + repoUri);
    }
Daniel Murygin