Search in sources :

Example 1 with BundleListXpp3Writer

use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.io.xpp3.BundleListXpp3Writer in project sling by apache.

the class AttachPartialBundleListMojo method execute.

public void execute() throws MojoExecutionException, MojoFailureException {
    final BundleList initializedBundleList;
    if (bundleListFile.exists()) {
        try {
            initializedBundleList = readBundleList(bundleListFile);
        } catch (IOException e) {
            throw new MojoExecutionException("Unable to read bundle list file", e);
        } catch (XmlPullParserException e) {
            throw new MojoExecutionException("Unable to read bundle list file", e);
        }
    } else {
        throw new MojoFailureException(String.format("Bundle list file %s does not exist.", bundleListFile.getAbsolutePath()));
    }
    interpolateProperties(initializedBundleList, this.project, this.mavenSession);
    final BundleListXpp3Writer writer = new BundleListXpp3Writer();
    try {
        this.bundleListOutput.getParentFile().mkdirs();
        writer.write(new FileWriter(bundleListOutput), initializedBundleList);
    } catch (IOException e) {
        throw new MojoExecutionException("Unable to write bundle list", e);
    }
    // if this project is a partial bundle list, it's the main artifact
    if (project.getPackaging().equals(PARTIAL)) {
        project.getArtifact().setFile(bundleListOutput);
    } else {
        // otherwise attach it as an additional artifact
        projectHelper.attachArtifact(project, TYPE, CLASSIFIER, bundleListOutput);
    }
    this.getLog().info("Attaching bundle list configuration");
    try {
        this.attachConfigurations();
    } catch (final IOException ioe) {
        throw new MojoExecutionException("Unable to attach configuration.", ioe);
    } catch (final ArchiverException ioe) {
        throw new MojoExecutionException("Unable to attach configuration.", ioe);
    }
}
Also used : BundleListXpp3Writer(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.io.xpp3.BundleListXpp3Writer) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) BundleListUtils.readBundleList(org.apache.sling.maven.projectsupport.BundleListUtils.readBundleList) BundleList(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) FileWriter(java.io.FileWriter) MojoFailureException(org.apache.maven.plugin.MojoFailureException) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) IOException(java.io.IOException)

Aggregations

FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 BundleListUtils.readBundleList (org.apache.sling.maven.projectsupport.BundleListUtils.readBundleList)1 BundleList (org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList)1 BundleListXpp3Writer (org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.io.xpp3.BundleListXpp3Writer)1 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)1 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)1