Search in sources :

Example 1 with SimpleArtifactDescriptor

use of org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor 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;
}
Also used : BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) IPropertyAdvice(org.eclipse.equinox.p2.publisher.actions.IPropertyAdvice) MavenPropertiesAdvice(org.eclipse.tycho.p2.impl.publisher.MavenPropertiesAdvice) FileNotFoundException(java.io.FileNotFoundException) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) FileOutputStream(java.io.FileOutputStream) IP2Artifact(org.eclipse.tycho.p2.metadata.IP2Artifact) P2Artifact(org.eclipse.tycho.p2.impl.publisher.P2Artifact) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) SimpleArtifactDescriptor(org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Aggregations

BufferedOutputStream (java.io.BufferedOutputStream)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 SimpleArtifactDescriptor (org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor)1 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)1 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)1 IPropertyAdvice (org.eclipse.equinox.p2.publisher.actions.IPropertyAdvice)1 MavenPropertiesAdvice (org.eclipse.tycho.p2.impl.publisher.MavenPropertiesAdvice)1 P2Artifact (org.eclipse.tycho.p2.impl.publisher.P2Artifact)1 IP2Artifact (org.eclipse.tycho.p2.metadata.IP2Artifact)1