use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.Repository in project tycho by eclipse.
the class RepositoryReferenceTool method getVisibleRepositories.
/**
* Returns the list of visible p2 repositories for the build of the current module. The list
* includes the p2 repositories of the referenced reactor modules, the target platform, and
* optionally the current module itself. The repositories are sorted in a reasonable order of
* precedence, so if there should be duplicate installable units or artifacts, the hope is that
* it is deterministic from which repository the unit or artifact is taken. The order is:
* <ol>
* <li>The publisher results of the current module (only if the flag
* {@link #REPOSITORIES_INCLUDE_CURRENT_MODULE} is set),
* <li>The results of the referenced reactor modules,
* <li>The non-reactor content of the module's target platform.
* </ol>
*
* @param module
* The current Maven project
* @param session
* The current Maven session
* @param flags
* Options flags; supported flags are {@link #REPOSITORIES_INCLUDE_CURRENT_MODULE}
* @return a {@link RepositoryReferences} instance with the repositories.
* @throws MojoExecutionException
* in case of internal errors
* @throws MojoFailureException
* in case required artifacts are missing
*/
public RepositoryReferences getVisibleRepositories(MavenProject module, MavenSession session, int flags) throws MojoExecutionException, MojoFailureException {
RepositoryReferences repositories = new RepositoryReferences();
if ((flags & REPOSITORIES_INCLUDE_CURRENT_MODULE) != 0) {
File publisherResults = new File(module.getBuild().getDirectory());
repositories.addMetadataRepository(publisherResults);
repositories.addArtifactRepository(publisherResults);
}
repositories.addArtifactRepository(RepositoryBlackboardKey.forResolutionContextArtifacts(module.getBasedir()));
// metadata and artifacts of target platform
addTargetPlatformRepository(repositories, session, module);
repositories.addArtifactRepository(new File(session.getLocalRepository().getBasedir()));
return repositories;
}
use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.Repository 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);
}
use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.Repository 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);
}
use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.Repository in project tycho by eclipse.
the class UpdateLocalIndexMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
LocalRepositoryP2Indices localRepoIndices = serviceFactory.getService(LocalRepositoryP2Indices.class);
GAV gav = new GAV(project.getGroupId(), project.getArtifactId(), project.getArtifact().getVersion());
TychoRepositoryIndex artifactsIndex = localRepoIndices.getArtifactsIndex();
TychoRepositoryIndex metadataIndex = localRepoIndices.getMetadataIndex();
try {
addGavAndSave(gav, artifactsIndex);
addGavAndSave(gav, metadataIndex);
} catch (IOException e) {
throw new MojoExecutionException("Could not update local repository index", e);
}
}
use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.Repository in project tycho by eclipse.
the class ModuleMetadataRepository method load.
private void load() throws ProvisionException {
try {
MetadataIO io = new MetadataIO();
FileInputStream is = new FileInputStream(storage);
units.addAll(io.readXML(is));
} catch (IOException e) {
String message = "I/O error while reading repository from " + storage;
int code = ProvisionException.REPOSITORY_FAILED_READ;
Status status = new Status(IStatus.ERROR, BUNDLE_ID, code, message, e);
throw new ProvisionException(status);
}
}
Aggregations