o Extended mojo to allow checking injected Plexus components

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@705864 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2008-10-18 09:22:46 +00:00
parent f2b69026a5
commit 3afaffd185
1 changed files with 39 additions and 13 deletions

View File

@ -28,6 +28,8 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@ -68,6 +70,13 @@ public class InstanceofMojo
*/
private String[] objectExpressions;
/**
* A list of injected component instances that should be type-checked.
*
* @component role="org.apache.maven.plugin.coreit.Component"
*/
private List components;
/**
* The current Maven project against which expressions are evaluated.
*
@ -98,6 +107,8 @@ public class InstanceofMojo
Properties instanceofProperties = new Properties();
if ( objectExpressions != null && objectExpressions.length > 0 )
{
Map contexts = new HashMap();
contexts.put( "project", project );
contexts.put( "pom", project );
@ -110,11 +121,26 @@ public class InstanceofMojo
getLog().info( "[MAVEN-CORE-IT-LOG] Checking object " + object );
if ( object != null )
{
getLog().info( "[MAVEN-CORE-IT-LOG] Loaded object from " + object.getClass().getClassLoader() );
getLog().info( "[MAVEN-CORE-IT-LOG] Loaded class " + object.getClass().getName() );
getLog().info( "[MAVEN-CORE-IT-LOG] Loaded class from " + object.getClass().getClassLoader() );
}
instanceofProperties.setProperty( expression.replace( '/', '.' ),
Boolean.toString( type.isInstance( object ) ) );
}
}
if ( components != null && !components.isEmpty() )
{
for ( Iterator it = components.iterator(); it.hasNext(); )
{
Object object = it.next();
getLog().info( "[MAVEN-CORE-IT-LOG] Checking component " + object );
getLog().info( "[MAVEN-CORE-IT-LOG] Loaded class " + object.getClass().getName() );
getLog().info( "[MAVEN-CORE-IT-LOG] Loaded class from " + object.getClass().getClassLoader() );
instanceofProperties.setProperty( object.getClass().getName(),
Boolean.toString( type.isInstance( object ) ) );
}
}
getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file " + instanceofPropertiesFile );