Save This Page
Home » maven-launchpad-plugin-2.0.6-source-release » org.apache.sling.maven.projectsupport » [javadoc | source]
    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.sling.maven.projectsupport;
   18   
   19   import java.io.File;
   20   import java.io.FileWriter;
   21   import java.io.IOException;
   22   
   23   import org.apache.maven.plugin.MojoExecutionException;
   24   import org.apache.maven.plugin.MojoFailureException;
   25   import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.io.xpp3.BundleListXpp3Writer;
   26   
   27   /**
   28    * Attaches the bundle list as a project artifact.
   29    *
   30    * @goal attach-bundle-list
   31    * @phase package
   32    * @description attach the bundle list as a project artifact
   33    */
   34   public class AttachBundleListMojo extends AbstractBundleListMojo {
   35   
   36       private static final String CLASSIFIER = "bundlelist";
   37   
   38       private static final String TYPE = "xml";
   39   
   40       /**
   41        * @parameter default-value="${project.build.directory}/bundleList.xml"
   42        */
   43       private File outputFile;
   44   
   45       private BundleListXpp3Writer writer = new BundleListXpp3Writer();
   46   
   47       @Override
   48       protected void executeWithArtifacts() throws MojoExecutionException, MojoFailureException {
   49           FileWriter fw = null;
   50           try {
   51               fw = new FileWriter(outputFile);
   52               writer.write(fw, getBundleList());
   53               projectHelper.attachArtifact(project, TYPE, CLASSIFIER, outputFile);
   54           } catch (IOException e) {
   55               throw new MojoExecutionException("Unable to output effective bundle list", e);
   56           } finally {
   57               if (fw != null) {
   58                   try {
   59                       fw.close();
   60                   } catch (IOException e) {
   61                   }
   62               }
   63           }
   64       }
   65   
   66   }

Save This Page
Home » maven-launchpad-plugin-2.0.6-source-release » org.apache.sling.maven.projectsupport » [javadoc | source]