You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2006/10/20 04:47:58 UTC

svn commit: r465954 - in /maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/plugin/ src/main/ja...

Author: jvanzyl
Date: Thu Oct 19 19:47:55 2006
New Revision: 465954

URL: http://svn.apache.org/viewvc?view=rev&rev=465954
Log:
o pulling apart another mojo

Added:
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/pom.xml   (with props)
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/java/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/java/org/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/java/org/apache/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/java/org/apache/maven/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/java/org/apache/maven/plugin/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/java/org/apache/maven/plugin/coreit/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java   (with props)

Added: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/pom.xml?view=auto&rev=465954
==============================================================================
--- maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/pom.xml (added)
+++ maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/pom.xml Thu Oct 19 19:47:55 2006
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Copyright 2005-2006 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <artifactId>maven-plugins</artifactId>
+    <groupId>org.apache.maven.plugins</groupId>
+    <version>2-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>maven-it-plugin-loadable</artifactId>
+  <packaging>maven-plugin</packaging>
+  <name>Maven Core Integration Test Plugin</name>
+  <version>1.1-SNAPSHOT</version>
+  <inceptionYear>2001</inceptionYear>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java?view=auto&rev=465954
==============================================================================
--- maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java (added)
+++ maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java Thu Oct 19 19:47:55 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/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-loadable/src/main/java/org/apache/maven/plugin/coreit/LoadableMojo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"