You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2006/01/10 04:19:28 UTC
svn commit: r367472 - in
/maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin:
./ src/main/java/org/apache/maven/plugin/coreit/
Author: jdcasey
Date: Mon Jan 9 19:19:23 2006
New Revision: 367472
URL: http://svn.apache.org/viewcvs?rev=367472&view=rev
Log:
Adding classloader testing mojos.
Added:
maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java (with props)
maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/ReachableMojo.java (with props)
maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/RunnableMojo.java (with props)
Modified:
maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/pom.xml
Modified: maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/pom.xml?rev=367472&r1=367471&r2=367472&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/pom.xml (original)
+++ maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/pom.xml Mon Jan 9 19:19:23 2006
@@ -3,7 +3,7 @@
<parent>
<artifactId>maven-plugin-parent</artifactId>
<groupId>org.apache.maven.plugins</groupId>
- <version>2.0-beta-3</version>
+ <version>2.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>maven-core-it-plugin</artifactId>
@@ -31,6 +31,16 @@
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>0.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>bsh</groupId>
+ <artifactId>bsh</artifactId>
+ <version>1.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.6.0</version>
</dependency>
</dependencies>
</model>
Added: maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java?rev=367472&view=auto
==============================================================================
--- maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java (added)
+++ maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java Mon Jan 9 19:19:23 2006
@@ -0,0 +1,59 @@
+package org.apache.maven.plugin.coreit;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * @goal loadable
+ * @requiresDependencyResolution test
+ */
+public class LoadableMojo
+ extends AbstractMojo
+{
+ /**
+ * @parameter
+ * @required
+ */
+ private String className;
+
+ public void execute() throws MojoFailureException
+ {
+ if ( !load( true ) || !load( false ) )
+ {
+ throw new MojoFailureException( this, "Class-loading test failed..", "Failed to load class: " + className + " using one or more methods." );
+ }
+ }
+
+ private boolean load( boolean useContextClassloader ) throws MojoFailureException
+ {
+ getLog().info( "Executing in java version: " + System.getProperty( "java.version" ) );
+
+ ClassLoader cl;
+ if ( useContextClassloader )
+ {
+ cl = Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ cl = this.getClass().getClassLoader();
+ }
+
+ getLog().info( "Attepting to load: " + className + " from: " + cl + (useContextClassloader ? " (context classloader)" : "" ) );
+
+ try
+ {
+ Class result = cl.loadClass( className );
+
+ getLog().info( "Load succeeded." );
+
+ return true;
+ }
+ catch ( ClassNotFoundException e )
+ {
+ getLog().info( "Failed to load class: " + className
+ + (useContextClassloader ? " using context classloader" : "") );
+
+ return false;
+ }
+ }
+}
Propchange: maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/ReachableMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/ReachableMojo.java?rev=367472&view=auto
==============================================================================
--- maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/ReachableMojo.java (added)
+++ maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/ReachableMojo.java Mon Jan 9 19:19:23 2006
@@ -0,0 +1,54 @@
+package org.apache.maven.plugin.coreit;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoFailureException;
+
+import java.net.URL;
+
+/**
+ * @goal reachable
+ * @requiresDependencyResolution test
+ */
+public class ReachableMojo extends AbstractMojo
+{
+ /**
+ * @parameter
+ * @required
+ */
+ private String resource;
+
+ public void execute()
+ throws MojoFailureException
+ {
+ if ( !reach( true ) || !reach( false ) )
+ {
+ throw new MojoFailureException( this, "Resource reachability test failed..", "Failed to reach resource: " + resource + " using one or more methods." );
+ }
+ }
+
+ public boolean reach( boolean useContextClassloader ) throws MojoFailureException
+ {
+ ClassLoader cl;
+ if ( useContextClassloader )
+ {
+ cl = Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ cl = this.getClass().getClassLoader();
+ }
+
+ URL result = cl.getResource( resource );
+
+ getLog().info( "Attepting to reach: " + resource + " from: " + cl + (useContextClassloader ? " (context classloader)" : "" ) + ( result == null ? ": FAILED" : ":SUCCEEDED" ) );
+
+ if ( result == null )
+ {
+ getLog().info( "Cannot find resource: " + resource + (useContextClassloader?" in context classloader":"") );
+
+ return false;
+ }
+
+ return true;
+ }
+}
Propchange: maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/ReachableMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/ReachableMojo.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/RunnableMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/RunnableMojo.java?rev=367472&view=auto
==============================================================================
--- maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/RunnableMojo.java (added)
+++ maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/RunnableMojo.java Mon Jan 9 19:19:23 2006
@@ -0,0 +1,39 @@
+package org.apache.maven.plugin.coreit;
+
+import bsh.EvalError;
+import bsh.Interpreter;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * @goal runnable
+ * @requiresDependencyResolution test
+ */
+public class RunnableMojo
+ extends AbstractMojo
+{
+ /**
+ * @parameter
+ * @required
+ */
+ private String script;
+
+ public void execute() throws MojoExecutionException
+ {
+ Interpreter terp = new Interpreter();
+
+ try
+ {
+ getLog().info( "Executing in java version: " + System.getProperty( "java.version" ) );
+
+ Object result = terp.eval( script );
+
+ getLog().info( "Result of script evaluation was: " + result + "\nLoaded from: " + result.getClass().getClassLoader() );
+ }
+ catch ( EvalError e )
+ {
+ throw new MojoExecutionException( "Failed to evaluate script.", e );
+ }
+ }
+}
Propchange: maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/RunnableMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/branches/maven-2.0.x/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/RunnableMojo.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"