use of org.eclipse.tycho.ArtifactDescriptor in project tycho by eclipse.
the class LicenseFeatureHelper method getLicenseFeature.
/**
* Get the license feature jar for feature (or <code>null</code> if it has no license feature).
*
* See {@linkplain http://wiki.eclipse.org/Equinox/p2/License_Mechanism }.
*
* @param feature
* original feature
* @param mavenProject
* original feature project
* @return the license feature jar
*/
public File getLicenseFeature(Feature feature, MavenProject mavenProject) {
String id = feature.getLicenseFeature();
if (id == null) {
return null;
}
ArtifactDescriptor licenseFeature = TychoProjectUtils.getDependencyArtifacts(mavenProject).getArtifact(ArtifactType.TYPE_ECLIPSE_FEATURE, id, feature.getLicenseFeatureVersion());
if (licenseFeature == null) {
throw new IllegalStateException("License feature with id " + id + " is not found among project dependencies");
}
ReactorProject licenseProject = licenseFeature.getMavenProject();
if (licenseProject == null) {
return licenseFeature.getLocation();
}
File artifact = licenseProject.getArtifact();
if (!artifact.isFile()) {
throw new IllegalStateException("At least ''package'' phase need to be executed");
}
return artifact;
}
use of org.eclipse.tycho.ArtifactDescriptor in project tycho by eclipse.
the class BuildQualifierAggregatorMojo method getBuildTimestamp.
@Override
protected Date getBuildTimestamp() throws MojoExecutionException {
Date timestamp = super.getBuildTimestamp();
if (timestampProvider == null) {
// no included bundle/feature can have more recent timestamp
return timestamp;
}
final Date[] latestTimestamp = new Date[] { timestamp };
TychoProject projectType = projectTypes.get(project.getPackaging());
if (projectType == null) {
throw new IllegalStateException("Unknown or unsupported packaging type " + packaging);
}
final ReactorProject thisProject = DefaultReactorProject.adapt(project);
projectType.getDependencyWalker(project).walk(new ArtifactDependencyVisitor() {
@Override
public boolean visitFeature(FeatureDescription feature) {
if (feature.getFeatureRef() == null || thisProject.equals(feature.getMavenProject())) {
// visit immediately included features
return true;
}
visitArtifact(feature);
// do not visit indirectly included features/bundles
return false;
}
@Override
public void visitPlugin(PluginDescription plugin) {
if (plugin.getPluginRef() == null || thisProject.equals(plugin.getMavenProject())) {
// 'this' bundle
return;
}
visitArtifact(plugin);
}
private void visitArtifact(ArtifactDescriptor artifact) {
ReactorProject otherProject = artifact.getMavenProject();
String otherVersion = (otherProject != null) ? otherProject.getExpandedVersion() : artifact.getKey().getVersion();
Version v = Version.parseVersion(otherVersion);
String otherQualifier = v.getQualifier();
if (otherQualifier != null) {
Date timestamp = parseQualifier(otherQualifier);
if (timestamp != null) {
if (latestTimestamp[0].compareTo(timestamp) < 0) {
if (getLog().isDebugEnabled()) {
getLog().debug("Found '" + format.format(timestamp) + "' from qualifier '" + otherQualifier + "' for artifact " + artifact);
}
latestTimestamp[0] = timestamp;
}
} else {
getLog().debug("Could not parse qualifier timestamp " + otherQualifier);
}
}
}
private Date parseQualifier(String qualifier) {
Date timestamp = parseQualifier(qualifier, format);
if (timestamp != null) {
return timestamp;
}
return discoverTimestamp(qualifier);
}
private Date parseQualifier(String qualifier, SimpleDateFormat format) {
ParsePosition pos = new ParsePosition(0);
Date timestamp = format.parse(qualifier, pos);
if (timestamp != null && pos.getIndex() == qualifier.length()) {
return timestamp;
}
return null;
}
private Date discoverTimestamp(String qualifier) {
return timestampFinder.findInString(qualifier);
}
});
return latestTimestamp[0];
}
Aggregations