org.apache.geronimo.genesis.plugins.maven.InvokeMavenMojo Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.apache.geronimo.genesis.plugins.maven;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.Iterator;
import org.apache.geronimo.genesis.MojoSupport;
import org.apache.geronimo.genesis.ant.AntHelper;
import org.apache.maven.project.MavenProject;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.util.Os;
import org.codehaus.plexus.util.DirectoryScanner;
import org.apache.tools.ant.taskdefs.ExecTask;
/**
* Invoke Maven in a sub-process.
*
* @goal invoke
*
* @version $Rev: 479786 $ $Date: 2006-11-27 14:23:36 -0800 (Mon, 27 Nov 2006) $
*/
public class InvokeMavenMojo
extends MojoSupport
{
/**
* Defines the set of pom.xml files to invoke.
*
* @parameter
* @required
*/
private DirectoryScanner fileset = null;
/**
* A set of command-line flags to pass to Maven.
*
* @parameter
*/
private String[] flags = null;
/**
* A map of parameters to define via -D
*
* @parameter
*/
private Map parameters = null;
/**
* A set of profiles to activate via -P
*
* @parameter
*/
private String[] profiles = null;
/**
* A set of goals (or phases) to be invoked.
*
* @parameter
*/
private String[] goals = null;
/**
* @component
*/
protected AntHelper ant;
//
// MojoSupport Hooks
//
/**
* The maven project.
*
* @parameter expression="${project}"
* @required
* @readonly
*/
protected MavenProject project = null;
protected MavenProject getProject() {
return project;
}
protected void init() throws MojoExecutionException, MojoFailureException {
super.init();
ant.setProject(getProject());
}
protected void doExecute() throws Exception {
fileset.addDefaultExcludes();
fileset.scan();
String[] filenames = fileset.getIncludedFiles();
if (filenames.length == 0) {
throw new MojoExecutionException("At least one pom file must be included");
}
for (int i=0; i © 2015 - 2025 Weber Informatics LLC | Privacy Policy