use of org.eclipse.tycho.model.PluginRef 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);
}
}
}
}
use of org.eclipse.tycho.model.PluginRef in project tycho by eclipse.
the class GeneratePomsMojo method getFeatureFeaturesAndPlugins.
private Set<File> getFeatureFeaturesAndPlugins(File basedir) throws MojoExecutionException {
try {
Set<File> result = new LinkedHashSet<>();
Feature feature = Feature.read(new File(basedir, "feature.xml"));
for (PluginRef plugin : feature.getPlugins()) {
addPlugin(result, plugin.getId());
}
for (FeatureRef includedFeature : feature.getIncludedFeatures()) {
addFeature(result, includedFeature.getId());
}
for (Feature.RequiresRef require : feature.getRequires()) {
for (Feature.ImportRef imp : require.getImports()) {
addPlugin(result, imp.getPlugin());
addFeature(result, imp.getFeature());
}
}
return result;
} catch (IOException e) {
throw new MojoExecutionException("Exception processing feature " + toString(basedir), e);
} catch (XmlPullParserException e) {
throw new MojoExecutionException("Exception processing feature " + toString(basedir), e);
}
}
use of org.eclipse.tycho.model.PluginRef in project tycho by eclipse.
the class WorkspaceTychoOsgiRuntimeLocator method addProduct.
public boolean addProduct(EquinoxRuntimeDescription result, Artifact pom) throws MavenExecutionException {
ProductConfiguration product;
try {
product = ProductConfiguration.read(new File(pom.getFile().getParentFile(), pom.getArtifactId() + ".product"));
} catch (IOException e) {
return false;
}
// the above fails with IOException if .product file is not available or can't be read
// we get here only when we have valid product instance
Set<String> missing = new LinkedHashSet<>();
for (PluginRef pluginRef : product.getPlugins()) {
DevBundleInfo bundleInfo = workspaceState.getBundleInfo(pluginRef.getId(), pluginRef.getVersion());
if (bundleInfo != null) {
addBundle(result, bundleInfo);
} else {
missing.add(pluginRef.toString());
}
}
if (!missing.isEmpty()) {
throw new MavenExecutionException("Inconsistent m2e-tycho workspace state, missing bundles: " + missing.toString(), (Throwable) null);
}
Map<String, BundleConfiguration> bundleConfigurations = product.getPluginConfiguration();
if (bundleConfigurations != null) {
for (BundleConfiguration bundleConfiguration : bundleConfigurations.values()) {
result.addBundleStartLevel(bundleConfiguration.getId(), bundleConfiguration.getStartLevel(), bundleConfiguration.isAutoStart());
}
}
return true;
}
use of org.eclipse.tycho.model.PluginRef in project tycho by eclipse.
the class FeatureXmlTransformerTest method testExpandReferences.
@SuppressWarnings("deprecation")
@Test
public void testExpandReferences() throws Exception {
subject = new FeatureXmlTransformer(new SilentLog(), new NoopFileLockService());
Feature feature = Feature.read(new File(TestUtil.getBasedir("projects/featureXmlVersionExpansion/"), "feature.xml"));
TargetPlatform tp = mock(TargetPlatform.class);
when(tp.resolveArtifact("eclipse-feature", "org.eclipse.rcp", "4.5.0.qualifier")).thenReturn(rcpFeatureInTP);
when(tp.resolveArtifact("eclipse-plugin", "org.junit4", "4.8.1.qualifier")).thenReturn(junit4InTP);
when(tp.getArtifactLocation(junit4InTP)).thenReturn(junit4JarLocation);
subject.expandReferences(feature, tp);
assertThat(feature.getIncludedFeatures(), hasItem(feature("org.eclipse.rcp", "4.5.0.v20140918")));
assertThat(feature.getPlugins(), hasItem(plugin("org.junit4", "4.8.1.v20100302")));
PluginRef plugin = feature.getPlugins().get(0);
assertThat(plugin.getId(), is("org.junit4"));
// 1720 bytes rounded to kiB
assertThat(plugin.getDownloadSize(), is(1L));
// 2419 bytes rounded to kiB // TODO shouldn't installSize=downloadSize for unpack=false?
assertThat(plugin.getInstallSize(), is(2L));
assertThat(plugin.isUnpack(), is(false));
}
use of org.eclipse.tycho.model.PluginRef in project tycho by eclipse.
the class FeatureXmlTransformer method expandReferences.
/**
* Replaces references in the feature model with versions from the target platform.
*
* @param feature
* The feature model to have plug-in and feature references completed.
*/
public Feature expandReferences(Feature feature, TargetPlatform targetPlatform) throws MojoFailureException {
for (PluginRef pluginRef : feature.getPlugins()) {
ArtifactKey plugin = resolvePluginReference(targetPlatform, pluginRef);
pluginRef.setVersion(plugin.getVersion());
File location = targetPlatform.getArtifactLocation(plugin);
setDownloadAndInstallSize(pluginRef, location);
}
for (FeatureRef featureRef : feature.getIncludedFeatures()) {
ArtifactKey includedFeature = resolveFeatureReference(targetPlatform, featureRef);
featureRef.setVersion(includedFeature.getVersion());
}
return feature;
}
Aggregations