mirror of https://github.com/apache/maven.git
Initial revision
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162921 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c4719462e4
commit
45da0a70c0
|
@ -0,0 +1,6 @@
|
|||
*~
|
||||
*.log
|
||||
target
|
||||
*.ipr
|
||||
*.iws
|
||||
*.iml
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-component</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-plugin</artifactId>
|
||||
<name>Maven Plugin</name>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>qdox</groupId>
|
||||
<artifactId>qdox</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>modello</groupId>
|
||||
<artifactId>modello</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,4 @@
|
|||
maven.log
|
||||
target
|
||||
.classpath
|
||||
.project
|
|
@ -0,0 +1,22 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.
|
||||
*/
|
||||
|
||||
public abstract class AbstractPlugin
|
||||
implements Plugin
|
||||
{
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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 java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Adapt a maven2 plugin for use as a bean with setters that can be used
|
||||
* within Jelly and Ant.
|
||||
*
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class BeanPluginAdapter
|
||||
{
|
||||
private Map parameters;
|
||||
|
||||
private Plugin plugin;
|
||||
|
||||
public BeanPluginAdapter( Plugin plugin )
|
||||
{
|
||||
this.plugin = plugin;
|
||||
|
||||
parameters = new HashMap();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public void execute()
|
||||
throws Exception
|
||||
{
|
||||
PluginExecutionRequest request = new PluginExecutionRequest( parameters );
|
||||
|
||||
PluginExecutionResponse response = new PluginExecutionResponse();
|
||||
|
||||
plugin.execute( request, response );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
protected void addParameter( String key, Object value )
|
||||
{
|
||||
parameters.put( key, value );
|
||||
}
|
||||
|
||||
protected Plugin getPlugin()
|
||||
{
|
||||
return plugin;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class FailureResponse
|
||||
{
|
||||
protected Object source;
|
||||
|
||||
protected FailureResponse( Object source )
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public abstract String shortMessage();
|
||||
|
||||
public abstract String longMessage();
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface Plugin
|
||||
{
|
||||
String ROLE = Plugin.class.getName();
|
||||
|
||||
void execute( PluginExecutionRequest request, PluginExecutionResponse response )
|
||||
throws Exception;
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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 java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PluginExecutionRequest
|
||||
{
|
||||
private Map parameters;
|
||||
|
||||
private Map context;
|
||||
|
||||
public PluginExecutionRequest( Map parameters )
|
||||
{
|
||||
context = new HashMap();
|
||||
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public Map getParameters()
|
||||
{
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters( Map parameters )
|
||||
{
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public Object getParameter( String key )
|
||||
{
|
||||
return parameters.get( key );
|
||||
}
|
||||
|
||||
public void addContextValue( Object key, Object value )
|
||||
{
|
||||
context.put( key, value );
|
||||
}
|
||||
|
||||
public Object getContextValue( String key )
|
||||
{
|
||||
return context.get( key );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PluginExecutionResponse
|
||||
{
|
||||
private boolean executionFailure;
|
||||
|
||||
private FailureResponse failureResponse;
|
||||
|
||||
public boolean isExecutionFailure()
|
||||
{
|
||||
return executionFailure;
|
||||
}
|
||||
|
||||
public void setExecutionFailure( boolean executionFailure, FailureResponse failureResponse )
|
||||
{
|
||||
this.executionFailure = executionFailure;
|
||||
|
||||
this.failureResponse = failureResponse;
|
||||
}
|
||||
|
||||
public FailureResponse getFailureResponse()
|
||||
{
|
||||
return failureResponse;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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 junit.framework.TestCase;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class PluginTestCase
|
||||
extends TestCase
|
||||
{
|
||||
protected Plugin plugin;
|
||||
|
||||
protected PluginExecutionRequest request;
|
||||
|
||||
protected PluginExecutionResponse response;
|
||||
|
||||
protected String basedir;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
protected PluginTestCase( String s )
|
||||
{
|
||||
super( s );
|
||||
}
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
basedir = System.getProperty( "basedir" );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
protected void setupPlugin()
|
||||
throws Exception
|
||||
{
|
||||
String mojoClassName = getClass().getName();
|
||||
|
||||
mojoClassName = mojoClassName.substring( 0, mojoClassName.length() - 4 );
|
||||
|
||||
try
|
||||
{
|
||||
Class mojoClass = Thread.currentThread().getContextClassLoader().loadClass( mojoClassName );
|
||||
|
||||
plugin = (Plugin) mojoClass.newInstance();
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
throw new Exception(
|
||||
"Cannot find " + mojoClassName + "! Make sure your test case is named in the form ${mojoClassName}Test " +
|
||||
"or override the setupPlugin() method to instantiate the mojo yourself." );
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Map getTestParameters()
|
||||
throws Exception;
|
||||
|
||||
protected abstract void validatePluginExecution()
|
||||
throws Exception;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public void testPlugin()
|
||||
throws Exception
|
||||
{
|
||||
setupPlugin();
|
||||
|
||||
request = new PluginExecutionRequest( getTestParameters() );
|
||||
|
||||
response = new PluginExecutionResponse();
|
||||
|
||||
plugin.execute( request, response );
|
||||
|
||||
validatePluginExecution();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package org.apache.maven.plugin.descriptor;
|
||||
|
||||
/*
|
||||
* LICENSE
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Dependency
|
||||
{
|
||||
private String groupId;
|
||||
|
||||
private String artifactId;
|
||||
|
||||
private String type;
|
||||
|
||||
private String version;
|
||||
|
||||
public String getGroupId()
|
||||
{
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId( String groupId )
|
||||
{
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public String getArtifactId()
|
||||
{
|
||||
return artifactId;
|
||||
}
|
||||
|
||||
public void setArtifactId( String artifactId )
|
||||
{
|
||||
this.artifactId = artifactId;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType( String type )
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion( String version )
|
||||
{
|
||||
this.version = version;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,215 @@
|
|||
package org.apache.maven.plugin.descriptor;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.descriptor.Parameter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MojoDescriptor
|
||||
implements Cloneable
|
||||
{
|
||||
public static final String SINGLE_PASS_EXEC_STRATEGY = "once-per-session";
|
||||
|
||||
public static final String MULTI_PASS_EXEC_STRATEGY = "always";
|
||||
|
||||
private String implementation;
|
||||
|
||||
private String description;
|
||||
|
||||
private String id;
|
||||
|
||||
private List parameters;
|
||||
|
||||
private Map parameterMap;
|
||||
|
||||
private String instantiationStrategy = "singleton";
|
||||
|
||||
private String executionStrategy = SINGLE_PASS_EXEC_STRATEGY;
|
||||
|
||||
private String goal;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
private List prereqs;
|
||||
|
||||
private boolean requiresDependencyResolution = false;
|
||||
|
||||
private boolean requiresProject = true;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public String getRole()
|
||||
{
|
||||
return "org.apache.maven.plugin.Plugin";
|
||||
}
|
||||
|
||||
public String getImplementation()
|
||||
{
|
||||
return implementation;
|
||||
}
|
||||
|
||||
public void setImplementation( String implementation )
|
||||
{
|
||||
this.implementation = implementation;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription( String description )
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getInstantiationStrategy()
|
||||
{
|
||||
return instantiationStrategy;
|
||||
}
|
||||
|
||||
public void setInstantiationStrategy( String instantiationStrategy )
|
||||
{
|
||||
this.instantiationStrategy = instantiationStrategy;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId( String id )
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List getParameters()
|
||||
{
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters( List parameters )
|
||||
{
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public Map getParameterMap()
|
||||
{
|
||||
if ( parameterMap == null )
|
||||
{
|
||||
parameterMap = new HashMap();
|
||||
|
||||
for ( Iterator iterator = parameters.iterator(); iterator.hasNext(); )
|
||||
{
|
||||
Parameter pd = (Parameter) iterator.next();
|
||||
|
||||
parameterMap.put( pd.getName(), pd );
|
||||
}
|
||||
}
|
||||
|
||||
return parameterMap;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Dependency requirement
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public void setRequiresDependencyResolution( boolean requiresDependencyResolution )
|
||||
{
|
||||
this.requiresDependencyResolution = requiresDependencyResolution;
|
||||
}
|
||||
|
||||
public boolean requiresDependencyResolution()
|
||||
{
|
||||
return requiresDependencyResolution;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Project requirement
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public void setRequiresProject( boolean requiresProject )
|
||||
{
|
||||
this.requiresProject = requiresProject;
|
||||
}
|
||||
|
||||
public boolean requiresProject()
|
||||
{
|
||||
return requiresProject;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Prereqs
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public List getPrereqs()
|
||||
{
|
||||
return prereqs;
|
||||
}
|
||||
|
||||
public void setPrereqs( List prereqs )
|
||||
{
|
||||
this.prereqs = prereqs;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public String getGoal()
|
||||
{
|
||||
return goal;
|
||||
}
|
||||
|
||||
public void setGoal( String goal )
|
||||
{
|
||||
this.goal = goal;
|
||||
}
|
||||
|
||||
public boolean alwaysExecute() {
|
||||
return MULTI_PASS_EXEC_STRATEGY.equals(executionStrategy);
|
||||
}
|
||||
|
||||
public String getExecutionStrategy() {
|
||||
return executionStrategy;
|
||||
}
|
||||
|
||||
public void setExecutionStrategy(String executionStrategy) {
|
||||
this.executionStrategy = executionStrategy;
|
||||
}
|
||||
|
||||
public MojoDescriptor copy()
|
||||
{
|
||||
try
|
||||
{
|
||||
return (MojoDescriptor) this.clone();
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package org.apache.maven.plugin.descriptor;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Parameter
|
||||
{
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
|
||||
private boolean required;
|
||||
|
||||
private String validator;
|
||||
|
||||
private String description;
|
||||
|
||||
private String expression;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName( String name )
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType( String type )
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean isRequired()
|
||||
{
|
||||
return required;
|
||||
}
|
||||
|
||||
public void setRequired( boolean required )
|
||||
{
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public String getValidator()
|
||||
{
|
||||
return validator;
|
||||
}
|
||||
|
||||
public void setValidator( String validator )
|
||||
{
|
||||
this.validator = validator;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription( String description )
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getExpression()
|
||||
{
|
||||
return expression;
|
||||
}
|
||||
|
||||
public void setExpression( String expression )
|
||||
{
|
||||
this.expression = expression;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package org.apache.maven.plugin.descriptor;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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 java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PluginDescriptor
|
||||
{
|
||||
private List mojos;
|
||||
|
||||
private String id;
|
||||
|
||||
private List dependencies;
|
||||
|
||||
private boolean isolatedRealm;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public List getMojos()
|
||||
{
|
||||
return mojos;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId( String id )
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Dependencies
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public List getDependencies()
|
||||
{
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
public boolean isIsolatedRealm()
|
||||
{
|
||||
return isolatedRealm;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package org.apache.maven.plugin.descriptor;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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 com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.alias.DefaultClassMapper;
|
||||
import com.thoughtworks.xstream.alias.DefaultNameMapper;
|
||||
import com.thoughtworks.xstream.objecttree.reflection.JavaReflectionObjectFactory;
|
||||
import com.thoughtworks.xstream.xml.xpp3.Xpp3DomBuilder;
|
||||
import com.thoughtworks.xstream.xml.xpp3.Xpp3DomXMLReader;
|
||||
import com.thoughtworks.xstream.xml.xpp3.Xpp3DomXMLReaderDriver;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PluginDescriptorBuilder
|
||||
{
|
||||
private XStream xstream;
|
||||
|
||||
public PluginDescriptorBuilder()
|
||||
{
|
||||
xstream = new XStream( new JavaReflectionObjectFactory(),
|
||||
new DefaultClassMapper( new DefaultNameMapper() ),
|
||||
new Xpp3DomXMLReaderDriver(),
|
||||
"implementation" );
|
||||
|
||||
xstream.alias( "plugin", PluginDescriptor.class );
|
||||
|
||||
xstream.alias( "mojo", MojoDescriptor.class );
|
||||
|
||||
xstream.alias( "prereq", String.class );
|
||||
|
||||
xstream.alias( "parameter", Parameter.class );
|
||||
|
||||
xstream.alias( "dependency", Dependency.class );
|
||||
}
|
||||
|
||||
public PluginDescriptor build( Reader reader )
|
||||
throws Exception
|
||||
{
|
||||
return (PluginDescriptor) xstream.fromXML( new Xpp3DomXMLReader( Xpp3DomBuilder.build( reader ) ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Bean
|
||||
extends BeanPluginAdapter
|
||||
{
|
||||
public Bean()
|
||||
{
|
||||
super( new TestPlugin() );
|
||||
}
|
||||
|
||||
public void setName( String name )
|
||||
{
|
||||
addParameter( "name", name );
|
||||
}
|
||||
|
||||
public void setArtifactId( String artifactId )
|
||||
{
|
||||
addParameter( "artifactId", artifactId );
|
||||
}
|
||||
|
||||
public void setFoo( String foo )
|
||||
{
|
||||
addParameter( "foo", foo );
|
||||
}
|
||||
|
||||
public boolean hasExecuted()
|
||||
{
|
||||
return ((TestPlugin)getPlugin()).hasExecuted();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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 junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class BeanTest
|
||||
extends TestCase
|
||||
{
|
||||
public void testBean()
|
||||
throws Exception
|
||||
{
|
||||
Bean bean = new Bean();
|
||||
|
||||
bean.setName( "jason" );
|
||||
|
||||
bean.setArtifactId( "artifactId" );
|
||||
|
||||
bean.setFoo( "bar" );
|
||||
|
||||
bean.execute();
|
||||
|
||||
assertTrue( bean.hasExecuted() );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class TestPlugin
|
||||
implements Plugin
|
||||
{
|
||||
protected boolean executed;
|
||||
|
||||
protected String name;
|
||||
|
||||
protected String artifactId;
|
||||
|
||||
protected String foo;
|
||||
|
||||
public boolean hasExecuted()
|
||||
{
|
||||
return executed;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getArtifactId()
|
||||
{
|
||||
return artifactId;
|
||||
}
|
||||
|
||||
public String getFoo()
|
||||
{
|
||||
return foo;
|
||||
}
|
||||
|
||||
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
|
||||
throws Exception
|
||||
{
|
||||
name = (String) request.getParameter( "name" );
|
||||
|
||||
artifactId = (String) request.getParameter( "artifactId" );
|
||||
|
||||
foo = (String) request.getParameter( "foo" );
|
||||
|
||||
executed = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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 junit.framework.TestCase;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class TestPluginTest
|
||||
extends TestCase
|
||||
{
|
||||
public void testIntegratedPluginExecution()
|
||||
throws Exception
|
||||
{
|
||||
TestPlugin plugin = new TestPlugin();
|
||||
|
||||
Map parameters = new HashMap();
|
||||
|
||||
parameters.put( "name", "Maven" );
|
||||
|
||||
parameters.put( "artifactId", "maven-core" );
|
||||
|
||||
parameters.put( "foo", "bar" );
|
||||
|
||||
PluginExecutionRequest request = new PluginExecutionRequest( parameters );
|
||||
|
||||
PluginExecutionResponse response = new PluginExecutionResponse();
|
||||
|
||||
plugin.execute( request, response );
|
||||
|
||||
assertTrue( plugin.hasExecuted() );
|
||||
|
||||
assertEquals( "Maven", plugin.getName() );
|
||||
|
||||
assertEquals( "maven-core", plugin.getArtifactId() );
|
||||
|
||||
assertEquals( "bar", plugin.getFoo() );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue