jvanzyl 2004/05/21 16:49:43
Modified: maven-plugin/src/main/java/org/apache/maven/plugin/generator
PluginDescriptorGenerator.java
Added: maven-plugin/src/main/java/org/apache/maven/plugin
BeanPluginAdapter.java PluginTestCase.java
maven-plugin/src/test/java/org/apache/maven/plugin Bean.java
BeanTest.java TestPlugin.java TestPluginTest.java
Removed: maven-plugin/src/test/java/org/apache/maven/plugin
IntegratedPlugin.java IntegratedPluginTest.java
Log:
o making a base class that will be used to adapt maven2 plugins into setter
type beans for use in Jelly for maven1 use and Ant.
Revision Changes Path
1.1
maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/BeanPluginAdapter.java
Index: BeanPluginAdapter.java
===================================================================
package org.apache.maven.plugin;
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:[EMAIL PROTECTED]">Jason van Zyl</a>
* @version $Id: BeanPluginAdapter.java,v 1.1 2004/05/21 23:49:43 jvanzyl Exp $
*/
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;
}
}
1.1
maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/PluginTestCase.java
Index: PluginTestCase.java
===================================================================
package org.apache.maven.plugin;
import junit.framework.TestCase;
import java.util.Map;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @version $Id: PluginTestCase.java,v 1.1 2004/05/21 23:49:43 jvanzyl Exp $
*/
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 abstract void setupPlugin()
throws Exception;
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();
}
}
1.3 +0 -4
maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/generator/PluginDescriptorGenerator.java
Index: PluginDescriptorGenerator.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/generator/PluginDescriptorGenerator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PluginDescriptorGenerator.java 20 May 2004 16:59:45 -0000 1.2
+++ PluginDescriptorGenerator.java 21 May 2004 23:49:43 -0000 1.3
@@ -5,8 +5,6 @@
import org.apache.maven.plugin.descriptor.Goal;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.plugin.descriptor.Goal;
-import org.apache.maven.plugin.descriptor.Parameter;
import java.io.File;
import java.io.FileWriter;
@@ -156,8 +154,6 @@
//
----------------------------------------------------------------------
List goalPrereqs = goal.getPrereqs();
-
- System.out.println( "goalPrereqs.size() = " + goalPrereqs.size() );
if ( goalPrereqs.size() > 0 )
{
1.1
maven-components/maven-plugin/src/test/java/org/apache/maven/plugin/Bean.java
Index: Bean.java
===================================================================
package org.apache.maven.plugin;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @version $Id: Bean.java,v 1.1 2004/05/21 23:49:43 jvanzyl Exp $
*/
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();
}
}
1.1
maven-components/maven-plugin/src/test/java/org/apache/maven/plugin/BeanTest.java
Index: BeanTest.java
===================================================================
package org.apache.maven.plugin;
import junit.framework.TestCase;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @version $Id: BeanTest.java,v 1.1 2004/05/21 23:49:43 jvanzyl Exp $
*/
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() );
}
}
1.1
maven-components/maven-plugin/src/test/java/org/apache/maven/plugin/TestPlugin.java
Index: TestPlugin.java
===================================================================
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:[EMAIL PROTECTED]">Jason van Zyl</a>
*
* @version $Id: TestPlugin.java,v 1.1 2004/05/21 23:49:43 jvanzyl Exp $
*/
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;
}
}
1.1
maven-components/maven-plugin/src/test/java/org/apache/maven/plugin/TestPluginTest.java
Index: TestPluginTest.java
===================================================================
package org.apache.maven.plugin;
import junit.framework.TestCase;
import java.util.Map;
import java.util.HashMap;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @version $Id: TestPluginTest.java,v 1.1 2004/05/21 23:49:43 jvanzyl Exp $
*/
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() );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]