use of org.eclipse.tycho.model.Feature in project tycho by eclipse.
the class AbstractArtifactDependencyWalker method traverseFeature.
protected void traverseFeature(FeatureRef ref, ArtifactDependencyVisitor visitor, WalkbackPath visited) {
ArtifactDescriptor artifact = artifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_FEATURE, ref.getId(), ref.getVersion());
if (artifact != null) {
if (visited.visited(artifact.getKey())) {
return;
}
visited.enter(artifact);
try {
File location = artifact.getLocation();
Feature feature = Feature.loadFeature(location);
traverseFeature(location, feature, ref, visitor, visited);
} finally {
visited.leave(artifact);
}
} else {
visitor.missingFeature(ref, visited.getWalkback());
}
}
use of org.eclipse.tycho.model.Feature in project tycho by eclipse.
the class EclipseModelTest method testDefaultXmlEncoding.
public void testDefaultXmlEncoding() throws Exception {
// Run the test with -Dfile.encoding=Cp1252 to be sure
Feature feature = Feature.read(new File("src/test/resources/modelio/feature-default-encoding.xml"));
Feature.write(feature, new File("target/feature-default-encoding.xml"));
Document document = XMLParser.parse(new File("target/feature-default-encoding.xml"));
Element child = document.getChild("/feature/license");
assertEquals("\u201cI AGREE\u201d", child.getText().trim());
}
use of org.eclipse.tycho.model.Feature in project tycho by eclipse.
the class ExpandReleaseVersionTest method test.
@Test
public void test() throws Exception {
Verifier verifier = getVerifier("/TYCHO0453expandReleaseVersion", false);
verifier.executeGoal("integration-test");
verifier.verifyErrorFreeLog();
File featureXml = new File(verifier.getBasedir(), "feature/target/feature.xml");
Feature feature = Feature.read(featureXml);
Assert.assertEquals("1.0.0.1234567890-bundle", feature.getPlugins().get(0).getVersion());
// TODO included features
File siteXml = new File(verifier.getBasedir(), "site/target/site/site.xml");
UpdateSite site = UpdateSite.read(siteXml);
Assert.assertEquals("1.0.0.1234567890-feature", site.getFeatures().get(0).getVersion());
// TODO .product version expansion
}
use of org.eclipse.tycho.model.Feature 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.Feature in project tycho by eclipse.
the class PackageFeatureMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
outputDirectory.mkdirs();
Feature feature = Feature.loadFeature(basedir);
File licenseFeature = licenseFeatureHelper.getLicenseFeature(feature, project);
updateLicenseProperties(feature, licenseFeature);
File featureXml = new File(outputDirectory, Feature.FEATURE_XML);
try {
expandVersionQualifiers(feature);
Feature.write(feature, featureXml);
} catch (IOException e) {
throw new MojoExecutionException("Error updating feature.xml", e);
}
BuildProperties buildProperties = buildPropertiesParser.parse(project.getBasedir());
checkBinIncludesExist(buildProperties);
File featureProperties = getFeatureProperties(licenseFeature, buildProperties);
File outputJar = new File(outputDirectory, finalName + ".jar");
outputJar.getParentFile().mkdirs();
MavenArchiver archiver = new MavenArchiver();
JarArchiver jarArchiver = getJarArchiver();
archiver.setArchiver(jarArchiver);
archiver.setOutputFile(outputJar);
jarArchiver.setDestFile(outputJar);
try {
archiver.getArchiver().addFileSet(getManuallyIncludedFiles(buildProperties));
if (licenseFeature != null) {
archiver.getArchiver().addArchivedFileSet(licenseFeatureHelper.getLicenseFeatureFileSet(licenseFeature));
}
archiver.getArchiver().addFile(featureXml, Feature.FEATURE_XML);
if (featureProperties != null) {
archiver.getArchiver().addFile(featureProperties, FEATURE_PROPERTIES);
}
if (archive == null) {
archive = new MavenArchiveConfiguration();
archive.setAddMavenDescriptor(false);
}
archiver.createArchive(session, project, archive);
} catch (Exception e) {
throw new MojoExecutionException("Error creating feature package", e);
}
project.getArtifact().setFile(outputJar);
if (deployableFeature) {
assembleDeployableFeature();
}
}
Aggregations