You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:20:32 UTC

[sling-org-apache-sling-commons-compiler] annotated tag org.apache.sling.commons.compiler-2.0.0 created (now 0f7eb2b)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git.


      at 0f7eb2b  (tag)
 tagging 1e4e705a6998e1df99b6ec001c7022933e38ef6f (commit)
      by Carsten Ziegeler
      on Thu Dec 16 10:11:39 2010 +0000

- Log -----------------------------------------------------------------
org.apache.sling.commons.compiler-2.0.0
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new f497e80  SLING-873 : Add new commons compiler bundle. Applied patch from Stefan Guggisberg.
     new 71a6b19  Ignore the target directory.
     new 715e761  SLING-874 - Use correct header.
     new 640e371  Add missing private package and correct javadoc generation.
     new 8d54570  SLING-884 : Apply patch from Stefan Guggisberg for pom fixing and code cleanup.
     new c9002db  Use release parent pom
     new 06372a8  Use new dev parent pom for contrib.
     new c59c885  Set parent pom to released version.
     new a999f86  Ignore hidden files (Eclipse .project, etc.)
     new 2006f88  Move Sling to new TLP location
     new 4f017a9  SLING-1011 : Remove disclaimer file.
     new dfde97a  SLING-1011 : Adjust svn location
     new f08f2f4  SLING-1011 : Remove disclaimer from readme's, adjust links to webite, fix versions in poms.
     new 348cc49  SLING-1033 Upgrade to Sling parent POM 6 (and ensure web app has the leglize stuff, too)
     new f5c7f26  Remove empty code and prints to system out.
     new 9176bc6  Update to latest release.
     new c80f3f0  [maven-release-plugin] prepare release org.apache.sling.commons.compiler-1.0.0
     new 9a15676  [maven-release-plugin] prepare for next development iteration
     new 26c5d31  Export version 1.0.0 of the API
     new b228898  SLING-1205 Upgrade all projects to parent POM 8 and use OSGi provided OSGi libraries
     new 21155d0  SLING-1436 Upgrade Eclipse compiler to latest version 3.3.0-v_771
     new 64fdb9e  SLING-1451 : Clean up compiler API and use classloading infrastructure
     new b50cd86  SLING-1451 : Clean up compiler API and use classloading infrastructure
     new d8d0a63  SLING-1451 : Clean up compiler API and use classloading infrastructure
     new fedaf7f  SLING-1459 :  Make references to class loader manager and class loader writer dynamic
     new 028f3d4  Use released parent pom.
     new 2040e0d  Add serial version
     new 6238b6a  SLING-1809 : Eclipse compiler used in commons.compiler causes "Illegal type in constant pool" with
     new 2c73dc8  Remove obsolete notice/licence files.
     new 759f50c  [maven-release-plugin] prepare release org.apache.sling.commons.compiler-2.0.0
     new 1e4e705  [maven-scm] copy for tag org.apache.sling.commons.compiler-2.0.0

The 31 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-commons-compiler] 09/14: Use released parent pom.

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit 028f3d4a76fcff4f8dde5faebf7a1ccc126b1da3
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon May 17 13:42:29 2010 +0000

    Use released parent pom.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@945149 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index cc1b3e1..a094192 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>8</version>
+        <version>9</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-compiler] 05/14: SLING-1451 : Clean up compiler API and use classloading infrastructure

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit 64fdb9e597f9f62deadfbcea526cf20c7d81e80d
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Mar 19 14:50:41 2010 +0000

    SLING-1451 : Clean up compiler API and use classloading infrastructure
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@925247 13f79535-47bb-0310-9956-ffa450edef68
---
 NOTICE                                             |   2 +-
 pom.xml                                            |  16 +-
 .../apache/sling/commons/compiler/ClassWriter.java |  31 --
 .../{CompileUnit.java => CompilationUnit.java}     |  20 +-
 .../commons/compiler/CompilerEnvironment.java      |  26 --
 .../sling/commons/compiler/ErrorHandler.java       |  22 +-
 .../sling/commons/compiler/JavaCompiler.java       |  18 +-
 .../org/apache/sling/commons/compiler/Options.java |  71 +++-
 .../commons/compiler/impl/EclipseJavaCompiler.java | 370 ++++++++++++++-------
 src/main/resources/META-INF/NOTICE                 |   2 +-
 .../commons/compiler/impl/CompilerJava5Test.java   | 146 +++-----
 src/test/resources/Java5Test                       |   2 +-
 12 files changed, 420 insertions(+), 306 deletions(-)

diff --git a/NOTICE b/NOTICE
index 3341854..76ff9f0 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,5 +1,5 @@
 Apache Sling Java Compiler
-Copyright 2008-2009 The Apache Software Foundation
+Copyright 2008-2010 The Apache Software Foundation
 
 Apache Sling is based on source code originally developed 
 by Day Software (http://www.day.com/).
diff --git a/pom.xml b/pom.xml
index 3c2906d..cc1b3e1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,7 +59,7 @@
                             !org.eclipse.*,*
                         </Import-Package>
                         <Export-Package>
-                            org.apache.sling.commons.compiler;version=1.0.0
+                            org.apache.sling.commons.compiler;version=2.0.0
                         </Export-Package>
                         <Private-Package>
                             org.apache.sling.commons.compiler.impl
@@ -88,6 +88,18 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <version>1.2.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.classloader</artifactId>
+            <version>1.1.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.eclipse.jdt</groupId>
             <artifactId>core</artifactId>
             <version>3.3.0-v_771</version>
@@ -111,12 +123,10 @@
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-simple</artifactId>
-            <scope>test</scope>
         </dependency>
     </dependencies>
 </project>
diff --git a/src/main/java/org/apache/sling/commons/compiler/ClassWriter.java b/src/main/java/org/apache/sling/commons/compiler/ClassWriter.java
deleted file mode 100644
index 46dc92a..0000000
--- a/src/main/java/org/apache/sling/commons/compiler/ClassWriter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.sling.commons.compiler;
-
-/**
- *
- */
-public interface ClassWriter {
-
-    /**
-     *
-     * @param className
-     * @param data
-     * @throws Exception
-     */
-    void write(String className, byte[] data) throws Exception;
-}
diff --git a/src/main/java/org/apache/sling/commons/compiler/CompileUnit.java b/src/main/java/org/apache/sling/commons/compiler/CompilationUnit.java
similarity index 70%
rename from src/main/java/org/apache/sling/commons/compiler/CompileUnit.java
rename to src/main/java/org/apache/sling/commons/compiler/CompilationUnit.java
index 92723ca..fd060c2 100644
--- a/src/main/java/org/apache/sling/commons/compiler/CompileUnit.java
+++ b/src/main/java/org/apache/sling/commons/compiler/CompilationUnit.java
@@ -16,16 +16,26 @@
  */
 package org.apache.sling.commons.compiler;
 
-public interface CompileUnit {
+import java.io.IOException;
+import java.io.Reader;
 
-    String getSourceFileName();
+/**
+ * This interface describes a compilation unit - usually a java class.
+ * @since 2.0
+ */
+public interface CompilationUnit {
 
-    char[] getSourceFileContents();
+    /**
+     * Return an input stream for the contents.
+     * The compiler will close this stream in all cases!
+     */
+    Reader getSource()
+    throws IOException;
 
     /**
      * Returns the name of the top level public type.
-     *
+     * This name includes the package.
      * @return the name of the top level public type.
      */
-    String getMainTypeName();
+    String getMainClassName();
 }
diff --git a/src/main/java/org/apache/sling/commons/compiler/CompilerEnvironment.java b/src/main/java/org/apache/sling/commons/compiler/CompilerEnvironment.java
deleted file mode 100644
index cddb7f7..0000000
--- a/src/main/java/org/apache/sling/commons/compiler/CompilerEnvironment.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.sling.commons.compiler;
-
-public interface CompilerEnvironment {
-
-    byte[] findClass(String className) throws Exception;
-
-    boolean isPackage(String packageName);
-
-    void cleanup();
-}
diff --git a/src/main/java/org/apache/sling/commons/compiler/ErrorHandler.java b/src/main/java/org/apache/sling/commons/compiler/ErrorHandler.java
index 40cf544..cebb678 100644
--- a/src/main/java/org/apache/sling/commons/compiler/ErrorHandler.java
+++ b/src/main/java/org/apache/sling/commons/compiler/ErrorHandler.java
@@ -17,25 +17,25 @@
 package org.apache.sling.commons.compiler;
 
 /**
- *
+ * The error handler for the compilation.
  */
 public interface ErrorHandler {
 
     /**
-     *
-     * @param msg
-     * @param sourceFile
-     * @param line
-     * @param position
+     * Notify the handler of an error.
+     * @param msg The error message.
+     * @param sourceFile The source file the error occured in
+     * @param line The source line number
+     * @param position The column
      */
     void onError(String msg, String sourceFile, int line, int position);
 
     /**
-     *
-     * @param msg
-     * @param sourceFile
-     * @param line
-     * @param position
+     * Notify the handler of a warning.
+     * @param msg The warning message.
+     * @param sourceFile The source file the warning occured in
+     * @param line The source line number
+     * @param position The column
      */
     void onWarning(String msg, String sourceFile, int line, int position);
 }
diff --git a/src/main/java/org/apache/sling/commons/compiler/JavaCompiler.java b/src/main/java/org/apache/sling/commons/compiler/JavaCompiler.java
index 67240f0..033b027 100644
--- a/src/main/java/org/apache/sling/commons/compiler/JavaCompiler.java
+++ b/src/main/java/org/apache/sling/commons/compiler/JavaCompiler.java
@@ -17,12 +17,20 @@
 package org.apache.sling.commons.compiler;
 
 /**
- * The <code>JavaCompiler</code> provides platform independant Java Compilation
- * support.
+ * The <code>JavaCompiler</code> provides platform independant Java
+ * compilation support.
  */
 public interface JavaCompiler {
 
-    boolean compile(CompileUnit[] units, CompilerEnvironment env,
-                        ClassWriter classWriter, ErrorHandler errorHandler,
-                        Options options);
+    /**
+     * Compile the compilation units.
+     * @param units The compilation units.
+     * @param errorHandler The error handler - this object is mandatory
+     * @param options The compilation options - this object is optional
+     * @return <code>true</code> if compilation was successful
+     * @since 2.0
+     */
+    boolean compile(CompilationUnit[] units,
+                    ErrorHandler errorHandler,
+                    Options options);
 }
diff --git a/src/main/java/org/apache/sling/commons/compiler/Options.java b/src/main/java/org/apache/sling/commons/compiler/Options.java
index 23b0625..366f6f0 100644
--- a/src/main/java/org/apache/sling/commons/compiler/Options.java
+++ b/src/main/java/org/apache/sling/commons/compiler/Options.java
@@ -16,7 +16,21 @@
  */
 package org.apache.sling.commons.compiler;
 
-public class Options {
+import java.util.HashMap;
+
+/**
+ * Options for the compilation process.
+ */
+public class Options extends HashMap<String, Object> {
+
+    /** The key for the source version. */
+    public static final String KEY_SOURCE_VERSION = "sourceVersion";
+
+    /** The key for the target version. */
+    public static final String KEY_TARGET_VERSION = "targetVersion";
+
+    /** The key for the generate debug info flag. */
+    public static final String KEY_GENERATE_DEBUG_INFO = "generateDebugInfo";
 
     public static final String VERSION_RUNTIME = null;
     public static final String VERSION_1_1 = "1.1";
@@ -24,33 +38,54 @@ public class Options {
     public static final String VERSION_1_3 = "1.3";
     public static final String VERSION_1_4 = "1.4";
     public static final String VERSION_1_5 = "1.5";
-    public static final String VERSION_1_6 = "1.6"; 
+    public static final String VERSION_1_6 = "1.6";
+    public static final String VERSION_1_7 = "1.7";
 
-    protected String sourceVersion;
-    protected boolean generateDebugInfo;
+    /** The key for the class loader writer.
+     * By default the registered class loader writer service is used. */
+    public static final String KEY_CLASS_LOADER_WRITER = "classLoaderWriter";
 
+    /**
+     * The key for the class loader.
+     * By default the commons dynamic classloader is used.
+     * This property overrides the classloader and ignores the
+     * {@link #KEY_ADDITIONAL_CLASS_LOADER} completly!
+     */
+    public static final String KEY_CLASS_LOADER = "classLoader";
+
+    /**
+     * The key for the additional class loader.
+     * By default the commons dynamic classloader is used.
+     * If this property is used and the {@link #KEY_CLASS_LOADER}
+     * property is not defined, a classloader with the dynamic
+     * class loader (default) and the class loader specified here
+     * is used.
+     */
+    public static final String KEY_ADDITIONAL_CLASS_LOADER = "classLoader";
+
+    /**
+     * Default options with the following presets:
+     * - generate debug info : true
+     */
     public Options() {
-        this(VERSION_RUNTIME, true);
-    }
-    
-    public Options(String sourceVersion, boolean generateDebugInfo) {
-        this.sourceVersion = sourceVersion;
-        this.generateDebugInfo = generateDebugInfo;
+        this.put(KEY_GENERATE_DEBUG_INFO, true);
     }
 
     public String getSourceVersion() {
-        return sourceVersion;
+        return (String) this.get(KEY_SOURCE_VERSION);
     }
 
-    public void setSourceVersion(String sourceVersion) {
-        this.sourceVersion = sourceVersion;
+    /**
+     * @since 2.0
+     */
+    public String getTargetVersion() {
+        return (String) this.get(KEY_TARGET_VERSION);
     }
 
     public boolean isGenerateDebugInfo() {
-        return generateDebugInfo;
-    }
-
-    public void setGenerateDebugInfo(boolean generateDebugInfo) {
-        this.generateDebugInfo = generateDebugInfo;
+        if ( this.get(KEY_GENERATE_DEBUG_INFO) != null ) {
+            return (Boolean) this.get(KEY_GENERATE_DEBUG_INFO);
+        }
+        return false;
     }
 }
diff --git a/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java b/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
index 8dc6c1a..bac1a1d 100644
--- a/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
+++ b/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
@@ -17,16 +17,22 @@
 package org.apache.sling.commons.compiler.impl;
 
 import java.io.BufferedReader;
-import java.io.CharArrayReader;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.PrintWriter;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.net.URL;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 
-import org.apache.sling.commons.compiler.ClassWriter;
-import org.apache.sling.commons.compiler.CompileUnit;
-import org.apache.sling.commons.compiler.CompilerEnvironment;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.commons.classloader.ClassLoaderWriter;
+import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
+import org.apache.sling.commons.compiler.CompilationUnit;
 import org.apache.sling.commons.compiler.ErrorHandler;
 import org.apache.sling.commons.compiler.JavaCompiler;
 import org.apache.sling.commons.compiler.Options;
@@ -48,122 +54,194 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * The <code>EclipseJavaCompiler</code> provides platform independant Java Compilation
- * support using the Eclipse Java Compiler (org.eclipse.jdt).
+ * The <code>EclipseJavaCompiler</code> provides platform independant
+ * Java compilation support using the Eclipse Java Compiler (org.eclipse.jdt).
  *
- * @scr.component metatype="no"
- * @scr.service interface="org.apache.sling.commons.compiler.JavaCompiler"
  */
+@Component
+@Service(value=JavaCompiler.class)
 public class EclipseJavaCompiler implements JavaCompiler {
 
     /** Logger instance */
-    private static final Logger log = LoggerFactory.getLogger(EclipseJavaCompiler.class);
+    private final Logger logger = LoggerFactory.getLogger(EclipseJavaCompiler.class);
 
-    // the static problem factory
-    private static IProblemFactory PROBLEM_FACTORY =
-        new DefaultProblemFactory(Locale.getDefault());
+    @Reference
+    private ClassLoaderWriter classLoaderWriter;
 
-    public EclipseJavaCompiler() {
-    }
+    @Reference
+    private DynamicClassLoaderManager dynamicClassLoaderManager;
+
+    private ClassLoader classLoader;
+
+    /** the static problem factory */
+    private IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());
+
+    /** the static policy. */
+    private final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
 
     /**
-     * @see org.apache.sling.commons.compiler.JavaCompiler#compile(org.apache.sling.commons.compiler.CompileUnit[], org.apache.sling.commons.compiler.CompilerEnvironment, org.apache.sling.commons.compiler.ClassWriter, org.apache.sling.commons.compiler.ErrorHandler, org.apache.sling.commons.compiler.Options)
+     * Bind the class load provider.
+     * @param repositoryClassLoaderProvider the new provider
      */
-    public boolean compile(CompileUnit[] units, CompilerEnvironment env,
-            ClassWriter classWriter, ErrorHandler errorHandler,
-            Options options) {
+    protected void bindDynamicClassLoaderManager(final DynamicClassLoaderManager rclp) {
+        if ( this.classLoader != null ) {
+            this.ungetClassLoader();
+        }
+        this.getClassLoader(rclp);
+    }
 
-        IErrorHandlingPolicy policy =
-            DefaultErrorHandlingPolicies.proceedWithAllProblems();
+    /**
+     * Unbind the class loader provider.
+     * @param repositoryClassLoaderProvider the old provider
+     */
+    protected void unbindDynamicClassLoaderManager(final DynamicClassLoaderManager rclp) {
+        if ( this.dynamicClassLoaderManager == rclp ) {
+            this.ungetClassLoader();
+        }
+    }
 
-        // output for non-error log messages
-        PrintWriter logWriter = null;
+    /**
+     * Get the class loader
+     */
+    private void getClassLoader(final DynamicClassLoaderManager rclp) {
+        this.dynamicClassLoaderManager = rclp;
+        this.classLoader = rclp.getDynamicClassLoader();
+    }
 
-        if (options == null) {
-            options = new Options();
-        }
+    /**
+     * Unget the class loader
+     */
+    private void ungetClassLoader() {
+        this.classLoader = null;
+        this.dynamicClassLoaderManager = null;
+    }
 
-        Map<String, String> props = new HashMap<String, String>();
+    /**
+     * @see org.apache.sling.commons.compiler.JavaCompiler#compile(org.apache.sling.commons.compiler.CompilationUnit[], org.apache.sling.commons.compiler.ErrorHandler, org.apache.sling.commons.compiler.Options)
+     */
+    public boolean compile(final CompilationUnit[] units,
+                           final ErrorHandler errorHandler,
+                           final Options compileOptions) {
+        // make sure we have an options object (to avoid null checks all over the place)
+        final Options options = (compileOptions != null ? compileOptions : new Options());
+
+        // create properties for the settings object
+        final Map<String, String> props = new HashMap<String, String>();
         if (options.isGenerateDebugInfo()) {
             props.put("org.eclipse.jdt.core.compiler.debug.localVariable", "generate");
             props.put("org.eclipse.jdt.core.compiler.debug.lineNumber", "generate");
             props.put("org.eclipse.jdt.core.compiler.debug.sourceFile", "generate");
         }
-        String sourceVersion = options.getSourceVersion();
-        if (sourceVersion != null) {
-            props.put("org.eclipse.jdt.core.compiler.source", sourceVersion);
-            //options.put("org.eclipse.jdt.core.compiler.compliance", sourceVersion);
-            //options.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", sourceVersion);
+        if (options.getSourceVersion() != null) {
+            props.put("org.eclipse.jdt.core.compiler.source", options.getSourceVersion());
+            //props.put("org.eclipse.jdt.core.compiler.compliance", options.getSourceVersion());
+            //props.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", options.getSourceVersion());
         }
-        //options.put("org.eclipse.jdt.core.encoding", "UTF8");
-        CompilerOptions settings = new CompilerOptions(props);
-
-        CompileContext context = new CompileContext(units, env, errorHandler, classWriter);
+        if (options.getTargetVersion() != null) {
+            props.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", options.getTargetVersion());
+        }
+        props.put("org.eclipse.jdt.core.encoding", "UTF8");
+
+        // create the settings
+        final CompilerOptions settings = new CompilerOptions(props);
+        logger.debug("Compiling with settings {}.", settings);
+
+        // classloader
+        final ClassLoader loader;
+        if ( options.get(Options.KEY_CLASS_LOADER) != null ) {
+            loader = (ClassLoader)options.get(Options.KEY_CLASS_LOADER);
+        } else if ( options.get(Options.KEY_ADDITIONAL_CLASS_LOADER) != null ) {
+            final ClassLoader additionalClassLoader = (ClassLoader)options.get(Options.KEY_ADDITIONAL_CLASS_LOADER);
+            loader = new ClassLoader(this.classLoader) {
+                protected Class<?> findClass(String name)
+                throws ClassNotFoundException {
+                    return additionalClassLoader.loadClass(name);
+                }
 
-        if (log.isDebugEnabled()) {
-            log.debug(settings.toString());
+                protected URL findResource(String name) {
+                    return additionalClassLoader.getResource(name);
+                }
+            };
+        } else {
+            loader = this.classLoader;
         }
 
-        org.eclipse.jdt.internal.compiler.Compiler compiler =
+        // classloader writer
+        final ClassLoaderWriter writer = (options.get(Options.KEY_CLASS_LOADER_WRITER) != null ?
+                (ClassLoaderWriter)options.get(Options.KEY_CLASS_LOADER_WRITER) : this.classLoaderWriter);
+
+        // create the context
+        final CompileContext context = new CompileContext(units, errorHandler, writer, loader);
+
+        // create the compiler
+        final org.eclipse.jdt.internal.compiler.Compiler compiler =
                 new org.eclipse.jdt.internal.compiler.Compiler(
                         context,
-                        policy,
+                        this.policy,
                         settings,
                         context,
-                        PROBLEM_FACTORY,
-                        logWriter);
+                        this.problemFactory,
+                        null);
 
-        compiler.compile(context.sourceUnits());
+        // compile
+        compiler.compile(context.getSourceUnits());
 
-        context.cleanup();
-
-        return !context.hadErrors;
+        return !context.hasErrors;
     }
 
     //--------------------------------------------------------< inner classes >
 
-    private class CompileContext implements ICompilerRequestor, INameEnvironment {
-
-        boolean hadErrors;
-        HashMap<String,ICompilationUnit> compUnits;
+    private class CompileContext implements ICompilerRequestor, INameEnvironment, ErrorHandler {
 
-        ErrorHandler errorHandler;
-        ClassWriter classWriter;
+        private final Map<String,ICompilationUnit> compUnits;
 
-        CompilerEnvironment compEnv;
+        private final ErrorHandler errorHandler;
+        private final ClassLoaderWriter classLoaderWriter;
+        private final ClassLoader classLoader;
 
-        CompileContext(CompileUnit[] units,
-        		CompilerEnvironment compEnv,
-        		ErrorHandler errorHandler,
-        		ClassWriter classWriter) {
+        /** Flag indicating if we have an error. */
+        private boolean hasErrors = false;
 
-        	compUnits = new HashMap<String,ICompilationUnit>(units.length);
+        public CompileContext(final CompilationUnit[] units,
+         		              final ErrorHandler errorHandler,
+        		              final ClassLoaderWriter classWriter,
+        		              final ClassLoader classLoader) {
+        	this.compUnits = new HashMap<String,ICompilationUnit>();
             for (int i = 0; i < units.length; i++) {
-                CompilationUnitAdapter cua = new CompilationUnitAdapter(units[i]);
+                CompilationUnitAdapter cua = new CompilationUnitAdapter(units[i], this);
                 char[][] compoundName = CharOperation.arrayConcat(cua.getPackageName(), cua.getMainTypeName());
-                compUnits.put(CharOperation.toString(compoundName), new CompilationUnitAdapter(units[i]));
+                this.compUnits.put(CharOperation.toString(compoundName), new CompilationUnitAdapter(units[i], this));
             }
 
-        	this.compEnv = compEnv;
         	this.errorHandler = errorHandler;
-            this.classWriter = classWriter;
-            hadErrors = false;
+            this.classLoaderWriter = classWriter;
+            this.classLoader = classLoader;
         }
 
-        ICompilationUnit[] sourceUnits() {
+        /**
+         * @see org.apache.sling.commons.compiler.ErrorHandler#onError(java.lang.String, java.lang.String, int, int)
+         */
+        public void onError(String msg, String sourceFile, int line, int position) {
+            this.errorHandler.onError(msg, sourceFile, line, position);
+            this.hasErrors = true;
+        }
+
+        /**
+         * @see org.apache.sling.commons.compiler.ErrorHandler#onWarning(java.lang.String, java.lang.String, int, int)
+         */
+        public void onWarning(String msg, String sourceFile, int line, int position) {
+            this.errorHandler.onWarning(msg, sourceFile, line, position);
+        }
+
+        public ICompilationUnit[] getSourceUnits() {
         	return compUnits.values().toArray(
         			new ICompilationUnit[compUnits.size()]);
         }
 
-        //---------------------------------------------------< ICompilerRequestor >
         /**
-         * {@inheritDoc}
+         * @see org.eclipse.jdt.internal.compiler.ICompilerRequestor#acceptResult(org.eclipse.jdt.internal.compiler.CompilationResult)
          */
         public void acceptResult(CompilationResult result) {
-            if (result.hasErrors()) {
-                hadErrors = true;
-            }
-
             if (result.hasProblems()) {
                 CategorizedProblem[] problems = result.getProblems();
                 for (int i = 0; i < problems.length; i++) {
@@ -174,11 +252,11 @@ public class EclipseJavaCompiler implements JavaCompiler {
                     int pos = problem.getSourceStart();
 
                     if (problem.isError()) {
-                        errorHandler.onError(msg, fileName, line, pos);
+                        this.onError(msg, fileName, line, pos);
                     } else if (problem.isWarning()) {
-                        errorHandler.onWarning(msg, fileName, line, pos);
+                        this.onWarning(msg, fileName, line, pos);
                     } else {
-                        log.debug("unknown problem category: " + problem.toString());
+                        logger.debug("unknown problem category: {}", problem);
                     }
                 }
             }
@@ -187,16 +265,15 @@ public class EclipseJavaCompiler implements JavaCompiler {
                 ClassFile classFile = classFiles[i];
                 String className = CharOperation.toString(classFile.getCompoundName());
                 try {
-                    classWriter.write(className, classFile.getBytes());
-                } catch (Exception e) {
-                    log.error("failed to persist class " + className, e);
+                    this.write(className, classFile.getBytes());
+                } catch (IOException e) {
+                    this.onError("Unable to write class file: " + e.getMessage(), className, 0, 0);
                 }
             }
         }
 
-        //-------------------------------------------------< INameEnvironment >
         /**
-         * {@inheritDoc}
+         * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#findType(char[][])
          */
         public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
             // check 1st if type corresponds with any of current compilation units
@@ -208,7 +285,7 @@ public class EclipseJavaCompiler implements JavaCompiler {
 
             // locate the class through the class loader
             try {
-                byte[] bytes = compEnv.findClass(CharOperation.toString(compoundTypeName));
+                byte[] bytes = this.findClass(CharOperation.toString(compoundTypeName));
                 if (bytes == null) {
                     return null;
                 }
@@ -221,78 +298,145 @@ public class EclipseJavaCompiler implements JavaCompiler {
         }
 
         /**
-         * {@inheritDoc}
+         * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#findType(char[], char[][])
          */
         public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
             return findType(CharOperation.arrayConcat(packageName, typeName));
         }
 
         /**
-         * {@inheritDoc}
+         * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#isPackage(char[][], char[])
          */
         public boolean isPackage(char[][] parentPackageName, char[] packageName) {
             String fqn = CharOperation.toString(
                     CharOperation.arrayConcat(parentPackageName, packageName));
-            return compUnits.get(fqn) == null && compEnv.isPackage(fqn);
+            return compUnits.get(fqn) == null && this.isPackage(fqn);
         }
 
         /**
-         * {@inheritDoc}
+         * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#cleanup()
          */
         public void cleanup() {
-            compEnv.cleanup();
+            // nothing to do
+        }
+
+        /**
+         * Write the classfile
+         */
+        private void write(String name, byte[] data) throws IOException {
+            final OutputStream os = this.classLoaderWriter.getOutputStream('/' + name.replace('.', '/') + ".class");
+            os.write(data);
+            os.close();
+        }
+
+        private boolean isPackage(String result) {
+            String resourceName = result.replace('.', '/') + ".class";
+            if ( resourceName.startsWith("/") ) {
+                resourceName = resourceName.substring(1);
+            }
+            final InputStream is = this.classLoader.getResourceAsStream(resourceName);
+            if ( is != null ) {
+                try {
+                    is.close();
+                } catch (IOException ignore) {}
+            }
+            return is == null;
+        }
+
+        private byte[] findClass(String name) throws Exception {
+            final String resourceName = name.replace('.', '/') + ".class";
+            final InputStream is = this.classLoader.getResourceAsStream(resourceName);
+            if (is != null) {
+                try {
+                    byte[] buf = new byte[8192];
+                    ByteArrayOutputStream baos = new ByteArrayOutputStream(buf.length);
+                    int count;
+                    while ((count = is.read(buf, 0, buf.length)) > 0) {
+                        baos.write(buf, 0, count);
+                    }
+                    baos.flush();
+                    return baos.toByteArray();
+                } finally {
+                    try {
+                        is.close();
+                    } catch (IOException ignore) {}
+                }
+            }
+            return null;
         }
     }
 
     private class CompilationUnitAdapter implements ICompilationUnit {
 
-        CompileUnit compUnit;
-        char[][] packageName;
+        private final ErrorHandler errorHandler;
+        private final CompilationUnit compUnit;
+        private final String mainTypeName;
+        private final String packageName;
 
-        CompilationUnitAdapter(CompileUnit compUnit) {
+        public CompilationUnitAdapter(final CompilationUnit compUnit, final ErrorHandler errorHandler) {
             this.compUnit = compUnit;
+            this.errorHandler = errorHandler;
+            final int pos = compUnit.getMainClassName().lastIndexOf('.');
+            if ( pos == -1 ) {
+                this.packageName = "";
+                this.mainTypeName = compUnit.getMainClassName();
+            } else {
+                this.packageName = compUnit.getMainClassName().substring(0, pos);
+                this.mainTypeName = compUnit.getMainClassName().substring(pos + 1);
+            }
         }
 
-        String extractPackageName(char[] contents) {
-            BufferedReader reader = new BufferedReader(new CharArrayReader(contents));
+        /**
+         * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getContents()
+         */
+        public char[] getContents() {
+            Reader fr = null;
             try {
-                String line;
-                while ((line = reader.readLine()) != null) {
-                    line = line.trim();
-                    if (line.startsWith("package")) {
-                        line = line.substring("package".length());
-                        line = line.substring(0, line.lastIndexOf(';'));
-                        return line.trim();
+                fr = this.compUnit.getSource();
+                final Reader reader = new BufferedReader(fr);
+                try {
+                    char[] chars = new char[8192];
+                    StringBuilder buf = new StringBuilder();
+                    int count;
+                    while ((count = reader.read(chars, 0, chars.length)) > 0) {
+                        buf.append(chars, 0, count);
                     }
+                    final char[] result = new char[buf.length()];
+                    buf.getChars(0, result.length, result, 0);
+                    return result;
+                } finally {
+                    reader.close();
                 }
             } catch (IOException e) {
-                // should never get here...
+                this.errorHandler.onError("Unable to read source file " + this.compUnit.getMainClassName() + " : " + e.getMessage(),
+                        this.compUnit.getMainClassName(), 0, 0);
+                return null;
+            } finally {
+                if ( fr != null ) {
+                    try { fr.close(); } catch (IOException ignore) {}
+                }
             }
-
-            // no package declaration found
-            return "";
-        }
-
-        //-------------------------------------------------< ICompilationUnit >
-
-        public char[] getContents() {
-            return compUnit.getSourceFileContents();
         }
 
+        /**
+         * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getMainTypeName()
+         */
         public char[] getMainTypeName() {
-            return compUnit.getMainTypeName().toCharArray();
+            return this.mainTypeName.toCharArray();
         }
 
+        /**
+         * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getPackageName()
+         */
         public char[][] getPackageName() {
-            if (packageName == null) {
-                String s = extractPackageName(compUnit.getSourceFileContents());
-                packageName = CharOperation.splitOn('.', s.toCharArray());
-            }
-            return packageName;
+            return CharOperation.splitOn('.', this.packageName.toCharArray());
         }
 
+        /**
+         * @see org.eclipse.jdt.internal.compiler.env.IDependent#getFileName()
+         */
         public char[] getFileName() {
-            return compUnit.getSourceFileName().toCharArray();
+            return (this.mainTypeName + ".java").toCharArray();
         }
     }
 }
diff --git a/src/main/resources/META-INF/NOTICE b/src/main/resources/META-INF/NOTICE
index d7953a3..03ad88a 100644
--- a/src/main/resources/META-INF/NOTICE
+++ b/src/main/resources/META-INF/NOTICE
@@ -1,5 +1,5 @@
 Apache Sling Java Compiler
-Copyright 2008-2009 The Apache Software Foundation
+Copyright 2008-2010 The Apache Software Foundation
 
 Apache Sling is based on source code originally developed 
 by Day Software (http://www.day.com/).
diff --git a/src/test/java/org/apache/sling/commons/compiler/impl/CompilerJava5Test.java b/src/test/java/org/apache/sling/commons/compiler/impl/CompilerJava5Test.java
index 598eb33..c42b9b6 100644
--- a/src/test/java/org/apache/sling/commons/compiler/impl/CompilerJava5Test.java
+++ b/src/test/java/org/apache/sling/commons/compiler/impl/CompilerJava5Test.java
@@ -17,17 +17,16 @@
 package org.apache.sling.commons.compiler.impl;
 
 import java.io.ByteArrayOutputStream;
-import java.io.CharArrayWriter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.OutputStream;
 import java.io.Reader;
 
 import junit.framework.TestCase;
 
-import org.apache.sling.commons.compiler.ClassWriter;
-import org.apache.sling.commons.compiler.CompileUnit;
-import org.apache.sling.commons.compiler.CompilerEnvironment;
+import org.apache.sling.commons.classloader.ClassLoaderWriter;
+import org.apache.sling.commons.compiler.CompilationUnit;
 import org.apache.sling.commons.compiler.ErrorHandler;
 import org.apache.sling.commons.compiler.Options;
 
@@ -35,13 +34,18 @@ import org.apache.sling.commons.compiler.Options;
  * Test case for java 5 support
  */
 public class CompilerJava5Test extends TestCase
-        implements CompilerEnvironment, ErrorHandler, ClassWriter {
+        implements ErrorHandler, ClassLoaderWriter {
 
     public void testJava5Support() throws Exception {
         String sourceFile = "Java5Test";
 
-        CompileUnit unit = createCompileUnit(sourceFile);
-        new EclipseJavaCompiler().compile(new CompileUnit[]{unit}, this, this, this, new Options(Options.VERSION_1_5, true));
+        CompilationUnit unit = createCompileUnit(sourceFile);
+        final Options options = new Options();
+        options.put(Options.KEY_SOURCE_VERSION, Options.VERSION_1_5);
+        options.put(Options.KEY_CLASS_LOADER_WRITER, this);
+        options.put(Options.KEY_CLASS_LOADER, this.getClass().getClassLoader());
+
+        assertTrue(new EclipseJavaCompiler().compile(new CompilationUnit[]{unit}, this, options));
     }
 
     //---------------------------------------------------------< ErrorHandler >
@@ -54,102 +58,62 @@ public class CompilerJava5Test extends TestCase
         System.out.println("Warning in " + sourceFile + ", line " + line + ", pos. " + position + ": " + msg);
     }
 
-    //--------------------------------------------------< CompilerEnvironment >
-
-    public byte[] findClass(String className) throws Exception {
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        InputStream in = cl.getResourceAsStream(className.replace('.', '/') + ".class");
-        if (in == null) {
-            return null;
-        }
-        ByteArrayOutputStream out = new ByteArrayOutputStream(0x7fff);
-
-        try {
-            byte[] buffer = new byte[0x1000];
-            int read = 0;
-            while ((read = in.read(buffer)) > 0) {
-                out.write(buffer, 0, read);
-            }
-        } finally {
-            //out.close();
-            in.close();
-        }
+    //----------------------------------------------------------< ClassLoaderWriter >
 
-        return out.toByteArray();
-    }
+    //--------------------------------------------------------< misc. helpers >
 
-    public char[] findSource(String className) throws Exception {
-        return new char[0];
-    }
+    private CompilationUnit createCompileUnit(final String sourceFile) throws Exception {
+        return new CompilationUnit() {
 
-    public boolean isPackage(String packageName) {
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        InputStream in = cl.getResourceAsStream(packageName.replace('.', '/') + ".class");
-        if (in != null) {
-            try {
-                in.close();
-            } catch (IOException ignore) {
+            /**
+             * @see org.apache.sling.commons.compiler.CompilationUnit#getMainClassName()
+             */
+            public String getMainClassName() {
+                return "org.apache.sling.commons.compiler.test." + sourceFile;
             }
-            return false;
-        }
-        return true;
-    }
 
-    public void cleanup() {
+            /**
+             * @see org.apache.sling.commons.compiler.CompilationUnit#getSource()
+             */
+            public Reader getSource() throws IOException {
+                InputStream in = getClass().getClassLoader().getResourceAsStream(sourceFile);
+                return new InputStreamReader(in, "UTF-8");
+            }
+        };
     }
 
-    //----------------------------------------------------------< ClassWriter >
-
-    public void write(String className, byte[] data) throws Exception {
-        // nothing to do
+    /**
+     * @see org.apache.sling.commons.classloader.ClassLoaderWriter#delete(java.lang.String)
+     */
+    public boolean delete(String path) {
+        return false;
     }
 
-    //--------------------------------------------------------< misc. helpers >
-
-    private CompileUnit createCompileUnit(final String sourceFile) throws Exception {
-        final char[] chars = readTextResource(sourceFile);
-
-        return new CompileUnit() {
-
-            public String getSourceFileName() {
-                return sourceFile;
-            }
+    /**
+     * @see org.apache.sling.commons.classloader.ClassLoaderWriter#getInputStream(java.lang.String)
+     */
+    public InputStream getInputStream(String path) throws IOException {
+        return null;
+    }
 
-            public char[] getSourceFileContents() {
-                return chars;
-            }
+    /**
+     * @see org.apache.sling.commons.classloader.ClassLoaderWriter#getLastModified(java.lang.String)
+     */
+    public long getLastModified(String path) {
+        return 0;
+    }
 
-            public String getMainTypeName() {
-                String className;
-                int pos = sourceFile.lastIndexOf(".java");
-                if (pos != -1) {
-                    className = sourceFile.substring(0, pos).trim();
-                } else {
-                    className = sourceFile.trim();
-                }
-                pos = className.lastIndexOf('/');
-                return (pos == -1) ? className : className.substring(pos);
-            }
-        };
+    /**
+     * @see org.apache.sling.commons.classloader.ClassLoaderWriter#getOutputStream(java.lang.String)
+     */
+    public OutputStream getOutputStream(String path) {
+        return new ByteArrayOutputStream();
     }
 
-    private char[] readTextResource(String resourcePath) throws IOException {
-        InputStream in = getClass().getClassLoader().getResourceAsStream(resourcePath);
-        if (in == null) {
-            throw new IOException("resource not found");
-        }
-        Reader reader = new InputStreamReader(in);
-        CharArrayWriter writer = new CharArrayWriter(0x7fff);
-        try {
-            char[] buffer = new char[0x1000];
-            int read = 0;
-            while ((read = reader.read(buffer)) > 0) {
-                writer.write(buffer, 0, read);
-            }
-            return writer.toCharArray();
-        } finally {
-            //writer.close();
-            reader.close();
-        }
+    /**
+     * @see org.apache.sling.commons.classloader.ClassLoaderWriter#rename(java.lang.String, java.lang.String)
+     */
+    public boolean rename(String oldPath, String newPath) {
+        return false;
     }
 }
diff --git a/src/test/resources/Java5Test b/src/test/resources/Java5Test
index 83bf4ac..44658bc 100644
--- a/src/test/resources/Java5Test
+++ b/src/test/resources/Java5Test
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package  org.apache.sling.commons.compiler.test ;
+package org.apache.sling.commons.compiler.test;
 
 import java.util.List;
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-compiler] 02/14: Export version 1.0.0 of the API

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit 26c5d311c4da5bc85ba2206171aa16360754690d
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Nov 26 15:37:20 2009 +0000

    Export version 1.0.0 of the API
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@884591 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index e12d789..7fb7b01 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,7 +59,7 @@
                             !org.eclipse.*,*
                         </Import-Package>
                         <Export-Package>
-                            org.apache.sling.commons.compiler;version=${pom.version}
+                            org.apache.sling.commons.compiler;version=1.0.0
                         </Export-Package>
                         <Private-Package>
                             org.apache.sling.commons.compiler.impl

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-compiler] 13/14: [maven-release-plugin] prepare release org.apache.sling.commons.compiler-2.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit 759f50c5ce226d18e8d7db5db5b98fe559eb6cd4
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Dec 16 10:11:26 2010 +0000

    [maven-release-plugin] prepare release org.apache.sling.commons.compiler-2.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@1049861 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index a094192..e0b41b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.commons.compiler</artifactId>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>2.0.0</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Commons Java Compiler</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/commons/compiler</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.compiler-2.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.compiler-2.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.compiler-2.0.0</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-compiler] 12/14: Remove obsolete notice/licence files.

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit 2c73dc80380181685bb2a8c5043fe89ff0178743
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Dec 16 10:07:52 2010 +0000

    Remove obsolete notice/licence files.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@1049857 13f79535-47bb-0310-9956-ffa450edef68
---
 LICENSE                             | 202 -------------------------------
 NOTICE                              |   9 --
 src/main/resources/META-INF/LICENSE | 233 ------------------------------------
 src/main/resources/META-INF/NOTICE  |   8 --
 4 files changed, 452 deletions(-)

diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index d645695..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   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.
diff --git a/NOTICE b/NOTICE
deleted file mode 100644
index 76ff9f0..0000000
--- a/NOTICE
+++ /dev/null
@@ -1,9 +0,0 @@
-Apache Sling Java Compiler
-Copyright 2008-2010 The Apache Software Foundation
-
-Apache Sling is based on source code originally developed 
-by Day Software (http://www.day.com/).
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
diff --git a/src/main/resources/META-INF/LICENSE b/src/main/resources/META-INF/LICENSE
deleted file mode 100644
index 1b63f8d..0000000
--- a/src/main/resources/META-INF/LICENSE
+++ /dev/null
@@ -1,233 +0,0 @@
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   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.
-
-
-APACHE SLING SUBCOMPONENTS:
-
-Apache Sling includes subcomponents with separate copyright notices and
-license terms. Your use of these subcomponents is subject to the terms
-and conditions of the following licenses.
-
-SLF4J logging libraries
-
-   Copyright (c) 2004-2007 QOS.ch
-   All rights reserved.
-
-   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.
diff --git a/src/main/resources/META-INF/NOTICE b/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index 03ad88a..0000000
--- a/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,8 +0,0 @@
-Apache Sling Java Compiler
-Copyright 2008-2010 The Apache Software Foundation
-
-Apache Sling is based on source code originally developed 
-by Day Software (http://www.day.com/).
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-compiler] 07/14: SLING-1451 : Clean up compiler API and use classloading infrastructure

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit d8d0a63c9b7fdbd39ed3ae673280a5fcd9e407f7
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Mar 24 07:54:50 2010 +0000

    SLING-1451 : Clean up compiler API and use classloading infrastructure
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@926965 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/commons/compiler/CompilationResult.java  |  64 +++++++
 .../sling/commons/compiler/CompilationUnit.java    |   7 +
 .../sling/commons/compiler/CompilerMessage.java    | 101 ++++++++++++
 .../sling/commons/compiler/ErrorHandler.java       |  41 -----
 .../sling/commons/compiler/JavaCompiler.java       |  14 +-
 .../org/apache/sling/commons/compiler/Options.java |  10 ++
 .../compiler/impl/CompilationResultImpl.java       | 106 ++++++++++++
 .../commons/compiler/impl/EclipseJavaCompiler.java | 183 ++++++++++++++-------
 .../commons/compiler/impl/CompilerJava5Test.java   |  29 ++--
 9 files changed, 429 insertions(+), 126 deletions(-)

diff --git a/src/main/java/org/apache/sling/commons/compiler/CompilationResult.java b/src/main/java/org/apache/sling/commons/compiler/CompilationResult.java
new file mode 100644
index 0000000..4a72cbd
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/compiler/CompilationResult.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sling.commons.compiler;
+
+import java.util.List;
+
+/**
+ * The compilation result allows clients of the java compiler
+ * to check for error messages, warnings (if not disabled by
+ * the options) and allows to access the compiled classes.
+ * @since 2.0
+ */
+public interface CompilationResult {
+
+    /**
+     * Return a list of error messages that occured during
+     * compilation. If no errors occured <code>null</code>
+     * is returned.
+     * @return A list of error messages or <code>null</code>.
+     */
+    List<CompilerMessage> getErrors();
+
+    /**
+     * Return a list of warnings that occured during
+     * compilation. If no warnings occured <code>null</code>
+     * is returned.
+     * @return A list of warnings or <code>null</code>.
+     */
+    List<CompilerMessage> getWarnings();
+
+    /**
+     * Was a compilation required or were all classes recent?
+     * @return <code>true>/code> if classes were compiled.
+     */
+    boolean didCompile();
+
+    /**
+     * Try to load the compiled class.
+     * The class loading might fail if the className is not
+     * one of the compiled sources, if the compilation failed
+     * or if a class loader writer has been used in combination
+     * with a class loader that is not able to load the classes
+     * written by the class loader writer.
+     * @return The compiled class
+     * @throws ClassNotFoundException If the class could not be found
+     *         or compilation failed.
+     */
+    Class<?> loadCompiledClass(final String className)
+    throws ClassNotFoundException;
+}
diff --git a/src/main/java/org/apache/sling/commons/compiler/CompilationUnit.java b/src/main/java/org/apache/sling/commons/compiler/CompilationUnit.java
index fd060c2..415c237 100644
--- a/src/main/java/org/apache/sling/commons/compiler/CompilationUnit.java
+++ b/src/main/java/org/apache/sling/commons/compiler/CompilationUnit.java
@@ -38,4 +38,11 @@ public interface CompilationUnit {
      * @return the name of the top level public type.
      */
     String getMainClassName();
+
+    /**
+     * Return the last modified for the compilation unit.
+     * @return The last modified information or <code>-1</code> if
+     *         the information can't be detected.
+     */
+    long getLastModified();
 }
diff --git a/src/main/java/org/apache/sling/commons/compiler/CompilerMessage.java b/src/main/java/org/apache/sling/commons/compiler/CompilerMessage.java
new file mode 100644
index 0000000..fd98d7a
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/compiler/CompilerMessage.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sling.commons.compiler;
+
+/**
+ * This class encapsulates a message produced the compiler.
+ * A message is either a warning or an error.
+ * The messages are retrieved from the {@link CompilationResult}.
+ *
+ * @since 2.0
+ */
+public class CompilerMessage {
+
+    /**
+     * The line number of the offending program text
+     */
+    private final int line;
+
+    /**
+     * The column number of the offending program text
+     */
+    private final int column;
+
+    /**
+     * The name of the file containing the offending program text
+     */
+    private final String file;
+
+    /**
+     * The actual text
+     */
+    private final String message;
+
+    /**
+     * The error message constructor.
+     *
+     * @param file The name of the file containing the offending program text
+     * @param line The line number of the offending program text
+     * @param column The column number of the offending program text
+     * @param message The actual text
+     */
+    public CompilerMessage(final String file,
+                           final int line,
+                           final int column,
+                           final String message) {
+        this.file = file;
+        this.line = line;
+        this.column = column;
+        this.message = message;
+    }
+
+    /**
+     * Return the filename associated with this compiler message.
+     *
+     * @return The filename associated with this compiler message
+     */
+    public String getFile() {
+        return file;
+    }
+
+    /**
+     * Return the line number of the program text originating this message
+     *
+     * @return The line number of the program text originating this message
+     */
+    public int getLine() {
+        return this.line;
+    }
+
+    /**
+     * Return the column number of the program text originating this message
+     *
+     * @return The column number of the program text originating this message
+     */
+    public int getColumn() {
+        return this.column;
+    }
+
+    /**
+     * Return the message
+     *
+     * @return The message
+     */
+    public String getMessage() {
+        return message;
+    }
+}
diff --git a/src/main/java/org/apache/sling/commons/compiler/ErrorHandler.java b/src/main/java/org/apache/sling/commons/compiler/ErrorHandler.java
deleted file mode 100644
index cebb678..0000000
--- a/src/main/java/org/apache/sling/commons/compiler/ErrorHandler.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.sling.commons.compiler;
-
-/**
- * The error handler for the compilation.
- */
-public interface ErrorHandler {
-
-    /**
-     * Notify the handler of an error.
-     * @param msg The error message.
-     * @param sourceFile The source file the error occured in
-     * @param line The source line number
-     * @param position The column
-     */
-    void onError(String msg, String sourceFile, int line, int position);
-
-    /**
-     * Notify the handler of a warning.
-     * @param msg The warning message.
-     * @param sourceFile The source file the warning occured in
-     * @param line The source line number
-     * @param position The column
-     */
-    void onWarning(String msg, String sourceFile, int line, int position);
-}
diff --git a/src/main/java/org/apache/sling/commons/compiler/JavaCompiler.java b/src/main/java/org/apache/sling/commons/compiler/JavaCompiler.java
index 033b027..8d2d629 100644
--- a/src/main/java/org/apache/sling/commons/compiler/JavaCompiler.java
+++ b/src/main/java/org/apache/sling/commons/compiler/JavaCompiler.java
@@ -24,13 +24,17 @@ public interface JavaCompiler {
 
     /**
      * Compile the compilation units.
+     * This method checks if the compilation is necessary by using
+     * last modified check of the source to compile and the class
+     * file (if available).
+     * The compiler compiles all sources if at least one of the
+     * class files is out dated!
+     *
      * @param units The compilation units.
-     * @param errorHandler The error handler - this object is mandatory
      * @param options The compilation options - this object is optional
-     * @return <code>true</code> if compilation was successful
+     * @return The compilation result with more information.
      * @since 2.0
      */
-    boolean compile(CompilationUnit[] units,
-                    ErrorHandler errorHandler,
-                    Options options);
+    CompilationResult compile(CompilationUnit[] units,
+                              Options options);
 }
diff --git a/src/main/java/org/apache/sling/commons/compiler/Options.java b/src/main/java/org/apache/sling/commons/compiler/Options.java
index 4085e04..6a24fa3 100644
--- a/src/main/java/org/apache/sling/commons/compiler/Options.java
+++ b/src/main/java/org/apache/sling/commons/compiler/Options.java
@@ -63,6 +63,16 @@ public class Options extends HashMap<String, Object> {
      */
     public static final String KEY_ADDITIONAL_CLASS_LOADER = "classLoader";
 
+    /** The key to force the compilation - even if the class files are more recent.
+     * The value should be of type Boolean. */
+    public static final String KEY_FORCE_COMPILATION = "forceCompilation";
+
+    /** The key to ignore warnings - if this option is turned on, the
+     * resulting compilation result does not get the warnings issued
+     * by the compiler.
+     * The value should be of type Boolean. */
+    public static final String KEY_IGNORE_WARNINGS = "ignoreWarnings";
+
     /**
      * Default options with the following presets:
      * - generate debug info : true
diff --git a/src/main/java/org/apache/sling/commons/compiler/impl/CompilationResultImpl.java b/src/main/java/org/apache/sling/commons/compiler/impl/CompilationResultImpl.java
new file mode 100644
index 0000000..83f2e58
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/compiler/impl/CompilationResultImpl.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sling.commons.compiler.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.sling.commons.compiler.CompilationResult;
+import org.apache.sling.commons.compiler.CompilerMessage;
+
+/**
+ * Implementation of the compilation result
+ */
+public class CompilationResultImpl implements CompilationResult {
+
+    private List<CompilerMessage> errors;
+
+    private List<CompilerMessage> warnings;
+
+    private final boolean ignoreWarnings;
+
+    private final boolean compilationRequired;
+
+    private final ClassLoader classLoader;
+
+    public CompilationResultImpl(final ClassLoader classLoader) {
+        this.ignoreWarnings = true;
+        this.classLoader = classLoader;
+        this.compilationRequired = false;
+    }
+
+    public CompilationResultImpl(final boolean ignoreWarnings,
+                                 final ClassLoader classLoader) {
+        this.ignoreWarnings = ignoreWarnings;
+        this.classLoader = classLoader;
+        this.compilationRequired = true;
+    }
+
+    /**
+     * @see org.apache.sling.commons.compiler.CompilationResult#getErrors()
+     */
+    public List<CompilerMessage> getErrors() {
+        return this.errors;
+    }
+
+    /**
+     * @see org.apache.sling.commons.compiler.CompilationResult#getWarnings()
+     */
+    public List<CompilerMessage> getWarnings() {
+        return this.warnings;
+    }
+
+    /**
+     * @see org.apache.sling.commons.compiler.CompilationResult#loadCompiledClass(java.lang.String)
+     */
+    public Class<?> loadCompiledClass(final String className)
+    throws ClassNotFoundException {
+        if ( errors != null ) {
+            throw new ClassNotFoundException(className);
+        }
+        return this.classLoader.loadClass(className);
+    }
+
+    /**
+     * @see org.apache.sling.commons.compiler.CompilationResult#didCompile()
+     */
+    public boolean didCompile() {
+        return this.compilationRequired;
+    }
+
+    /**
+     * Notification of an error
+     */
+    public void onError(String msg, String sourceFile, int line, int position) {
+        if ( errors == null ) {
+            errors = new ArrayList<CompilerMessage>();
+        }
+        errors.add(new CompilerMessage(sourceFile, line, position, msg));
+    }
+
+    /**
+     * Notification of a warning
+     */
+    public void onWarning(String msg, String sourceFile, int line, int position) {
+        if ( !this.ignoreWarnings ) {
+            if ( warnings == null ) {
+                warnings = new ArrayList<CompilerMessage>();
+            }
+            warnings.add(new CompilerMessage(sourceFile, line, position, msg));
+        }
+    }
+}
diff --git a/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java b/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
index bac1a1d..641be1c 100644
--- a/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
+++ b/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
@@ -32,14 +32,13 @@ import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.commons.classloader.ClassLoaderWriter;
 import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
+import org.apache.sling.commons.compiler.CompilationResult;
 import org.apache.sling.commons.compiler.CompilationUnit;
-import org.apache.sling.commons.compiler.ErrorHandler;
 import org.apache.sling.commons.compiler.JavaCompiler;
 import org.apache.sling.commons.compiler.Options;
 import org.eclipse.jdt.core.compiler.CategorizedProblem;
 import org.eclipse.jdt.core.compiler.CharOperation;
 import org.eclipse.jdt.internal.compiler.ClassFile;
-import org.eclipse.jdt.internal.compiler.CompilationResult;
 import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
 import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
 import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
@@ -101,7 +100,7 @@ public class EclipseJavaCompiler implements JavaCompiler {
     }
 
     /**
-     * Get the class loader
+     * Get the commons dynamic class loader
      */
     private void getClassLoader(final DynamicClassLoaderManager rclp) {
         this.dynamicClassLoaderManager = rclp;
@@ -109,7 +108,7 @@ public class EclipseJavaCompiler implements JavaCompiler {
     }
 
     /**
-     * Unget the class loader
+     * Unget the commons dynamic class loader
      */
     private void ungetClassLoader() {
         this.classLoader = null;
@@ -117,13 +116,109 @@ public class EclipseJavaCompiler implements JavaCompiler {
     }
 
     /**
-     * @see org.apache.sling.commons.compiler.JavaCompiler#compile(org.apache.sling.commons.compiler.CompilationUnit[], org.apache.sling.commons.compiler.ErrorHandler, org.apache.sling.commons.compiler.Options)
+     * Get the classloader for the compilation.
      */
-    public boolean compile(final CompilationUnit[] units,
-                           final ErrorHandler errorHandler,
-                           final Options compileOptions) {
+    private ClassLoader getClassLoader(final Options options) {
+        final ClassLoader loader;
+        if ( options.get(Options.KEY_CLASS_LOADER) != null ) {
+            loader = (ClassLoader)options.get(Options.KEY_CLASS_LOADER);
+        } else if ( options.get(Options.KEY_ADDITIONAL_CLASS_LOADER) != null ) {
+            final ClassLoader additionalClassLoader = (ClassLoader)options.get(Options.KEY_ADDITIONAL_CLASS_LOADER);
+            loader = new ClassLoader(this.classLoader) {
+                protected Class<?> findClass(String name)
+                throws ClassNotFoundException {
+                    return additionalClassLoader.loadClass(name);
+                }
+
+                protected URL findResource(String name) {
+                    return additionalClassLoader.getResource(name);
+                }
+            };
+        } else {
+            loader = this.classLoader;
+        }
+        return loader;
+    }
+
+    /**
+     * Get the class loader writer for the compilation.
+     */
+    private ClassLoaderWriter getClassLoaderWriter(final Options options) {
+        if (options.get(Options.KEY_CLASS_LOADER_WRITER) != null ) {
+            return (ClassLoaderWriter)options.get(Options.KEY_CLASS_LOADER_WRITER);
+        }
+        return this.classLoaderWriter;
+    }
+
+    /**
+     * Check if the compiled class file is older than the source file
+     */
+    private boolean isOutDated(final CompilationUnit unit,
+                               final ClassLoaderWriter writer) {
+        final long targetLastModified = writer.getLastModified('/' + unit.getMainClassName().replace('.', '/') + ".class");
+        if (targetLastModified < 0) {
+            return true;
+        }
+
+        return targetLastModified < unit.getLastModified();
+    }
+
+    /**
+     * Return the force compilation value
+     */
+    private boolean isForceCompilation(final Options options) {
+        final Boolean flag = (Boolean)options.get(Options.KEY_FORCE_COMPILATION);
+        if ( flag != null ) {
+            return flag;
+        }
+        return false;
+    }
+
+    /**
+     * Return the ignore warnings value
+     */
+    private boolean isIgnoreWarnings(final Options options) {
+        final Boolean flag = (Boolean)options.get(Options.KEY_IGNORE_WARNINGS);
+        if ( flag != null ) {
+            return flag;
+        }
+        return false;
+    }
+
+    private static final Options EMPTY_OPTIONS = new Options();
+
+    /**
+     * @see org.apache.sling.commons.compiler.JavaCompiler#compile(org.apache.sling.commons.compiler.CompilationUnit[], org.apache.sling.commons.compiler.Options)
+     */
+    public CompilationResult compile(final CompilationUnit[] units,
+                                     final Options compileOptions) {
         // make sure we have an options object (to avoid null checks all over the place)
-        final Options options = (compileOptions != null ? compileOptions : new Options());
+        final Options options = (compileOptions != null ? compileOptions : EMPTY_OPTIONS);
+
+        // get classloader and classloader writer
+        final ClassLoader loader = this.getClassLoader(options);
+        final ClassLoaderWriter writer = this.getClassLoaderWriter(options);
+
+        // check sources for compilation
+        boolean needsCompilation = isForceCompilation(options);
+        if ( !needsCompilation ) {
+            for(final CompilationUnit unit : units) {
+                if ( this.isOutDated(unit, writer) ) {
+                    needsCompilation = true;
+                    break;
+                }
+            }
+        }
+        if ( !needsCompilation ) {
+            logger.debug("All source files are recent - no compilation required.");
+            return new CompilationResultImpl(loader);
+        }
+
+        // delete old class files
+        for(final CompilationUnit unit : units) {
+            final String name = '/' + unit.getMainClassName().replace('.', '/') + ".class";
+            writer.delete(name);
+        }
 
         // create properties for the settings object
         final Map<String, String> props = new HashMap<String, String>();
@@ -146,32 +241,10 @@ public class EclipseJavaCompiler implements JavaCompiler {
         final CompilerOptions settings = new CompilerOptions(props);
         logger.debug("Compiling with settings {}.", settings);
 
-        // classloader
-        final ClassLoader loader;
-        if ( options.get(Options.KEY_CLASS_LOADER) != null ) {
-            loader = (ClassLoader)options.get(Options.KEY_CLASS_LOADER);
-        } else if ( options.get(Options.KEY_ADDITIONAL_CLASS_LOADER) != null ) {
-            final ClassLoader additionalClassLoader = (ClassLoader)options.get(Options.KEY_ADDITIONAL_CLASS_LOADER);
-            loader = new ClassLoader(this.classLoader) {
-                protected Class<?> findClass(String name)
-                throws ClassNotFoundException {
-                    return additionalClassLoader.loadClass(name);
-                }
-
-                protected URL findResource(String name) {
-                    return additionalClassLoader.getResource(name);
-                }
-            };
-        } else {
-            loader = this.classLoader;
-        }
-
-        // classloader writer
-        final ClassLoaderWriter writer = (options.get(Options.KEY_CLASS_LOADER_WRITER) != null ?
-                (ClassLoaderWriter)options.get(Options.KEY_CLASS_LOADER_WRITER) : this.classLoaderWriter);
-
+        // create the result
+        final CompilationResultImpl result = new CompilationResultImpl(isIgnoreWarnings(options), loader);
         // create the context
-        final CompileContext context = new CompileContext(units, errorHandler, writer, loader);
+        final CompileContext context = new CompileContext(units, result, writer, loader);
 
         // create the compiler
         final org.eclipse.jdt.internal.compiler.Compiler compiler =
@@ -186,31 +259,28 @@ public class EclipseJavaCompiler implements JavaCompiler {
         // compile
         compiler.compile(context.getSourceUnits());
 
-        return !context.hasErrors;
+        return result;
     }
 
     //--------------------------------------------------------< inner classes >
 
-    private class CompileContext implements ICompilerRequestor, INameEnvironment, ErrorHandler {
+    private class CompileContext implements ICompilerRequestor, INameEnvironment {
 
         private final Map<String,ICompilationUnit> compUnits;
 
-        private final ErrorHandler errorHandler;
+        private final CompilationResultImpl errorHandler;
         private final ClassLoaderWriter classLoaderWriter;
         private final ClassLoader classLoader;
 
-        /** Flag indicating if we have an error. */
-        private boolean hasErrors = false;
-
         public CompileContext(final CompilationUnit[] units,
-         		              final ErrorHandler errorHandler,
+         		              final CompilationResultImpl errorHandler,
         		              final ClassLoaderWriter classWriter,
         		              final ClassLoader classLoader) {
         	this.compUnits = new HashMap<String,ICompilationUnit>();
             for (int i = 0; i < units.length; i++) {
-                CompilationUnitAdapter cua = new CompilationUnitAdapter(units[i], this);
+                CompilationUnitAdapter cua = new CompilationUnitAdapter(units[i], errorHandler);
                 char[][] compoundName = CharOperation.arrayConcat(cua.getPackageName(), cua.getMainTypeName());
-                this.compUnits.put(CharOperation.toString(compoundName), new CompilationUnitAdapter(units[i], this));
+                this.compUnits.put(CharOperation.toString(compoundName), new CompilationUnitAdapter(units[i], errorHandler));
             }
 
         	this.errorHandler = errorHandler;
@@ -218,21 +288,6 @@ public class EclipseJavaCompiler implements JavaCompiler {
             this.classLoader = classLoader;
         }
 
-        /**
-         * @see org.apache.sling.commons.compiler.ErrorHandler#onError(java.lang.String, java.lang.String, int, int)
-         */
-        public void onError(String msg, String sourceFile, int line, int position) {
-            this.errorHandler.onError(msg, sourceFile, line, position);
-            this.hasErrors = true;
-        }
-
-        /**
-         * @see org.apache.sling.commons.compiler.ErrorHandler#onWarning(java.lang.String, java.lang.String, int, int)
-         */
-        public void onWarning(String msg, String sourceFile, int line, int position) {
-            this.errorHandler.onWarning(msg, sourceFile, line, position);
-        }
-
         public ICompilationUnit[] getSourceUnits() {
         	return compUnits.values().toArray(
         			new ICompilationUnit[compUnits.size()]);
@@ -241,7 +296,7 @@ public class EclipseJavaCompiler implements JavaCompiler {
         /**
          * @see org.eclipse.jdt.internal.compiler.ICompilerRequestor#acceptResult(org.eclipse.jdt.internal.compiler.CompilationResult)
          */
-        public void acceptResult(CompilationResult result) {
+        public void acceptResult(org.eclipse.jdt.internal.compiler.CompilationResult result) {
             if (result.hasProblems()) {
                 CategorizedProblem[] problems = result.getProblems();
                 for (int i = 0; i < problems.length; i++) {
@@ -252,9 +307,9 @@ public class EclipseJavaCompiler implements JavaCompiler {
                     int pos = problem.getSourceStart();
 
                     if (problem.isError()) {
-                        this.onError(msg, fileName, line, pos);
+                        this.errorHandler.onError(msg, fileName, line, pos);
                     } else if (problem.isWarning()) {
-                        this.onWarning(msg, fileName, line, pos);
+                        this.errorHandler.onWarning(msg, fileName, line, pos);
                     } else {
                         logger.debug("unknown problem category: {}", problem);
                     }
@@ -267,7 +322,7 @@ public class EclipseJavaCompiler implements JavaCompiler {
                 try {
                     this.write(className, classFile.getBytes());
                 } catch (IOException e) {
-                    this.onError("Unable to write class file: " + e.getMessage(), className, 0, 0);
+                    this.errorHandler.onError("Unable to write class file: " + e.getMessage(), className, 0, 0);
                 }
             }
         }
@@ -368,12 +423,12 @@ public class EclipseJavaCompiler implements JavaCompiler {
 
     private class CompilationUnitAdapter implements ICompilationUnit {
 
-        private final ErrorHandler errorHandler;
+        private final CompilationResultImpl errorHandler;
         private final CompilationUnit compUnit;
         private final String mainTypeName;
         private final String packageName;
 
-        public CompilationUnitAdapter(final CompilationUnit compUnit, final ErrorHandler errorHandler) {
+        public CompilationUnitAdapter(final CompilationUnit compUnit, final CompilationResultImpl errorHandler) {
             this.compUnit = compUnit;
             this.errorHandler = errorHandler;
             final int pos = compUnit.getMainClassName().lastIndexOf('.');
diff --git a/src/test/java/org/apache/sling/commons/compiler/impl/CompilerJava5Test.java b/src/test/java/org/apache/sling/commons/compiler/impl/CompilerJava5Test.java
index c42b9b6..c409ca0 100644
--- a/src/test/java/org/apache/sling/commons/compiler/impl/CompilerJava5Test.java
+++ b/src/test/java/org/apache/sling/commons/compiler/impl/CompilerJava5Test.java
@@ -26,15 +26,15 @@ import java.io.Reader;
 import junit.framework.TestCase;
 
 import org.apache.sling.commons.classloader.ClassLoaderWriter;
+import org.apache.sling.commons.compiler.CompilationResult;
 import org.apache.sling.commons.compiler.CompilationUnit;
-import org.apache.sling.commons.compiler.ErrorHandler;
 import org.apache.sling.commons.compiler.Options;
 
 /**
  * Test case for java 5 support
  */
 public class CompilerJava5Test extends TestCase
-        implements ErrorHandler, ClassLoaderWriter {
+        implements ClassLoaderWriter {
 
     public void testJava5Support() throws Exception {
         String sourceFile = "Java5Test";
@@ -45,21 +45,11 @@ public class CompilerJava5Test extends TestCase
         options.put(Options.KEY_CLASS_LOADER_WRITER, this);
         options.put(Options.KEY_CLASS_LOADER, this.getClass().getClassLoader());
 
-        assertTrue(new EclipseJavaCompiler().compile(new CompilationUnit[]{unit}, this, options));
+        final CompilationResult result = new EclipseJavaCompiler().compile(new CompilationUnit[]{unit}, options);
+        assertNotNull(result);
+        assertNull(result.getErrors());
     }
 
-    //---------------------------------------------------------< ErrorHandler >
-
-    public void onError(String msg, String sourceFile, int line, int position) {
-        System.out.println("Error in " + sourceFile + ", line " + line + ", pos. " + position + ": " + msg);
-    }
-
-    public void onWarning(String msg, String sourceFile, int line, int position) {
-        System.out.println("Warning in " + sourceFile + ", line " + line + ", pos. " + position + ": " + msg);
-    }
-
-    //----------------------------------------------------------< ClassLoaderWriter >
-
     //--------------------------------------------------------< misc. helpers >
 
     private CompilationUnit createCompileUnit(final String sourceFile) throws Exception {
@@ -79,6 +69,13 @@ public class CompilerJava5Test extends TestCase
                 InputStream in = getClass().getClassLoader().getResourceAsStream(sourceFile);
                 return new InputStreamReader(in, "UTF-8");
             }
+
+            /**
+             * @see org.apache.sling.commons.compiler.CompilationUnit#getLastModified()
+             */
+            public long getLastModified() {
+                return 0;
+            }
         };
     }
 
@@ -100,7 +97,7 @@ public class CompilerJava5Test extends TestCase
      * @see org.apache.sling.commons.classloader.ClassLoaderWriter#getLastModified(java.lang.String)
      */
     public long getLastModified(String path) {
-        return 0;
+        return -1;
     }
 
     /**

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-compiler] 01/14: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit 9a15676a54ab628543e0f5661fc5c10af4a83fed
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Nov 26 15:31:41 2009 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@884582 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index bea9649..e12d789 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.commons.compiler</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Commons Java Compiler</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.compiler-1.0.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.compiler-1.0.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.compiler-1.0.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/commons/compiler</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-compiler] 14/14: [maven-scm] copy for tag org.apache.sling.commons.compiler-2.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit 1e4e705a6998e1df99b6ec001c7022933e38ef6f
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Dec 16 10:11:39 2010 +0000

    [maven-scm] copy for tag org.apache.sling.commons.compiler-2.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.compiler-2.0.0@1049862 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-compiler] 06/14: SLING-1451 : Clean up compiler API and use classloading infrastructure

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit b50cd86fb7957cdf5122991208ea77fb8c290f85
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Mar 19 15:58:57 2010 +0000

    SLING-1451 : Clean up compiler API and use classloading infrastructure
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@925291 13f79535-47bb-0310-9956-ffa450edef68
---
 src/main/java/org/apache/sling/commons/compiler/Options.java | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/main/java/org/apache/sling/commons/compiler/Options.java b/src/main/java/org/apache/sling/commons/compiler/Options.java
index 366f6f0..4085e04 100644
--- a/src/main/java/org/apache/sling/commons/compiler/Options.java
+++ b/src/main/java/org/apache/sling/commons/compiler/Options.java
@@ -71,6 +71,13 @@ public class Options extends HashMap<String, Object> {
         this.put(KEY_GENERATE_DEBUG_INFO, true);
     }
 
+    /**
+     * Create a new options object based on an existing one.
+     */
+    public Options(final Options options) {
+        super(options);
+    }
+
     public String getSourceVersion() {
         return (String) this.get(KEY_SOURCE_VERSION);
     }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-compiler] 08/14: SLING-1459 : Make references to class loader manager and class loader writer dynamic

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit fedaf7fccca6c2ef09af9ce3fba4afbd54079156
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Mar 24 08:01:33 2010 +0000

    SLING-1459 :  Make references to class loader manager and class loader writer dynamic
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@926966 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/commons/compiler/impl/CompilationResultImpl.java    |  7 +++++++
 .../sling/commons/compiler/impl/EclipseJavaCompiler.java      | 11 +++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/commons/compiler/impl/CompilationResultImpl.java b/src/main/java/org/apache/sling/commons/compiler/impl/CompilationResultImpl.java
index 83f2e58..83baef6 100644
--- a/src/main/java/org/apache/sling/commons/compiler/impl/CompilationResultImpl.java
+++ b/src/main/java/org/apache/sling/commons/compiler/impl/CompilationResultImpl.java
@@ -37,6 +37,13 @@ public class CompilationResultImpl implements CompilationResult {
 
     private final ClassLoader classLoader;
 
+    public CompilationResultImpl(final String errorMessage) {
+        this.ignoreWarnings = true;
+        this.classLoader = null;
+        this.compilationRequired = false;
+        this.onError(errorMessage, "<General>", 0, 0);
+    }
+
     public CompilationResultImpl(final ClassLoader classLoader) {
         this.ignoreWarnings = true;
         this.classLoader = classLoader;
diff --git a/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java b/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
index 641be1c..7893d9c 100644
--- a/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
+++ b/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
@@ -29,6 +29,7 @@ import java.util.Map;
 
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.commons.classloader.ClassLoaderWriter;
 import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
@@ -64,10 +65,10 @@ public class EclipseJavaCompiler implements JavaCompiler {
     /** Logger instance */
     private final Logger logger = LoggerFactory.getLogger(EclipseJavaCompiler.class);
 
-    @Reference
+    @Reference(policy=ReferencePolicy.DYNAMIC)
     private ClassLoaderWriter classLoaderWriter;
 
-    @Reference
+    @Reference(policy=ReferencePolicy.DYNAMIC)
     private DynamicClassLoaderManager dynamicClassLoaderManager;
 
     private ClassLoader classLoader;
@@ -197,7 +198,13 @@ public class EclipseJavaCompiler implements JavaCompiler {
 
         // get classloader and classloader writer
         final ClassLoader loader = this.getClassLoader(options);
+        if ( loader == null ) {
+            return new CompilationResultImpl("Class loader for compilation is not available.");
+        }
         final ClassLoaderWriter writer = this.getClassLoaderWriter(options);
+        if ( writer == null ) {
+            return new CompilationResultImpl("Class loader writer for compilation is not available.");
+        }
 
         // check sources for compilation
         boolean needsCompilation = isForceCompilation(options);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-compiler] 11/14: SLING-1809 : Eclipse compiler used in commons.compiler causes "Illegal type in constant pool" with

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit 6238b6aad51600f72f495a950633e1016b99fd5e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Dec 16 09:39:27 2010 +0000

    SLING-1809 : Eclipse compiler used in commons.compiler causes "Illegal type in constant pool" with
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@1049850 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java    | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java b/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
index 7893d9c..e34e2ab 100644
--- a/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
+++ b/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
@@ -236,8 +236,7 @@ public class EclipseJavaCompiler implements JavaCompiler {
         }
         if (options.getSourceVersion() != null) {
             props.put("org.eclipse.jdt.core.compiler.source", options.getSourceVersion());
-            //props.put("org.eclipse.jdt.core.compiler.compliance", options.getSourceVersion());
-            //props.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", options.getSourceVersion());
+            props.put("org.eclipse.jdt.core.compiler.compliance", options.getSourceVersion());
         }
         if (options.getTargetVersion() != null) {
             props.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", options.getTargetVersion());

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-compiler] 04/14: SLING-1436 Upgrade Eclipse compiler to latest version 3.3.0-v_771

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit 21155d0aa18b50212ea4111f969390db1ae0454f
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Thu Mar 11 14:32:01 2010 +0000

    SLING-1436 Upgrade Eclipse compiler to latest version 3.3.0-v_771
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@921870 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index ddacce3..3c2906d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,7 +90,17 @@
         <dependency>
             <groupId>org.eclipse.jdt</groupId>
             <artifactId>core</artifactId>
-            <version>3.2.0.666</version>
+            <version>3.3.0-v_771</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.eclipse.equinox</groupId>
+                    <artifactId>app</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.eclipse.equinox</groupId>
+                    <artifactId>common</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-compiler] 10/14: Add serial version

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit 2040e0d71926229ce18dd5be7b67a2ebcea1f32c
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Aug 24 14:33:01 2010 +0000

    Add serial version
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@988567 13f79535-47bb-0310-9956-ffa450edef68
---
 src/main/java/org/apache/sling/commons/compiler/Options.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/main/java/org/apache/sling/commons/compiler/Options.java b/src/main/java/org/apache/sling/commons/compiler/Options.java
index 6a24fa3..d3985d1 100644
--- a/src/main/java/org/apache/sling/commons/compiler/Options.java
+++ b/src/main/java/org/apache/sling/commons/compiler/Options.java
@@ -23,6 +23,8 @@ import java.util.HashMap;
  */
 public class Options extends HashMap<String, Object> {
 
+    private static final long serialVersionUID = 1576005888428747431L;
+
     /** The key for the source version. */
     public static final String KEY_SOURCE_VERSION = "sourceVersion";
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-compiler] 03/14: SLING-1205 Upgrade all projects to parent POM 8 and use OSGi provided OSGi libraries

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.compiler-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git

commit b22889826dd9e6ec8c141be0b9b5ca03c8bc8997
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Tue Dec 1 07:32:34 2009 +0000

    SLING-1205 Upgrade all projects to parent POM 8 and use OSGi provided OSGi libraries
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@885680 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 7fb7b01..ddacce3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>7</version>
+        <version>8</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.