Search in sources :

Example 11 with ArtifactDescriptor

use of org.eclipse.tycho.ArtifactDescriptor in project tycho by eclipse.

the class ArtifactCollection method addArtifact.

protected void addArtifact(ArtifactDescriptor artifact, boolean merge) {
    if (artifact.getClass() != DefaultArtifactDescriptor.class) {
        throw new IllegalAccessError();
    }
    ArtifactKey key = normalizePluginType(artifact.getKey());
    File location = normalizeLocation(artifact.getLocation());
    ArtifactDescriptor original = artifacts.get(key);
    Set<Object> units = null;
    if (original != null) {
        // can't use DefaultArtifactDescriptor.equals because artifact.location is not normalized
        if (!eq(original.getLocation(), location) || !eq(original.getClassifier(), artifact.getClassifier()) || !eq(original.getMavenProject(), artifact.getMavenProject())) {
            // TODO better error message
            throw new IllegalStateException("Inconsistent artifact with key " + artifact.getKey());
        }
        // artifact equals to original
        if (eq(original.getInstallableUnits(), artifact.getInstallableUnits())) {
            return;
        }
        if (!merge) {
            // TODO better error message
            throw new IllegalStateException("Inconsistent artifact with key " + artifact.getKey());
        }
        units = new LinkedHashSet<>(original.getInstallableUnits());
        units.addAll(artifact.getInstallableUnits());
    } else {
        units = artifact.getInstallableUnits();
    }
    // reuse artifact keys to reduce memory usage
    key = normalize(key);
    if (units != null) {
        units = Collections.unmodifiableSet(units);
    }
    // recreate artifact descriptor to use normalized location, key and units
    artifact = new DefaultArtifactDescriptor(key, location, artifact.getMavenProject(), artifact.getClassifier(), units);
    // do not cache reactor project artifact descriptors because their IUs can change without changing (id,version)
    if (artifact.getMavenProject() == null) {
        artifact = normalize(artifact);
    }
    artifacts.put(artifact.getKey(), artifact);
    Map<String, ArtifactDescriptor> classified = locations.get(location);
    if (classified == null) {
        classified = new LinkedHashMap<>();
        locations.put(location, classified);
    }
    // sanity check, all artifacts at the same location have the same reactor project
    for (ArtifactDescriptor other : classified.values()) {
        if (!eq(artifact.getMavenProject(), other.getMavenProject())) {
            throw new IllegalStateException("Inconsistent reactor project at location " + location + ". " + artifact.getMavenProject() + " is not the same as " + other.getMavenProject());
        }
    }
    classified.put(artifact.getClassifier(), artifact);
}
Also used : DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) ArtifactKey(org.eclipse.tycho.ArtifactKey) DefaultArtifactDescriptor(org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) DefaultArtifactDescriptor(org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor) File(java.io.File)

Example 12 with ArtifactDescriptor

use of org.eclipse.tycho.ArtifactDescriptor in project tycho by eclipse.

the class ArtifactCollection method removeAll.

public void removeAll(String type, String id) {
    Iterator<Entry<ArtifactKey, ArtifactDescriptor>> iter = artifacts.entrySet().iterator();
    while (iter.hasNext()) {
        Entry<ArtifactKey, ArtifactDescriptor> entry = iter.next();
        ArtifactKey key = entry.getKey();
        if (key.getType().equals(type) && key.getId().equals(id)) {
            locations.remove(entry.getValue().getLocation());
            iter.remove();
        }
    }
}
Also used : Entry(java.util.Map.Entry) DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) ArtifactKey(org.eclipse.tycho.ArtifactKey) DefaultArtifactDescriptor(org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor)

Example 13 with ArtifactDescriptor

use of org.eclipse.tycho.ArtifactDescriptor in project tycho by eclipse.

the class DefaultDependencyArtifacts method getInstallableUnits.

@Override
public Set<?> getInstallableUnits() {
    Set<Object> units = new LinkedHashSet<>();
    for (ArtifactDescriptor artifact : artifacts.values()) {
        if (project == null || !project.equals(artifact.getMavenProject())) {
            units.addAll(artifact.getInstallableUnits());
        }
    }
    units.addAll(nonReactorUnits);
    return Collections.unmodifiableSet(units);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor)

Example 14 with ArtifactDescriptor

use of org.eclipse.tycho.ArtifactDescriptor in project tycho by eclipse.

the class AbstractArtifactDependencyWalker method traverseFeature.

protected void traverseFeature(File location, Feature feature, FeatureRef featureRef, ArtifactDependencyVisitor visitor, WalkbackPath visited) {
    ArtifactDescriptor artifact = getArtifact(location, feature.getId());
    if (artifact == null) {
        // ah?
        throw new IllegalStateException("Feature " + location + " with id " + feature.getId() + " is not part of the project build target platform");
    }
    ArtifactKey key = artifact.getKey();
    ReactorProject project = artifact.getMavenProject();
    String classifier = artifact.getClassifier();
    Set<Object> installableUnits = artifact.getInstallableUnits();
    DefaultFeatureDescription description = new DefaultFeatureDescription(key, location, project, classifier, feature, featureRef, installableUnits);
    if (visitor.visitFeature(description)) {
        for (PluginRef ref : feature.getPlugins()) {
            traversePlugin(ref, visitor, visited);
        }
        for (FeatureRef ref : feature.getIncludedFeatures()) {
            traverseFeature(ref, visitor, visited);
        }
    }
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) ReactorProject(org.eclipse.tycho.ReactorProject) PluginRef(org.eclipse.tycho.model.PluginRef) FeatureRef(org.eclipse.tycho.model.FeatureRef)

Example 15 with ArtifactDescriptor

use of org.eclipse.tycho.ArtifactDescriptor in project tycho by eclipse.

the class AbstractArtifactDependencyWalker method traverseProduct.

protected void traverseProduct(ProductConfiguration product, ArtifactDependencyVisitor visitor, WalkbackPath visited) {
    if (product.useFeatures()) {
        for (FeatureRef ref : product.getFeatures()) {
            traverseFeature(ref, visitor, visited);
        }
    } else {
        for (PluginRef ref : product.getPlugins()) {
            traversePlugin(ref, visitor, visited);
        }
    }
    Set<String> bundles = new HashSet<>();
    for (ArtifactDescriptor artifact : visited.getVisited()) {
        ArtifactKey key = artifact.getKey();
        if (ArtifactType.TYPE_ECLIPSE_PLUGIN.equals(key.getType())) {
            bundles.add(key.getId());
        }
    }
    if (environments != null && product.includeLaunchers()) {
        for (TargetEnvironment environment : environments) {
            String os = environment.getOs();
            String ws = environment.getWs();
            String arch = environment.getArch();
            String id;
            // see http://jira.codehaus.org/browse/MNGECLIPSE-1075
            if (PlatformPropertiesUtils.OS_MACOSX.equals(os) && (PlatformPropertiesUtils.ARCH_X86.equals(arch) || PlatformPropertiesUtils.ARCH_PPC.equals(arch))) {
                id = "org.eclipse.equinox.launcher." + ws + "." + os;
            } else {
                id = "org.eclipse.equinox.launcher." + ws + "." + os + "." + arch;
            }
            if (!bundles.contains(id)) {
                PluginRef ref = new PluginRef("plugin");
                ref.setId(id);
                ref.setOs(os);
                ref.setWs(ws);
                ref.setArch(arch);
                ref.setUnpack(true);
                traversePlugin(ref, visitor, visited);
            }
        }
    }
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) PluginRef(org.eclipse.tycho.model.PluginRef) FeatureRef(org.eclipse.tycho.model.FeatureRef) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) HashSet(java.util.HashSet)

Aggregations

ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)32 File (java.io.File)20 ArtifactKey (org.eclipse.tycho.ArtifactKey)13 ReactorProject (org.eclipse.tycho.ReactorProject)10 DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)8 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)5 IOException (java.io.IOException)4 DefaultArtifactKey (org.eclipse.tycho.DefaultArtifactKey)4 DefaultArtifactDescriptor (org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor)4 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)4 ArrayList (java.util.ArrayList)3 LinkedHashMap (java.util.LinkedHashMap)3 PluginDescription (org.eclipse.tycho.core.PluginDescription)3 Version (org.osgi.framework.Version)3 FileOutputStream (java.io.FileOutputStream)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 Properties (java.util.Properties)2 ZipFile (java.util.zip.ZipFile)2