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;


    

Component:
Readonly:
 
     private ArtifactFactory artifactFactory;

    

Component:
Readonly:
 
     private ArtifactResolver artifactResolver;


    

Parameter:
expression="${localRepository}"
Readonly:
 
     private ArtifactRepository localRepository;

    
Whether to run the "chmod" command on the remote site after the deploy. Defaults to "true".

Since:
2.1
Parameter:
expression="${maven.updatesite.chmod}" default-value="true"
 
     private boolean chmod;

    
The mode used by the "chmod" command. Only used if chmod = true. Defaults to "g+w,a+rX".

Since:
2.1
Parameter:
expression="${maven.updatesite.chmod.mode}" default-value="g+w,a+rX"
 
     private String chmodMode;

    
The Server ID used to deploy the site which should reference a <server> in your ~/.m2/settings.xml file for username/pwd

Parameter:
expression="${updatesite.remoteServerId}"
    private String remoteServerId;

    
The Server Server URL to deploy the site to which uses the same URL format as the distributionManagement / site / url expression in the pom.xml

Parameter:
expression="${updatesite.remoteServerUrl}"
    private String remoteServerUrl;

    
The directory used to put the update site in. Defaults to "update".

If you use the htacess generation then this directory is used as part of the redirects

Parameter:
default-value="update"
    private String remoteDirectory;


    
The options used by the "chmod" command. Only used if chmod = true. Defaults to "-Rf".

Since:
2.1
Parameter:
expression="${maven.updatesite.chmod.options}" default-value="-Rf"
    private String chmodOptions;

    
The options used by the "mv" command to move the current update site out of the way Defaults to "".

Since:
2.1
Parameter:
expression="${maven.updatesite.mv.options}" default-value=""
    private String mvOptions;

    
The date format to use for old build directories

Parameter:
expression="${maven.updatesite.oldBuild.dateFormat}" default-value="yyyy-MM-dd-HH-mm-ss-SSS"
    private String oldBuildDateFormat = "yyyy-MM-dd-HH-mm-ss-SSS";


    

Component:
    private WagonManager wagonManager;

    
The current user system settings for use in Maven.

Parameter:
expression="${settings}"
Required:
Readonly:
    private Settings settings;
    public void execute() throws MojoExecutionExceptionMojoFailureException {
        if (.exists()) {
            if (.isFile()) {
                throw new MojoExecutionException("Output directory is a file: " + );
            }
        } else {
            .mkdirs();
            if (!.exists() || !.isDirectory()) {
                throw new MojoExecutionException("Failed to create output directory: " + );
            }
        }
        Artifact a = .getArtifact();
        String groupId = a.getGroupId();
        String artifactId = a.getArtifactId();
        String version = a.getVersion();
        String packaging = a.getType();
        getLog().debug("Attempting to resolve: " + groupId + ":" + artifactId + ":" + version + ":" + packaging);
        Artifact toDownload = .createBuildArtifact(groupIdartifactIdversionpackaging);
        List remoteArtifactRepositories = .getRemoteArtifactRepositories();
        try {
            .resolve(toDownloadremoteArtifactRepositories);
        } catch (AbstractArtifactResolutionException e) {
            throw new MojoExecutionException("Couldn't download artifact: " + e.getMessage(), e);
        }
        File file = toDownload.getFile();
        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);
        }
    }
New to GrepCode? Check out our FAQ X