use of org.eclipse.tycho.model.Feature in project tycho by eclipse.
the class SetLicenseFeatureVersionTest method test.
@Test
public void test() throws Exception {
Verifier verifier = getVerifier("/licenseFeature.setVersion", false);
verifier.getCliOptions().add("-DnewVersion=" + NEW_MAVEN_VERSION);
verifier.executeGoal("org.eclipse.tycho:tycho-versions-plugin:" + TychoVersion.getTychoVersion() + ":set-version");
verifier.verifyErrorFreeLog();
File licenseFeatureDir = new File(verifier.getBasedir(), "license.feature");
Feature licenseFeature = Feature.read(new File(licenseFeatureDir, "feature.xml"));
assertEquals(NEW_OSGI_VERSION, licenseFeature.getVersion());
File otherFeatureDir = new File(verifier.getBasedir(), "other.feature");
Feature otherFeature = Feature.read(new File(otherFeatureDir, "feature.xml"));
assertEquals(NEW_OSGI_VERSION, otherFeature.getLicenseFeatureVersion());
}
use of org.eclipse.tycho.model.Feature 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.Feature in project tycho by eclipse.
the class PackageFeatureMojo method updateLicenseProperties.
private void updateLicenseProperties(Feature feature, File licenseFeatureFile) {
// remove license feature id and version from feature.xml
feature.setLicenseFeature(null);
feature.setLicenseFeatureVersion(null);
// copy the license text and URL from the license feature
if (licenseFeatureFile != null) {
Feature licenseFeature = Feature.loadFeature(licenseFeatureFile);
if (licenseFeature.getLicenseURL() != null) {
feature.setLicenseURL(licenseFeature.getLicenseURL());
}
if (licenseFeature.getLicense() != null) {
feature.setLicense(licenseFeature.getLicense());
}
}
}
use of org.eclipse.tycho.model.Feature in project tycho by eclipse.
the class PackageFeatureMojoTest method testLicenseFeature.
public void testLicenseFeature() throws Exception {
File basedir = getBasedir("projects/licenseFeature/feature");
File platform = new File("src/test/resources/projects/licenseFeature/eclipse");
List<MavenProject> projects = getSortedProjects(basedir, platform);
MavenProject project = getProject(projects, "licenseFeature.feature");
MavenSession session = newMavenSession(project, projects);
// set build qualifier
lookupMojoWithDefaultConfiguration(project, session, "build-qualifier").execute();
PackageFeatureMojo mojo = (PackageFeatureMojo) lookupMojo("package-feature", project.getFile());
setVariableValueToObject(mojo, "project", project);
setVariableValueToObject(mojo, "session", session);
setVariableValueToObject(mojo, "finalName", "feature");
mojo.execute();
ZipFile zip = new ZipFile(new File(basedir, "target/feature.jar"));
try {
// igorf: input streams are closed by zip.close() at the end, sloppy but should work
// all bin.includes files from license features are included
assertNotNull(zip.getEntry("file-license.txt"));
assertNull(zip.getEntry("file-unlicense.txt"));
// do not leak build.properties into 'this' feature
assertNull(zip.getEntry("build.properties"));
// license feature id/version are stripped off
Feature feature = Feature.read(zip.getInputStream(zip.getEntry(Feature.FEATURE_XML)));
assertNull(feature.getLicenseFeature());
assertNull(feature.getLicenseFeatureVersion());
assertEquals("http://www.foo.bar", feature.getLicenseURL());
assertEquals("This is the license", feature.getLicense().trim());
// feature.properties merged
Properties p = new Properties();
p.load(zip.getInputStream(zip.getEntry("feature.properties")));
assertEquals("test property value", p.getProperty("test"));
assertEquals("license test property value", p.getProperty("license-test"));
// when present both in 'this' and license feature, files from 'this' feature are included
assertEquals("file.txt contents", IOUtil.toString(zip.getInputStream(zip.getEntry("file.txt"))));
} finally {
zip.close();
}
}
use of org.eclipse.tycho.model.Feature in project tycho by eclipse.
the class LocalDependencyResolver method resolveDependencies.
@Override
public DependencyArtifacts resolveDependencies(MavenSession session, MavenProject project, TargetPlatform resolutionContext, List<ReactorProject> reactorProjects, DependencyResolverConfiguration resolverConfiguration) {
DefaultDependencyArtifacts platform = new DefaultDependencyArtifacts(DefaultReactorProject.adapt(project));
for (File site : layout.getSites()) {
for (File plugin : layout.getPlugins(site)) {
ArtifactKey artifactKey = getArtifactKey(session, plugin);
if (artifactKey != null) {
platform.addArtifactFile(artifactKey, plugin, null);
}
}
for (File feature : layout.getFeatures(site)) {
Feature desc = Feature.loadFeature(feature);
ArtifactKey key = new DefaultArtifactKey(ArtifactType.TYPE_ECLIPSE_FEATURE, desc.getId(), desc.getVersion());
platform.addArtifactFile(key, feature, null);
}
}
addProjects(session, platform);
addDependencies(session, project, platform);
if (platform.isEmpty()) {
getLogger().warn("Could not find any bundles or features in " + layout.getLocation());
}
return platform;
}
Aggregations