use of org.eclipse.equinox.p2.publisher.actions.IPropertyAdvice in project tycho by eclipse.
the class FeatureRootfileArtifactRepository method createRootfileOutputStream.
private OutputStream createRootfileOutputStream(IArtifactKey artifactKey) throws ProvisionException, IOException {
File outputFile = new File(this.outputDirectory, artifactKey.getId() + "-" + artifactKey.getVersion() + "-" + ROOTFILE_CLASSIFIER + "." + ROOTFILE_EXTENSION);
OutputStream target = null;
try {
SimpleArtifactDescriptor simpleArtifactDescriptor = (SimpleArtifactDescriptor) createArtifactDescriptor(artifactKey);
Collection<IPropertyAdvice> advices = publisherInfo.getAdvice(null, false, simpleArtifactDescriptor.getArtifactKey().getId(), simpleArtifactDescriptor.getArtifactKey().getVersion(), IPropertyAdvice.class);
boolean mavenPropAdviceExists = false;
for (IPropertyAdvice entry : advices) {
if (entry instanceof MavenPropertiesAdvice) {
mavenPropAdviceExists = true;
entry.getArtifactProperties(null, simpleArtifactDescriptor);
}
}
if (!mavenPropAdviceExists) {
throw new ProvisionException("MavenPropertiesAdvice does not exist for artifact: " + simpleArtifactDescriptor);
}
String mavenArtifactClassifier = getRootFileArtifactClassifier(simpleArtifactDescriptor.getArtifactKey().getId());
simpleArtifactDescriptor.setProperty(RepositoryLayoutHelper.PROP_CLASSIFIER, mavenArtifactClassifier);
simpleArtifactDescriptor.setProperty(RepositoryLayoutHelper.PROP_EXTENSION, ROOTFILE_EXTENSION);
target = new BufferedOutputStream(new FileOutputStream(outputFile));
this.publishedArtifacts.put(mavenArtifactClassifier, new P2Artifact(outputFile, Collections.<IInstallableUnit>emptySet(), simpleArtifactDescriptor));
descriptors.add(simpleArtifactDescriptor);
} catch (FileNotFoundException e) {
throw new ProvisionException(e.getMessage(), e);
}
return target;
}
Aggregations