Search in sources :

Example 16 with Repository

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.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;
}
Also used : RepositoryReferences(org.eclipse.tycho.p2.tools.RepositoryReferences) File(java.io.File)

Example 17 with Repository

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.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);
}
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 18 with Repository

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.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);
}
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 19 with Repository

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.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);
    }
}
Also used : LocalRepositoryP2Indices(org.eclipse.tycho.p2.repository.LocalRepositoryP2Indices) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) TychoRepositoryIndex(org.eclipse.tycho.p2.repository.TychoRepositoryIndex) IOException(java.io.IOException) GAV(org.eclipse.tycho.p2.repository.GAV)

Example 20 with Repository

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.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);
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) MetadataIO(org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Aggregations

File (java.io.File)11 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)10 IOException (java.io.IOException)5 URI (java.net.URI)5 ArrayList (java.util.ArrayList)5 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)5 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)5 FacadeException (org.eclipse.tycho.p2.tools.FacadeException)5 Test (org.junit.Test)5 GAV (org.eclipse.tycho.p2.repository.GAV)4 TychoRepositoryIndex (org.eclipse.tycho.p2.repository.TychoRepositoryIndex)4 TargetDefinition (org.eclipse.tycho.p2.target.facade.TargetDefinition)4 FileInputStream (java.io.FileInputStream)3 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)3 MavenRepositoryLocation (org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation)3 DestinationRepositoryDescriptor (org.eclipse.tycho.p2.tools.DestinationRepositoryDescriptor)3 RepositoryReferences (org.eclipse.tycho.p2.tools.RepositoryReferences)3 InputStream (java.io.InputStream)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2