Search in sources :

Example 1 with TargetDefinitionFile

use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile in project tycho by eclipse.

the class TargetDefinitionUtil method makeURLsAbsolute.

/**
 * Resolves relative URLs in the given target definition file, with the specified resource as
 * base URL.
 *
 * @param targetDefinitionFile
 *            The target definition file in which relative URLs shall be replaced.
 * @param base
 * @throws IOException
 */
public static void makeURLsAbsolute(File targetDefinitionFile, File relocationBasedir) throws IOException {
    TargetDefinitionFile platform = TargetDefinitionFile.read(targetDefinitionFile, null);
    List<? extends TargetDefinition.Location> locations = platform.getLocations();
    for (TargetDefinition.Location location : locations) {
        List<Repository> repositories = ((IULocation) location).getRepositoryImpls();
        for (Repository repository : repositories) {
            makeRepositoryElementAbsolute(repository, relocationBasedir);
        }
    }
    TargetDefinitionFile.write(platform, targetDefinitionFile);
}
Also used : TargetDefinitionFile(org.eclipse.tycho.p2.resolver.TargetDefinitionFile) Repository(org.eclipse.tycho.p2.resolver.TargetDefinitionFile.Repository) IULocation(org.eclipse.tycho.p2.resolver.TargetDefinitionFile.IULocation) TargetDefinition(org.eclipse.tycho.p2.target.facade.TargetDefinition)

Example 2 with TargetDefinitionFile

use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile in project tycho by eclipse.

the class TargetDefinitionUtil method setRepositoryURLs.

/**
 * Overwrites all repository URLs in the target file.
 */
public static void setRepositoryURLs(File targetDefinitionFile, String url) throws IOException {
    TargetDefinitionFile platform = TargetDefinitionFile.read(targetDefinitionFile, null);
    for (TargetDefinition.Location location : platform.getLocations()) {
        for (Repository repository : ((IULocation) location).getRepositoryImpls()) {
            repository.setLocation(url);
        }
    }
    TargetDefinitionFile.write(platform, targetDefinitionFile);
}
Also used : TargetDefinitionFile(org.eclipse.tycho.p2.resolver.TargetDefinitionFile) Repository(org.eclipse.tycho.p2.resolver.TargetDefinitionFile.Repository) IULocation(org.eclipse.tycho.p2.resolver.TargetDefinitionFile.IULocation) TargetDefinition(org.eclipse.tycho.p2.target.facade.TargetDefinition)

Aggregations

TargetDefinitionFile (org.eclipse.tycho.p2.resolver.TargetDefinitionFile)2 IULocation (org.eclipse.tycho.p2.resolver.TargetDefinitionFile.IULocation)2 Repository (org.eclipse.tycho.p2.resolver.TargetDefinitionFile.Repository)2 TargetDefinition (org.eclipse.tycho.p2.target.facade.TargetDefinition)2