You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2006/02/12 00:08:39 UTC

svn commit: r377080 - in /beehive/sandbox/maven2: ./ beehive-archetype-controls/ beehive-archetype-controls/src/ beehive-archetype-controls/src/main/ beehive-archetype-controls/src/main/java/ beehive-archetype-controls/src/main/resources/ beehive-arche...

Author: ekoneil
Date: Sat Feb 11 15:08:38 2006
New Revision: 377080

URL: http://svn.apache.org/viewcvs?rev=377080&view=rev
Log:
Add two Maven 2 artifacts to a sandbox/.

maven-apt-compiler: this is a Maven2 Compiler implementation that is derived from the Javac compiler.  Note, these files (AptCompiler and IsolatedClassLoader) preserve their MIT licenses and add an ASL 2.0 license.  They are from the Plexus infrastructure kept at codehaus.org.  I believe that they are acceptable to have committed to an ASF repo.  This module is documented in its README.txt file and can be built / installed locally in order to bulid Java source files with "apt.exe".

beehive-archetype-controls: this is a Maven2 archetype (project template) that includes a simple Control and a JUnit test.  Once built, it can be installed locally and used to create a new standalone Controls project.  This archetype depends on having built and installed the maven-apt-compiler as well.

Note, these do not include IDEA (or Eclipse) projects.  I expect that anyone interested in these will generate those locally.

BB: self
Test: none


Added:
    beehive/sandbox/maven2/
    beehive/sandbox/maven2/beehive-archetype-controls/
    beehive/sandbox/maven2/beehive-archetype-controls/pom.xml
    beehive/sandbox/maven2/beehive-archetype-controls/src/
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/java/
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/META-INF/
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/META-INF/archetype.xml
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/pom.xml
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/main/
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/main/java/
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/main/java/HelloWorldControl.java
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/main/java/HelloWorldControlImpl.java
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/test/
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/test/java/
    beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/test/java/HelloWorldControlTest.java
    beehive/sandbox/maven2/beehive-archetype-controls/src/test/
    beehive/sandbox/maven2/beehive-archetype-controls/src/test/java/
    beehive/sandbox/maven2/maven-apt-compiler/
    beehive/sandbox/maven2/maven-apt-compiler/README.txt
    beehive/sandbox/maven2/maven-apt-compiler/pom.xml
    beehive/sandbox/maven2/maven-apt-compiler/src/
    beehive/sandbox/maven2/maven-apt-compiler/src/main/
    beehive/sandbox/maven2/maven-apt-compiler/src/main/java/
    beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/
    beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/
    beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/
    beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/tools/
    beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/tools/maven2/
    beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/tools/maven2/compiler/
    beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/tools/maven2/compiler/AptCompiler.java
    beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/tools/maven2/compiler/IsolatedClassLoader.java
    beehive/sandbox/maven2/maven-apt-compiler/src/main/resources/
    beehive/sandbox/maven2/maven-apt-compiler/src/main/resources/META-INF/
    beehive/sandbox/maven2/maven-apt-compiler/src/main/resources/META-INF/plexus/
    beehive/sandbox/maven2/maven-apt-compiler/src/main/resources/META-INF/plexus/components.xml
    beehive/sandbox/maven2/maven-apt-compiler/src/test/
    beehive/sandbox/maven2/maven-apt-compiler/src/test/java/

Added: beehive/sandbox/maven2/beehive-archetype-controls/pom.xml
URL: http://svn.apache.org/viewcvs/beehive/sandbox/maven2/beehive-archetype-controls/pom.xml?rev=377080&view=auto
==============================================================================
--- beehive/sandbox/maven2/beehive-archetype-controls/pom.xml (added)
+++ beehive/sandbox/maven2/beehive-archetype-controls/pom.xml Sat Feb 11 15:08:38 2006
@@ -0,0 +1,19 @@
+<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">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.beehive</groupId>
+    <artifactId>beehive-archetype-controls</artifactId>
+    <packaging>maven-plugin</packaging>
+    <version>1.0-SNAPSHOT</version>
+    <name>Beehive Controls Archetype Project</name>
+    <url>http://beehive.apache.org</url>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

Added: beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/META-INF/archetype.xml
URL: http://svn.apache.org/viewcvs/beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/META-INF/archetype.xml?rev=377080&view=auto
==============================================================================
--- beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/META-INF/archetype.xml (added)
+++ beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/META-INF/archetype.xml Sat Feb 11 15:08:38 2006
@@ -0,0 +1,10 @@
+<archetype>
+    <id>beehive-archetype-controls</id>
+    <sources>
+        <source>src/main/java/HelloWorldControl.java</source>
+        <source>src/main/java/HelloWorldControlImpl.java</source>
+    </sources>
+    <testSources>
+        <source>src/test/java/HelloWorldControlTest.java</source>
+    </testSources>
+</archetype>
\ No newline at end of file

Added: beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/pom.xml
URL: http://svn.apache.org/viewcvs/beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/pom.xml?rev=377080&view=auto
==============================================================================
--- beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/pom.xml (added)
+++ beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/pom.xml Sat Feb 11 15:08:38 2006
@@ -0,0 +1,54 @@
+<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">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>${groupId}</groupId>
+    <artifactId>${artifactId}</artifactId>
+    <packaging>jar</packaging>
+    <version>${version}</version>
+    <name>Custom Controls Project</name>
+    <url>http://maven.apache.org</url>
+    <dependencies>
+        <dependency>
+            <groupId>beehive</groupId>
+            <artifactId>controls</artifactId>
+            <version>1.0.1</version>
+        </dependency>
+        <dependency>
+            <groupId>velocity</groupId>
+            <artifactId>velocity-dep</artifactId>
+            <version>1.4</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-discovery</groupId>
+            <artifactId>commons-discovery</artifactId>
+            <version>0.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <compilerId>apt</compilerId>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                    <fork>true</fork>
+                    <verbose>true</verbose>
+                    <compilerArguments>
+                        <sourcepath>src/main/java;src/test/java</sourcepath>
+                        <s>target/srcgen</s>
+                    </compilerArguments>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file

Added: beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/main/java/HelloWorldControl.java
URL: http://svn.apache.org/viewcvs/beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/main/java/HelloWorldControl.java?rev=377080&view=auto
==============================================================================
--- beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/main/java/HelloWorldControl.java (added)
+++ beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/main/java/HelloWorldControl.java Sat Feb 11 15:08:38 2006
@@ -0,0 +1,12 @@
+package ${package};
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+
+/**
+ * Simple control interface.
+ */
+@ControlInterface
+public interface HelloWorldControl {
+
+    public String sayHello(String name);
+}

Added: beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/main/java/HelloWorldControlImpl.java
URL: http://svn.apache.org/viewcvs/beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/main/java/HelloWorldControlImpl.java?rev=377080&view=auto
==============================================================================
--- beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/main/java/HelloWorldControlImpl.java (added)
+++ beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/main/java/HelloWorldControlImpl.java Sat Feb 11 15:08:38 2006
@@ -0,0 +1,23 @@
+package ${package};
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+
+/**
+ * Simple control implementation.  This control is stateless as indicated by the isTransient flag
+ */
+@ControlImplementation(isTransient=true)
+public class HelloWorldControlImpl
+    implements HelloWorldControl {
+
+    /**
+     * A reference to the Control's ControlBeanContext object
+     */
+    @Context
+    private ControlBeanContext cbc;
+
+    public String sayHello(String name) {
+        return "Hello, " + name;
+    }
+}

Added: beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/test/java/HelloWorldControlTest.java
URL: http://svn.apache.org/viewcvs/beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/test/java/HelloWorldControlTest.java?rev=377080&view=auto
==============================================================================
--- beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/test/java/HelloWorldControlTest.java (added)
+++ beehive/sandbox/maven2/beehive-archetype-controls/src/main/resources/archetype-resources/src/test/java/HelloWorldControlTest.java Sat Feb 11 15:08:38 2006
@@ -0,0 +1,30 @@
+package ${package};
+
+import org.apache.beehive.controls.test.junit.ControlTestCase;
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.api.bean.ControlBean;
+import ${package}.HelloWorldControl;
+
+/**
+ * Simple JUnit test of the HelloWorldControl.  This test extends the Beehive Control's
+ * ControlTestCase class that provides a simple Controls container.
+ */
+public class HelloWorldControlTest
+    extends ControlTestCase {
+
+    /**
+     * Instance of the HelloWorldControl.
+     */
+    @Control
+    private HelloWorldControl _control;
+
+    /**
+     * Basic test.  Ensures that the Control's environment is setup correctly
+     * and that the Control returns valid data from its <code>sayHello</code> method.
+     */
+    public void testSimple() {
+        assertNotNull(getControlContainerContext());
+        assertNotNull(((ControlBean)_control).getControlBeanContext());
+        assertEquals("Hello, foobar", _control.sayHello("foobar"));
+    }
+}
\ No newline at end of file

Added: beehive/sandbox/maven2/maven-apt-compiler/README.txt
URL: http://svn.apache.org/viewcvs/beehive/sandbox/maven2/maven-apt-compiler/README.txt?rev=377080&view=auto
==============================================================================
--- beehive/sandbox/maven2/maven-apt-compiler/README.txt (added)
+++ beehive/sandbox/maven2/maven-apt-compiler/README.txt Sat Feb 11 15:08:38 2006
@@ -0,0 +1,52 @@
+JDK APT + Maven2
+================
+
+1) Build the Maven2 compiler extension here (note, this isn't a Maven2 plugin.  yet.) using:
+
+   mvn clean compile
+
+2) Install the plugin to your local Maven2 repository:
+
+  mvn install
+
+3) Edit the following configuration file:
+
+  .m2\repository\org\apache\maven\plugins\maven-compiler-plugin\2.0\maven-compiler-plugin-2.0.pom
+
+to add the following block of XML:
+
+    <dependency>
+      <groupId>org.apache.beehive</groupId>
+      <artifactId>beehive-compiler-apt</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+
+This registers the APT compiler plugin with Maven's CompilerManager so that it's available for use
+as a compiler executable for the built-in "compile" target.
+
+To use APT from a POM, use something like this:
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <compilerId>apt</compilerId>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                    <fork>true</fork>
+                    <verbose>true</verbose>
+                    <compilerArguments>
+                        <s>target/srcgen</s>
+                    </compilerArguments>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+Limitations:
+- the "fork" mode doesn't work
+- "-A" options to APT must be passed via a POM's compilerArguments element
+- a POM should manually specify the "-s" option to set the output directory for generated files
\ No newline at end of file

Added: beehive/sandbox/maven2/maven-apt-compiler/pom.xml
URL: http://svn.apache.org/viewcvs/beehive/sandbox/maven2/maven-apt-compiler/pom.xml?rev=377080&view=auto
==============================================================================
--- beehive/sandbox/maven2/maven-apt-compiler/pom.xml (added)
+++ beehive/sandbox/maven2/maven-apt-compiler/pom.xml Sat Feb 11 15:08:38 2006
@@ -0,0 +1,40 @@
+<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">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.beehive</groupId>
+    <artifactId>beehive-compiler-apt</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0-SNAPSHOT</version>
+    <name>Apache Beehive Maven2 APT Compiler</name>
+    <url>http://beehive.apache.org</url>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+            <version>2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-compiler-api</artifactId>
+            <version>1.5.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-compiler-manager</artifactId>
+            <version>1.5.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-utils</artifactId>
+            <version>1.0.4</version>
+        </dependency>
+        <!-- test dependencies -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

Added: beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/tools/maven2/compiler/AptCompiler.java
URL: http://svn.apache.org/viewcvs/beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/tools/maven2/compiler/AptCompiler.java?rev=377080&view=auto
==============================================================================
--- beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/tools/maven2/compiler/AptCompiler.java (added)
+++ beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/tools/maven2/compiler/AptCompiler.java Sat Feb 11 15:08:38 2006
@@ -0,0 +1,445 @@
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2005, The Codehaus
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ *
+ * Copyright 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.
+ */
+package org.apache.beehive.tools.maven2.compiler;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.StringTokenizer;
+
+import org.codehaus.plexus.compiler.AbstractCompiler;
+import org.codehaus.plexus.compiler.CompilerConfiguration;
+import org.codehaus.plexus.compiler.CompilerError;
+import org.codehaus.plexus.compiler.CompilerException;
+import org.codehaus.plexus.compiler.CompilerOutputStyle;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ *
+ */
+public class AptCompiler
+    extends AbstractCompiler {
+
+    /* todo: support -A arguments */
+    /* todo: add a Maven2 plugin that supports setting -A arguments */
+
+    private static final String WARNING_PREFIX = "warning: ";
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    public AptCompiler() {
+        super(CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", ".class", null);
+    }
+
+    // ----------------------------------------------------------------------
+    // Compiler Implementation
+    // ----------------------------------------------------------------------
+
+    public List compile(CompilerConfiguration config) throws CompilerException {
+        getLogger().info("Using APT compiler");
+
+        File destinationDir = new File(config.getOutputLocation());
+
+        if (!destinationDir.exists()) {
+            destinationDir.mkdirs();
+        }
+
+        String[] sourceFiles = getSourceFiles(config);
+
+        if (sourceFiles.length == 0) {
+            return Collections.EMPTY_LIST;
+        }
+
+        System.out.println("Compiling " + sourceFiles.length + " " + "source file" + (sourceFiles.length == 1 ? "" : "s") + " to " + destinationDir.getAbsolutePath());
+
+        String[] args = buildCompilerArguments(config, sourceFiles);
+
+        List messages;
+
+        if (config.isFork()) {
+            String executable = config.getExecutable();
+
+            if (StringUtils.isEmpty(executable)) {
+                executable = "apt";
+            }
+
+            messages = compileOutOfProcess(config.getWorkingDirectory(), executable, args);
+        } else {
+            messages = compileInProcess(args);
+        }
+
+        return messages;
+    }
+
+    public String[] createCommandLine(CompilerConfiguration config) throws CompilerException {
+        return buildCompilerArguments(config, getSourceFiles(config));
+    }
+
+    public static String[] buildCompilerArguments(CompilerConfiguration config, String[] sourceFiles) {
+        List args = new ArrayList();
+
+        // ----------------------------------------------------------------------
+        // Set output
+        // ----------------------------------------------------------------------
+
+        File destinationDir = new File(config.getOutputLocation());
+
+        args.add("-d");
+
+        args.add(destinationDir.getAbsolutePath());
+
+        // ----------------------------------------------------------------------
+        // Set the class and source paths
+        // ----------------------------------------------------------------------
+
+        List classpathEntries = config.getClasspathEntries();
+        if (classpathEntries != null && !classpathEntries.isEmpty()) {
+            args.add("-classpath");
+
+            args.add(getPathString(classpathEntries));
+        }
+
+        List sourceLocations = config.getSourceLocations();
+        if (sourceLocations != null && !sourceLocations.isEmpty() && (sourceFiles.length == 0)) {
+            args.add("-sourcepath");
+
+            args.add(getPathString(sourceLocations));
+        }
+
+        for (int i = 0; i < sourceFiles.length; i++) {
+            args.add(sourceFiles[i]);
+        }
+
+        if (config.isOptimize()) {
+            args.add("-O");
+        }
+
+        if (config.isDebug()) {
+            args.add("-g");
+        }
+
+        if (config.isVerbose()) {
+            args.add("-verbose");
+        }
+
+        if (config.isShowDeprecation()) {
+            args.add("-deprecation");
+
+            // This is required to actually display the deprecation messages
+            config.setShowWarnings(true);
+        }
+
+        if (!config.isShowWarnings()) {
+            args.add("-nowarn");
+        }
+
+        // TODO: this could be much improved
+        if (StringUtils.isEmpty(config.getTargetVersion())) {
+            // Required, or it defaults to the target of your JDK (eg 1.5)
+            args.add("-target");
+            args.add("1.1");
+        } else {
+            args.add("-target");
+            args.add(config.getTargetVersion());
+        }
+
+        if (!suppressSource(config) && StringUtils.isEmpty(config.getSourceVersion())) {
+            // If omitted, later JDKs complain about a 1.1 target
+            args.add("-source");
+            args.add("1.3");
+        } else if (!suppressSource(config)) {
+            args.add("-source");
+            args.add(config.getSourceVersion());
+        }
+
+        if (!suppressEncoding(config) && !StringUtils.isEmpty(config.getSourceEncoding())) {
+            args.add("-encoding");
+            args.add(config.getSourceEncoding());
+        }
+
+        for (Iterator it = config.getCustomCompilerArguments().entrySet().iterator(); it.hasNext();) {
+            Map.Entry entry = (Map.Entry) it.next();
+
+            String key = (String) entry.getKey();
+
+            if (StringUtils.isEmpty(key)) {
+                continue;
+            }
+
+            args.add(key);
+
+            String value = (String) entry.getValue();
+
+            if (StringUtils.isEmpty(value)) {
+                continue;
+            }
+
+            args.add(value);
+        }
+
+        return (String[]) args.toArray(new String[ args.size() ]);
+    }
+
+    private static boolean suppressSource(CompilerConfiguration config) {
+        return "1.3".equals(config.getCompilerVersion());
+    }
+
+    private static boolean suppressEncoding(CompilerConfiguration config) {
+        return "1.3".equals(config.getCompilerVersion());
+    }
+
+    private List compileOutOfProcess(File workingDirectory, String executable, String[] args) throws CompilerException {
+        Commandline cli = new Commandline();
+
+        cli.setWorkingDirectory(workingDirectory.getAbsolutePath());
+
+        cli.setExecutable(executable);
+
+        cli.addArguments(args);
+
+        CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
+
+        CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
+
+        int returnCode;
+
+        List messages;
+
+        try {
+            returnCode = CommandLineUtils.executeCommandLine(cli, out, err);
+
+            messages = parseModernStream(new BufferedReader(new StringReader(err.getOutput())));
+        } catch (CommandLineException e) {
+            throw new CompilerException("Error while executing the external compiler.", e);
+        } catch (IOException e) {
+            throw new CompilerException("Error while executing the external compiler.", e);
+        }
+
+        if (returnCode != 0 && messages.isEmpty()) {
+            // TODO: exception?
+            messages.add(new CompilerError("Failure executing javac,  but could not parse the error:" + EOL + err.getOutput(), true));
+        }
+
+        return messages;
+    }
+
+    private List compileInProcess(String[] args) throws CompilerException {
+        IsolatedClassLoader cl = new IsolatedClassLoader();
+
+        File toolsJar = new File(System.getProperty("java.home"), "../lib/tools.jar");
+
+        if (toolsJar.exists()) {
+            try {
+                cl.addURL(toolsJar.toURL());
+            } catch (MalformedURLException e) {
+                throw new CompilerException("Could not convert the file reference to tools.jar to a URL, path to tools.jar: '" + toolsJar.getAbsolutePath() + "'.");
+            }
+        }
+
+        Class c;
+
+        try {
+            c = cl.loadClass("com.sun.tools.apt.Main");
+        } catch (ClassNotFoundException e) {
+            String message = "Unable to locate the Javac Compiler in:" + EOL + "  " + toolsJar + EOL + "Please ensure you are using JDK 1.4 or above and" + EOL + "not a JRE (the com.sun.tools.javac.Main class is required)." + EOL + "In most cases you can change the location of your Java" + EOL + "installation by setting the JAVA_HOME environment variable.";
+            return Collections.singletonList(new CompilerError(message, true));
+        }
+
+        StringWriter out = new StringWriter();
+
+        Integer ok;
+
+        List messages;
+
+        try {
+            Method compile = c.getMethod("compile", new Class[]{String[].class, PrintWriter.class});
+
+            ok = (Integer) compile.invoke(null, new Object[]{args, new PrintWriter(out)});
+
+            messages = parseModernStream(new BufferedReader(new StringReader(out.toString())));
+        } catch (NoSuchMethodException e) {
+            throw new CompilerException("Error while executing the compiler.", e);
+        } catch (IllegalAccessException e) {
+            throw new CompilerException("Error while executing the compiler.", e);
+        } catch (InvocationTargetException e) {
+            throw new CompilerException("Error while executing the compiler.", e);
+        } catch (IOException e) {
+            throw new CompilerException("Error while executing the compiler.", e);
+        }
+
+        if (ok.intValue() != 0 && messages.isEmpty()) {
+            // TODO: exception?
+            messages.add(new CompilerError("Failure executing javac, but could not parse the error:" + EOL + out.toString(), true));
+        }
+
+        return messages;
+    }
+
+    protected static List parseModernStream(BufferedReader input) throws IOException {
+        List errors = new ArrayList();
+
+        String line;
+
+        StringBuffer buffer;
+
+        while (true) {
+            // cleanup the buffer
+            buffer = new StringBuffer(); // this is quicker than clearing it
+
+            // most errors terminate with the '^' char
+            do {
+                line = input.readLine();
+
+                if (line == null) {
+                    return errors;
+                }
+
+                // TODO: there should be a better way to parse these
+                if (buffer.length() == 0 && line.startsWith("error: ")) {
+                    errors.add(new CompilerError(line, true));
+                } else if (buffer.length() == 0 && line.startsWith("Note: ")) {
+                    // skip this one - it is JDK 1.5 telling us that the interface is deprecated.
+                } else {
+                    buffer.append(line);
+
+                    buffer.append(EOL);
+                }
+            } while (!line.endsWith("^"));
+
+            // add the error bean
+            errors.add(parseModernError(buffer.toString()));
+        }
+    }
+
+    public static CompilerError parseModernError(String error) {
+        StringTokenizer tokens = new StringTokenizer(error, ":");
+
+        boolean isError = true;
+
+        StringBuffer msgBuffer;
+
+        try {
+            String file = tokens.nextToken();
+
+            // When will this happen?
+            if (file.length() == 1) {
+                file = new StringBuffer(file).append(":").append(tokens.nextToken()).toString();
+            }
+
+            int line = Integer.parseInt(tokens.nextToken());
+
+            msgBuffer = new StringBuffer();
+
+            String msg = tokens.nextToken(EOL).substring(2);
+
+            isError = !msg.startsWith(WARNING_PREFIX);
+
+            // Remove the 'warning: ' prefix
+            if (!isError) {
+                msg = msg.substring(WARNING_PREFIX.length());
+            }
+
+            msgBuffer.append(msg);
+
+            msgBuffer.append(EOL);
+
+            String context = tokens.nextToken(EOL);
+
+            String pointer = tokens.nextToken(EOL);
+
+            if (tokens.hasMoreTokens()) {
+                msgBuffer.append(context);    // 'symbol' line
+
+                msgBuffer.append(EOL);
+
+                msgBuffer.append(pointer);    // 'location' line
+
+                msgBuffer.append(EOL);
+
+                context = tokens.nextToken(EOL);
+
+                try {
+                    pointer = tokens.nextToken(EOL);
+                } catch (NoSuchElementException e) {
+                    pointer = context;
+
+                    context = null;
+                }
+
+            }
+
+            String message = msgBuffer.toString();
+
+            int startcolumn = pointer.indexOf("^");
+
+            int endcolumn = context == null ? startcolumn : context.indexOf(" ", startcolumn);
+
+            if (endcolumn == -1) {
+                endcolumn = context.length();
+            }
+
+            return new CompilerError(file, isError, line, startcolumn, line, endcolumn, message);
+        } catch (NoSuchElementException e) {
+            return new CompilerError("no more tokens - could not parse error message: " + error, isError);
+        } catch (NumberFormatException e) {
+            return new CompilerError("could not parse error message: " + error, isError);
+        } catch (Exception e) {
+            return new CompilerError("could not parse error message: " + error, isError);
+        }
+    }
+}
\ No newline at end of file

Added: beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/tools/maven2/compiler/IsolatedClassLoader.java
URL: http://svn.apache.org/viewcvs/beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/tools/maven2/compiler/IsolatedClassLoader.java?rev=377080&view=auto
==============================================================================
--- beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/tools/maven2/compiler/IsolatedClassLoader.java (added)
+++ beehive/sandbox/maven2/maven-apt-compiler/src/main/java/org/apache/beehive/tools/maven2/compiler/IsolatedClassLoader.java Sat Feb 11 15:08:38 2006
@@ -0,0 +1,92 @@
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2005, The Codehaus
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ *
+ * Copyright 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.
+ */
+package org.apache.beehive.tools.maven2.compiler;
+
+import java.net.URLClassLoader;
+import java.net.URL;
+
+class IsolatedClassLoader
+    extends URLClassLoader
+{
+    private ClassLoader parentClassLoader = ClassLoader.getSystemClassLoader();
+
+    public IsolatedClassLoader()
+    {
+        super( new URL[0], null );
+    }
+
+    public void addURL( URL url )
+    {
+        super.addURL( url );
+    }
+
+    public synchronized Class loadClass( String className )
+        throws ClassNotFoundException
+    {
+        Class c = findLoadedClass( className );
+
+        ClassNotFoundException ex = null;
+
+        if ( c == null )
+        {
+            try
+            {
+                c = findClass( className );
+            }
+            catch ( ClassNotFoundException e )
+            {
+                ex = e;
+
+                if ( parentClassLoader != null )
+                {
+                    c = parentClassLoader.loadClass( className );
+                }
+            }
+        }
+
+        if ( c == null )
+        {
+            throw ex;
+        }
+
+        return c;
+    }
+}
\ No newline at end of file

Added: beehive/sandbox/maven2/maven-apt-compiler/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/beehive/sandbox/maven2/maven-apt-compiler/src/main/resources/META-INF/plexus/components.xml?rev=377080&view=auto
==============================================================================
--- beehive/sandbox/maven2/maven-apt-compiler/src/main/resources/META-INF/plexus/components.xml (added)
+++ beehive/sandbox/maven2/maven-apt-compiler/src/main/resources/META-INF/plexus/components.xml Sat Feb 11 15:08:38 2006
@@ -0,0 +1,9 @@
+<component-set>
+  <components>
+    <component>
+      <role>org.codehaus.plexus.compiler.Compiler</role>
+      <role-hint>apt</role-hint>
+      <implementation>org.apache.beehive.tools.maven2.compiler.AptCompiler</implementation>
+    </component>
+  </components>
+</component-set>