use of org.eclipse.tycho.model.Feature in project tycho by eclipse.
the class EclipseModelTest method testFeature.
public void testFeature() throws Exception {
Feature feature = Feature.read(new File("src/test/resources/modelio/feature.xml"));
assertEquals("1.0.0", feature.getVersion());
List<PluginRef> plugins = feature.getPlugins();
assertEquals(1, plugins.size());
assertEquals("pluginA", plugins.get(0).getId());
List<FeatureRef> features = feature.getIncludedFeatures();
assertEquals(1, features.size());
List<Feature.RequiresRef> requires = feature.getRequires();
assertEquals(1, requires.size());
assertEquals("pluginB", requires.get(0).getImports().get(0).getPlugin());
assertEquals("featureC", requires.get(0).getImports().get(1).getFeature());
// not structural data - getters
assertEquals("featureA", feature.getLabel());
assertEquals("COMPANY", feature.getProvider());
assertEquals("Test License", feature.getLicense().trim());
assertEquals("http://www.example.com/license", feature.getLicenseURL());
assertEquals(null, feature.getCopyrightURL());
assertEquals(null, feature.getCopyright());
feature.setVersion("1.2.3");
plugins.get(0).setVersion("3.4.5");
// not structural data - setters
feature.setLabel("featureA_MODIFIED");
feature.setProvider("COMPANY_MODIFIED");
feature.setLicense("Test License MODIFIED");
feature.setLicenseURL("http://www.example.com/license_MODIFIED");
feature.setCopyright("Test Copyright");
feature.setCopyrightURL("http://www.example.com/copyright");
File updatedFile = new File(target, "feature.xml");
Feature.write(feature, updatedFile);
Feature updated = Feature.read(updatedFile);
assertEquals("1.2.3", updated.getVersion());
assertEquals("3.4.5", updated.getPlugins().get(0).getVersion());
// not structural data - persistence
assertEquals("featureA_MODIFIED", feature.getLabel());
assertEquals("COMPANY_MODIFIED", feature.getProvider());
assertEquals("Test License MODIFIED", feature.getLicense());
assertEquals("http://www.example.com/license_MODIFIED", feature.getLicenseURL());
assertEquals("http://www.example.com/copyright", feature.getCopyrightURL());
assertEquals("Test Copyright", feature.getCopyright());
}
use of org.eclipse.tycho.model.Feature in project tycho by eclipse.
the class FeatureXmlManipulator method applyChanges.
@Override
public void applyChanges(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
if (isFeature(project)) {
Feature feature = getFeatureXml(project);
for (PomVersionChange change : versionChangeContext.getVersionChanges()) {
if (isFeature(change.getProject().getPackaging())) {
if (change.getArtifactId().equals(feature.getId()) && change.getVersion().equals(feature.getVersion())) {
logger.info(" feature.xml//feature/@version: " + change.getVersion() + " => " + change.getNewVersion());
feature.setVersion(change.getNewVersion());
}
changeLicenseFeature(change, feature);
// could be included feature
changeIncludedFeatures(change, feature);
changeRequiredFeatures(change, feature, versionChangeContext.getVersionRangeUpdateStrategy());
} else if (isBundle(change.getProject())) {
changeIncludedPlugins(change, feature);
changeRequiredPlugins(change, feature, versionChangeContext.getVersionRangeUpdateStrategy());
}
}
}
}
use of org.eclipse.tycho.model.Feature in project tycho by eclipse.
the class OsgiBundleProject method getDependencyWalker.
@Override
public ArtifactDependencyWalker getDependencyWalker(MavenProject project) {
final DependencyArtifacts artifacts = getDependencyArtifacts(project);
final List<ClasspathEntry> cp = getClasspath(project);
return new ArtifactDependencyWalker() {
@Override
public void walk(ArtifactDependencyVisitor visitor) {
for (ClasspathEntry entry : cp) {
ArtifactDescriptor artifact = artifacts.getArtifact(entry.getArtifactKey());
ArtifactKey key = artifact.getKey();
File location = artifact.getLocation();
ReactorProject project = artifact.getMavenProject();
String classifier = artifact.getClassifier();
Set<Object> installableUnits = artifact.getInstallableUnits();
PluginDescription plugin = new DefaultPluginDescription(key, location, project, classifier, null, installableUnits);
visitor.visitPlugin(plugin);
}
}
@Override
public void traverseFeature(File location, Feature feature, ArtifactDependencyVisitor visitor) {
}
@Override
public void traverseUpdateSite(UpdateSite site, ArtifactDependencyVisitor artifactDependencyVisitor) {
}
@Override
public void traverseProduct(ProductConfiguration productConfiguration, ArtifactDependencyVisitor visitor) {
}
};
}
use of org.eclipse.tycho.model.Feature in project tycho by eclipse.
the class EclipseFeatureProject method newDependencyWalker.
@Override
protected ArtifactDependencyWalker newDependencyWalker(MavenProject project, TargetEnvironment environment) {
final File location = project.getBasedir();
final Feature feature = Feature.loadFeature(location);
return new AbstractArtifactDependencyWalker(getDependencyArtifacts(project, environment), getEnvironments(project, environment)) {
@Override
public void walk(ArtifactDependencyVisitor visitor) {
traverseFeature(location, feature, visitor);
}
};
}
use of org.eclipse.tycho.model.Feature in project tycho by eclipse.
the class LicenseFeatureTest method assertFeatureJar.
protected void assertFeatureJar(File feature) throws ZipException, IOException {
assertTrue(feature.canRead());
ZipFile zip = new ZipFile(feature);
try {
Assert.assertNotNull(zip.getEntry("file1.txt"));
Assert.assertNotNull(zip.getEntry("file2.txt"));
Properties p = new Properties();
InputStream is = zip.getInputStream(zip.getEntry("feature.properties"));
try {
p.load(is);
} finally {
IOUtil.close(is);
}
Feature featureXML = Feature.readJar(feature);
// make sure that the properties file contains the keys
Assert.assertEquals("file1.txt", p.getProperty("licenseURL"));
Assert.assertEquals("License - The More The Merrier.", p.getProperty("license"));
// make sure that the feature.xml references the keys from the properties file
Assert.assertEquals("%licenseURL", featureXML.getLicenseURL());
Assert.assertEquals("%license", featureXML.getLicense().trim());
} finally {
zip.close();
}
}
Aggregations