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);
}
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();
}
}
}
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);
}
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);
}
}
}
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);
}
}
}
}
Aggregations