Search in sources :

Example 11 with Entry

use of org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry in project tycho by eclipse.

the class P2ResolverTest method getClassifiedArtifact.

private static P2ResolutionResult.Entry getClassifiedArtifact(P2ResolutionResult resolutionResult, String classifier) {
    Set<String> availableClassifiers = new HashSet<>();
    P2ResolutionResult.Entry selectedEntry = null;
    for (Entry entry : resolutionResult.getArtifacts()) {
        availableClassifiers.add(entry.getClassifier());
        if (eq(classifier, entry.getClassifier())) {
            selectedEntry = entry;
        }
    }
    assertThat(availableClassifiers, hasItem(classifier));
    return selectedEntry;
}
Also used : Entry(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry) P2ResolutionResult(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Entry(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry) HashSet(java.util.HashSet)

Example 12 with Entry

use of org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry in project tycho by eclipse.

the class FeatureRootfileArtifactRepository method createRootfileOutputStream.

private OutputStream createRootfileOutputStream(IArtifactKey artifactKey) throws ProvisionException, IOException {
    File outputFile = new File(this.outputDirectory, artifactKey.getId() + "-" + artifactKey.getVersion() + "-" + ROOTFILE_CLASSIFIER + "." + ROOTFILE_EXTENSION);
    OutputStream target = null;
    try {
        SimpleArtifactDescriptor simpleArtifactDescriptor = (SimpleArtifactDescriptor) createArtifactDescriptor(artifactKey);
        Collection<IPropertyAdvice> advices = publisherInfo.getAdvice(null, false, simpleArtifactDescriptor.getArtifactKey().getId(), simpleArtifactDescriptor.getArtifactKey().getVersion(), IPropertyAdvice.class);
        boolean mavenPropAdviceExists = false;
        for (IPropertyAdvice entry : advices) {
            if (entry instanceof MavenPropertiesAdvice) {
                mavenPropAdviceExists = true;
                entry.getArtifactProperties(null, simpleArtifactDescriptor);
            }
        }
        if (!mavenPropAdviceExists) {
            throw new ProvisionException("MavenPropertiesAdvice does not exist for artifact: " + simpleArtifactDescriptor);
        }
        String mavenArtifactClassifier = getRootFileArtifactClassifier(simpleArtifactDescriptor.getArtifactKey().getId());
        simpleArtifactDescriptor.setProperty(RepositoryLayoutHelper.PROP_CLASSIFIER, mavenArtifactClassifier);
        simpleArtifactDescriptor.setProperty(RepositoryLayoutHelper.PROP_EXTENSION, ROOTFILE_EXTENSION);
        target = new BufferedOutputStream(new FileOutputStream(outputFile));
        this.publishedArtifacts.put(mavenArtifactClassifier, new P2Artifact(outputFile, Collections.<IInstallableUnit>emptySet(), simpleArtifactDescriptor));
        descriptors.add(simpleArtifactDescriptor);
    } catch (FileNotFoundException e) {
        throw new ProvisionException(e.getMessage(), e);
    }
    return target;
}
Also used : BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) IPropertyAdvice(org.eclipse.equinox.p2.publisher.actions.IPropertyAdvice) MavenPropertiesAdvice(org.eclipse.tycho.p2.impl.publisher.MavenPropertiesAdvice) FileNotFoundException(java.io.FileNotFoundException) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) FileOutputStream(java.io.FileOutputStream) IP2Artifact(org.eclipse.tycho.p2.metadata.IP2Artifact) P2Artifact(org.eclipse.tycho.p2.impl.publisher.P2Artifact) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) SimpleArtifactDescriptor(org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 13 with Entry

use of org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry in project tycho by eclipse.

the class P2DependencyResolver method getThisReactorProject.

private ReactorProject getThisReactorProject(MavenSession session, MavenProject project, TargetPlatformConfiguration configuration) {
    // 'this' project should obey optionalDependencies configuration
    final List<TargetEnvironment> environments = configuration.getEnvironments();
    final OptionalResolutionAction optionalAction = configuration.getDependencyResolverConfiguration().getOptionalResolutionAction();
    Map<String, IDependencyMetadata> dependencyMetadata = getDependencyMetadata(session, project, environments, optionalAction);
    final Set<Object> metadata = new LinkedHashSet<>();
    final Set<Object> secondaryMetadata = new LinkedHashSet<>();
    for (Map.Entry<String, IDependencyMetadata> entry : dependencyMetadata.entrySet()) {
        metadata.addAll(entry.getValue().getMetadata(true));
        secondaryMetadata.addAll(entry.getValue().getMetadata(false));
    }
    ReactorProject reactorProjet = new DefaultReactorProject(project) {

        @Override
        public Set<?> getDependencyMetadata(boolean primary) {
            return primary ? metadata : secondaryMetadata;
        }
    };
    return reactorProjet;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) OptionalResolutionAction(org.eclipse.tycho.core.resolver.shared.OptionalResolutionAction) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) IDependencyMetadata(org.eclipse.tycho.p2.metadata.IDependencyMetadata) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ArrayList (java.util.ArrayList)5 Entry (org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry)5 File (java.io.File)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)4 IP2Artifact (org.eclipse.tycho.p2.metadata.IP2Artifact)4 P2ResolutionResult (org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 LinkedHashSet (java.util.LinkedHashSet)3 ReactorProject (org.eclipse.tycho.ReactorProject)3 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)3 IOException (java.io.IOException)2 Artifact (org.apache.maven.artifact.Artifact)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 ArtifactDelta (org.eclipse.tycho.artifactcomparator.ArtifactDelta)2 MavenRepositoryLocation (org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation)2