Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2009 Progress Software, Inc. http://fusesource.com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.fusesource.mvnplugins.provision;
 
 
 import java.io.File;
 import java.util.List;

A Maven Mojo to install a provision in the local repo if its not already there and then provision an artifact into an output directory

Author(s):
James Strachan
Goal:
provision
Execute:
phase="install"
 
 public class ProvisionMojo extends AbstractMojo {

    
The directory where the output files will be located.

Parameter:
expression="${outputDirectory}
Required:
 
     private File outputDirectory;


    
The maven project.

Parameter:
expression="${project}"
Required:
Readonly:
 
     protected MavenProject project;
 
 
     public void execute() throws MojoExecutionExceptionMojoFailureException {
         if ("pom".equals(.getPackaging())) {
             getLog().debug("Ignoring pom packaging");
             return;
         }
         Build build = .getBuild();
         if (build == null) {
             getLog().debug("No Build available in this Project");
             return;
         }
         File file = new File(build.getDirectory(), build.getFinalName() + "." + getArtifactExtension());
         getLog().debug("Trying to detect: " + file.getAbsolutePath());
 
         if (file.exists()) {
             File destFile = new File(file.getName());
             try {
                 getLog().info("Copying "
                         + file.getName() + " to "
                         + destFile);
                 FileUtils.copyFile(filedestFile);
 
             } catch (Exception e) {
                 throw new MojoExecutionException("Error copying artifact from " + file + " to " + destFilee);
             }
         } else {
             getLog().info("Artifact does not exist so cannot be provisioned: " + file.getPath());
         }
     }
 
     private String getArtifactExtension() {
         String packaging = .getPackaging();
         if ("bundle".equals(packaging)) {
             return "jar";
         } else {
            return packaging;
        }
    }
New to GrepCode? Check out our FAQ X