Search in sources :

Example 6 with RepositoryReferences

use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.

the class MirrorApplicationServiceImpl method createMirrorApplication.

private static MirrorApplication createMirrorApplication(RepositoryReferences sources, DestinationRepositoryDescriptor destination, IProvisioningAgent agent, boolean includePacked) {
    final MirrorApplication mirrorApp = new MirrorApplication(agent, includePacked);
    List<RepositoryDescriptor> sourceDescriptors = createSourceDescriptors(sources);
    for (RepositoryDescriptor sourceDescriptor : sourceDescriptors) {
        mirrorApp.addSource(sourceDescriptor);
    }
    mirrorApp.addDestination(createDestinationDescriptor(destination));
    return mirrorApp;
}
Also used : DestinationRepositoryDescriptor(org.eclipse.tycho.p2.tools.DestinationRepositoryDescriptor) RepositoryDescriptor(org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor)

Example 7 with RepositoryReferences

use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.

the class DirectorMojo method getBuildOutputRepository.

private RepositoryReferences getBuildOutputRepository() {
    // TODO share "repository" constant?
    File buildOutputRepository = getBuildDirectory().getChild("repository");
    RepositoryReferences result = new RepositoryReferences();
    result.addMetadataRepository(buildOutputRepository);
    result.addArtifactRepository(buildOutputRepository);
    return result;
}
Also used : RepositoryReferences(org.eclipse.tycho.p2.tools.RepositoryReferences) File(java.io.File)

Example 8 with RepositoryReferences

use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.

the class DirectorMojo method execute.

// TODO extract methods
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    List<Product> products = getProductConfig().getProducts();
    if (products.isEmpty()) {
        getLog().info("No product definitions found. Nothing to do.");
    }
    DirectorRuntime director = getDirectorRuntime();
    RepositoryReferences sources = getSourceRepositories();
    for (Product product : products) {
        for (TargetEnvironment env : getEnvironments()) {
            DirectorRuntime.Command command = director.newInstallCommand();
            File destination = getProductMaterializeDirectory(product, env);
            String rootFolder = product.getRootFolder(env.getOs());
            if (rootFolder != null && rootFolder.length() > 0) {
                destination = new File(destination, rootFolder);
            }
            command.addMetadataSources(sources.getMetadataRepositories());
            command.addArtifactSources(sources.getArtifactRepositories());
            command.addUnitToInstall(product.getId());
            for (DependencySeed seed : product.getAdditionalInstallationSeeds()) {
                command.addUnitToInstall(seed);
            }
            command.setDestination(destination);
            command.setProfileName(ProfileName.getNameForEnvironment(env, profileNames, profile));
            command.setEnvironment(env);
            command.setInstallFeatures(installFeatures);
            getLog().info("Installing product " + product.getId() + " for environment " + env + " to " + destination.getAbsolutePath());
            try {
                command.execute();
            } catch (DirectorCommandException e) {
                throw new MojoFailureException("Installation of product " + product.getId() + " for environment " + env + " failed", e);
            }
        }
    }
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) RepositoryReferences(org.eclipse.tycho.p2.tools.RepositoryReferences) DirectorCommandException(org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) File(java.io.File) DirectorRuntime(org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime)

Example 9 with RepositoryReferences

use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.

the class TestMojo method createProvisionedInstallation.

private EquinoxInstallation createProvisionedInstallation() throws MojoExecutionException {
    try {
        TestFrameworkProvider provider = providerHelper.selectProvider(getProjectType().getClasspath(project), getMergedProviderProperties(), providerHint);
        createSurefireProperties(provider);
        ProvisionedInstallationBuilder installationBuilder = provisionedInstallationBuilderFactory.createInstallationBuilder();
        Set<Artifact> testHarnessArtifacts = providerHelper.filterTestFrameworkBundles(provider, pluginArtifacts);
        for (Artifact testHarnessArtifact : testHarnessArtifacts) {
            installationBuilder.addBundleJar(testHarnessArtifact.getFile());
        }
        RepositoryReferences sources = repositoryReferenceTool.getVisibleRepositories(project, session, RepositoryReferenceTool.REPOSITORIES_INCLUDE_CURRENT_MODULE);
        installationBuilder.addMetadataRepositories(sources.getMetadataRepositories());
        installationBuilder.addArtifactRepositories(sources.getArtifactRepositories());
        installationBuilder.setProfileName(profileName);
        installationBuilder.addIUsToBeInstalled(getIUsToInstall(testHarnessArtifacts));
        File workingDir = new File(project.getBuild().getDirectory(), "p2temp");
        workingDir.mkdirs();
        installationBuilder.setWorkingDir(workingDir);
        installationBuilder.setDestination(work);
        return installationBuilder.install();
    } catch (Exception ex) {
        throw new MojoExecutionException(ex.getMessage(), ex);
    }
}
Also used : ProvisionedInstallationBuilder(org.eclipse.tycho.surefire.provisioning.ProvisionedInstallationBuilder) RepositoryReferences(org.eclipse.tycho.p2.tools.RepositoryReferences) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) TestFrameworkProvider(org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact) MalformedURLException(java.net.MalformedURLException) ArtifactResolutionException(org.apache.maven.artifact.resolver.ArtifactResolutionException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 10 with RepositoryReferences

use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.

the class RepositoryReferenceTool method addTargetPlatformRepository.

/**
 * Restores the p2 metadata view on the module's build target platform that was calculated
 * during the initial dependency resolution (see
 * org.eclipse.tycho.p2.resolver.P2ResolverImpl.toResolutionResult(...)).
 */
private void addTargetPlatformRepository(RepositoryReferences sources, MavenSession session, MavenProject project) throws MojoExecutionException, MojoFailureException {
    try {
        File repositoryLocation = new File(project.getBuild().getDirectory(), "targetPlatformRepository");
        repositoryLocation.mkdirs();
        FileOutputStream stream = new FileOutputStream(new File(repositoryLocation, "content.xml"));
        try {
            MetadataSerializable serializer = osgiServices.getService(MetadataSerializable.class);
            TargetPlatform targetPlatform = TychoProjectUtils.getTargetPlatform(project);
            DependencyResolver resolver = dependencyResolverLocator.lookupDependencyResolver(project);
            TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
            DependencyResolverConfiguration resolverConfiguration = configuration.getDependencyResolverConfiguration();
            DependencyArtifacts dependencyArtifacts = resolver.resolveDependencies(session, project, targetPlatform, DefaultReactorProject.adapt(session), resolverConfiguration);
            // this contains dependency-only metadata for 'this' project
            Set<Object> targetPlatformInstallableUnits = new HashSet<>(dependencyArtifacts.getInstallableUnits());
            for (ArtifactDescriptor artifact : dependencyArtifacts.getArtifacts()) {
                ReactorProject otherProject = artifact.getMavenProject();
                if (otherProject == null) {
                    // can't really happen
                    continue;
                }
                File artifactXml = otherProject.getArtifact(RepositoryLayoutHelper.CLASSIFIER_P2_ARTIFACTS);
                if (artifactXml != null && artifactXml.isFile()) {
                    sources.addArtifactRepository(artifactXml.getParentFile());
                }
            }
            serializer.serialize(stream, targetPlatformInstallableUnits);
        } finally {
            stream.close();
        }
        sources.addMetadataRepository(repositoryLocation);
    } catch (IOException e) {
        throw new MojoExecutionException("I/O exception while writing the build target platform to disk", e);
    }
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) ReactorProject(org.eclipse.tycho.ReactorProject) IOException(java.io.IOException) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) DependencyResolverConfiguration(org.eclipse.tycho.core.DependencyResolverConfiguration) DependencyResolver(org.eclipse.tycho.core.DependencyResolver) MetadataSerializable(org.eclipse.tycho.p2.metadata.MetadataSerializable) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) FileOutputStream(java.io.FileOutputStream) TargetPlatform(org.eclipse.tycho.artifacts.TargetPlatform) File(java.io.File) HashSet(java.util.HashSet)

Aggregations

RepositoryReferences (org.eclipse.tycho.p2.tools.RepositoryReferences)10 File (java.io.File)6 FacadeException (org.eclipse.tycho.p2.tools.FacadeException)4 Test (org.junit.Test)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)3 DependencySeed (org.eclipse.tycho.core.resolver.shared.DependencySeed)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 IStatus (org.eclipse.core.runtime.IStatus)2 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)2 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)2 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)2 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)2 DestinationRepositoryDescriptor (org.eclipse.tycho.p2.tools.DestinationRepositoryDescriptor)2 IUDescription (org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription)2 FileOutputStream (java.io.FileOutputStream)1 MalformedURLException (java.net.MalformedURLException)1 HashSet (java.util.HashSet)1