mirror of https://github.com/apache/maven.git
convert plugin plugin to new execute()
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163664 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c5d7cd804c
commit
1e121e8d1a
|
@ -1,8 +1,23 @@
|
||||||
package org.apache.maven.plugin.plugin;
|
package org.apache.maven.plugin.plugin;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
import org.apache.maven.plugin.AbstractPlugin;
|
import org.apache.maven.plugin.AbstractPlugin;
|
||||||
import org.apache.maven.plugin.PluginExecutionRequest;
|
import org.apache.maven.plugin.PluginExecutionException;
|
||||||
import org.apache.maven.plugin.PluginExecutionResponse;
|
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.tools.plugin.scanner.MojoScanner;
|
import org.apache.maven.tools.plugin.scanner.MojoScanner;
|
||||||
|
|
||||||
|
@ -15,28 +30,28 @@ import java.util.Set;
|
||||||
public abstract class AbstractGeneratorMojo
|
public abstract class AbstractGeneratorMojo
|
||||||
extends AbstractPlugin
|
extends AbstractPlugin
|
||||||
{
|
{
|
||||||
|
protected String outputDirectory;
|
||||||
|
|
||||||
|
protected MavenProject project;
|
||||||
|
|
||||||
|
protected MojoScanner mojoScanner;
|
||||||
|
|
||||||
protected abstract void generate( String outputDirectory, Set mavenMojoDescriptors, MavenProject project )
|
protected abstract void generate( String outputDirectory, Set mavenMojoDescriptors, MavenProject project )
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
|
public void execute()
|
||||||
throws Exception
|
throws PluginExecutionException
|
||||||
{
|
{
|
||||||
// ----------------------------------------------------------------------
|
try
|
||||||
//
|
{
|
||||||
// ----------------------------------------------------------------------
|
Set mavenMojoDescriptors = mojoScanner.execute( project );
|
||||||
|
|
||||||
String outputDirectory = (String) request.getParameter( "outputDirectory" );
|
generate( outputDirectory, mavenMojoDescriptors, project );
|
||||||
|
}
|
||||||
MavenProject project = (MavenProject)request.getParameter( "project" );
|
catch ( Exception e )
|
||||||
|
{
|
||||||
MojoScanner scanner = (MojoScanner)request.getParameter("mojoScanner");
|
// TODO: improve error handling
|
||||||
|
throw new PluginExecutionException( "Error generating plugin descriptor", e );
|
||||||
Set mavenMojoDescriptors = scanner.execute(project);
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
generate( outputDirectory, mavenMojoDescriptors, project );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
package org.apache.maven.plugin.plugin;
|
|
||||||
|
|
||||||
import org.apache.maven.plugin.AbstractPlugin;
|
|
||||||
import org.apache.maven.plugin.PluginExecutionRequest;
|
|
||||||
import org.apache.maven.plugin.PluginExecutionResponse;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public abstract class AbstractPluginMojo
|
|
||||||
extends AbstractPlugin
|
|
||||||
{
|
|
||||||
|
|
||||||
protected File getJarFile( PluginExecutionRequest request )
|
|
||||||
{
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
String outputDirectory = (String) request.getParameter( "outputDirectory" );
|
|
||||||
|
|
||||||
String jarName = (String) request.getParameter( "jarName" );
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
File jarFile = new File( new File( outputDirectory ), jarName + ".jar" );
|
|
||||||
|
|
||||||
return jarFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,39 +1,49 @@
|
||||||
package org.apache.maven.plugin.plugin;
|
package org.apache.maven.plugin.plugin;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.tools.plugin.generator.BeanGenerator;
|
import org.apache.maven.tools.plugin.generator.BeanGenerator;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @goal bean
|
|
||||||
*
|
|
||||||
* @description Goal for generating a plugin descriptor.
|
|
||||||
*
|
|
||||||
* @parameter
|
|
||||||
* name="mojoScanner"
|
|
||||||
* type="org.apache.maven.tools.plugin.scanner.MojoScanner"
|
|
||||||
* required="true"
|
|
||||||
* validator=""
|
|
||||||
* expression="#component.org.apache.maven.tools.plugin.scanner.MojoScanner"
|
|
||||||
* description="Scanner used to discover mojo descriptors from this project"
|
|
||||||
* @parameter
|
|
||||||
* name="project"
|
|
||||||
* type="org.apache.maven.project.MavenProject"
|
|
||||||
* required="true"
|
|
||||||
* validator=""
|
|
||||||
* expression="#project"
|
|
||||||
* description=""
|
|
||||||
* @parameter
|
|
||||||
* name="outputDirectory"
|
|
||||||
* type="String"
|
|
||||||
* required="true"
|
|
||||||
* validator=""
|
|
||||||
* expression="#project.build.directory/generated-sources"
|
|
||||||
* description=""
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
* @goal bean
|
||||||
|
* @description Goal for generating a plugin descriptor.
|
||||||
|
* @parameter name="mojoScanner"
|
||||||
|
* type="org.apache.maven.tools.plugin.scanner.MojoScanner"
|
||||||
|
* required="true"
|
||||||
|
* validator=""
|
||||||
|
* expression="#component.org.apache.maven.tools.plugin.scanner.MojoScanner"
|
||||||
|
* description="Scanner used to discover mojo descriptors from this project"
|
||||||
|
* @parameter name="project"
|
||||||
|
* type="org.apache.maven.project.MavenProject"
|
||||||
|
* required="true"
|
||||||
|
* validator=""
|
||||||
|
* expression="#project"
|
||||||
|
* description=""
|
||||||
|
* @parameter name="outputDirectory"
|
||||||
|
* type="String"
|
||||||
|
* required="true"
|
||||||
|
* validator=""
|
||||||
|
* expression="#project.build.directory/generated-sources"
|
||||||
|
* description=""
|
||||||
*/
|
*/
|
||||||
public class BeanGeneratorMojo
|
public class BeanGeneratorMojo
|
||||||
extends AbstractGeneratorMojo
|
extends AbstractGeneratorMojo
|
||||||
|
|
|
@ -1,5 +1,21 @@
|
||||||
package org.apache.maven.plugin.plugin;
|
package org.apache.maven.plugin.plugin;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator;
|
import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator;
|
||||||
|
|
||||||
|
|
|
@ -1,40 +1,49 @@
|
||||||
package org.apache.maven.plugin.plugin;
|
package org.apache.maven.plugin.plugin;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.tools.plugin.generator.jelly.JellyHarnessGenerator;
|
import org.apache.maven.tools.plugin.generator.jelly.JellyHarnessGenerator;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @goal jelly
|
|
||||||
*
|
|
||||||
* @description Goal for generating a plugin descriptor.
|
|
||||||
*
|
|
||||||
* @parameter
|
|
||||||
* name="mojoScanner"
|
|
||||||
* type="org.apache.maven.tools.plugin.scanner.MojoScanner"
|
|
||||||
* required="true"
|
|
||||||
* validator=""
|
|
||||||
* expression="#component.org.apache.maven.tools.plugin.scanner.MojoScanner"
|
|
||||||
* description="Scanner used to discover mojo descriptors from this project"
|
|
||||||
* @parameter
|
|
||||||
* name="project"
|
|
||||||
* type="org.apache.maven.project.MavenProject"
|
|
||||||
* required="true"
|
|
||||||
* validator=""
|
|
||||||
* expression="#project"
|
|
||||||
* description=""
|
|
||||||
* @parameter
|
|
||||||
* name="outputDirectory"
|
|
||||||
* type="String"
|
|
||||||
* required="true"
|
|
||||||
* validator=""
|
|
||||||
* expression="#project.build.directory/generated-sources"
|
|
||||||
* description=""
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
* @goal jelly
|
||||||
|
* @description Goal for generating a plugin descriptor.
|
||||||
|
* @parameter name="mojoScanner"
|
||||||
|
* type="org.apache.maven.tools.plugin.scanner.MojoScanner"
|
||||||
|
* required="true"
|
||||||
|
* validator=""
|
||||||
|
* expression="#component.org.apache.maven.tools.plugin.scanner.MojoScanner"
|
||||||
|
* description="Scanner used to discover mojo descriptors from this project"
|
||||||
|
* @parameter name="project"
|
||||||
|
* type="org.apache.maven.project.MavenProject"
|
||||||
|
* required="true"
|
||||||
|
* validator=""
|
||||||
|
* expression="#project"
|
||||||
|
* description=""
|
||||||
|
* @parameter name="outputDirectory"
|
||||||
|
* type="String"
|
||||||
|
* required="true"
|
||||||
|
* validator=""
|
||||||
|
* expression="#project.build.directory/generated-sources"
|
||||||
|
* description=""
|
||||||
*/
|
*/
|
||||||
public class JellyGeneratorMojo
|
public class JellyGeneratorMojo
|
||||||
extends AbstractGeneratorMojo
|
extends AbstractGeneratorMojo
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
package org.apache.maven.plugin.plugin;
|
|
||||||
|
|
||||||
import org.apache.maven.plugin.FailureResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class PluginFailureResponse
|
|
||||||
extends FailureResponse
|
|
||||||
{
|
|
||||||
private String LS = System.getProperty( "line.separator" );
|
|
||||||
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
public PluginFailureResponse( Object o )
|
|
||||||
{
|
|
||||||
super( o );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String shortMessage()
|
|
||||||
{
|
|
||||||
return (String) source;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String longMessage()
|
|
||||||
{
|
|
||||||
return shortMessage();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue