sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-org-apache-sling-commons-compiler] 01/18: SLING-873 : Add new commons compiler bundle. Applied patch from Stefan Guggisberg.
Date Tue, 07 Nov 2017 09:20:14 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit f497e80243d4791b4189800a18a2dabea25a224a
Author: Carsten Ziegeler <cziegeler@apache.org>
AuthorDate: Wed Feb 25 16:54:01 2009 +0000

    SLING-873 : Add new commons compiler bundle. Applied patch from Stefan Guggisberg.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/contrib/commons/compiler@747859 13f79535-47bb-0310-9956-ffa450edef68
---
 LICENSE                                            | 202 ++++++++++++++
 NOTICE                                             |   9 +
 README.txt                                         |  37 +++
 pom.xml                                            |  93 +++++++
 .../apache/sling/commons/compiler/ClassWriter.java |  29 ++
 .../apache/sling/commons/compiler/CompileUnit.java |  42 +++
 .../commons/compiler/CompilerEnvironment.java      |  51 ++++
 .../sling/commons/compiler/ErrorHandler.java       |  41 +++
 .../sling/commons/compiler/JavaCompiler.java       |  38 +++
 .../org/apache/sling/commons/compiler/Options.java |  56 ++++
 .../commons/compiler/impl/EclipseJavaCompiler.java | 303 +++++++++++++++++++++
 src/main/resources/META-INF/DISCLAIMER             |   7 +
 src/main/resources/META-INF/LICENSE                | 233 ++++++++++++++++
 src/main/resources/META-INF/NOTICE                 |   8 +
 .../commons/compiler/impl/CompilerJava5Test.java   | 159 +++++++++++
 .../compiler/impl/EclipseJavaCompilerTest.java     |  45 +++
 src/test/resources/Java5Test                       |  31 +++
 17 files changed, 1384 insertions(+)

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+                                 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
new file mode 100644
index 0000000..3341854
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,9 @@
+Apache Sling Java Compiler
+Copyright 2008-2009 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/README.txt b/README.txt
new file mode 100644
index 0000000..30d5a38
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,37 @@
+Apache Sling Commons Java Compiler
+
+The Sling Commons Java Compiler bundle provides platform independant Java Compilation 
+support using the Eclipse Java Compiler (org.eclipse.jdt).
+
+Disclaimer
+==========
+Apache Sling is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Jackrabbit PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other
+successful ASF projects. While incubation status is not necessarily a reflection of
+the completeness or stability of the code, it does indicate that the project has yet
+to be fully endorsed by the ASF.
+
+Getting Started
+===============
+
+This component uses a Maven 2 (http://maven.apache.org/) build
+environment. It requires a Java 5 JDK (or higher) and Maven (http://maven.apache.org/)
+2.0.7 or later. We recommend to use the latest Maven version.
+
+If you have Maven 2 installed, you can compile and
+package the jar using the following command:
+
+    mvn package
+
+See the Maven 2 documentation for other build features.
+
+The latest source code for this component is available in the
+Subversion (http://subversion.tigris.org/) source repository of
+the Apache Software Foundation. If you have Subversion installed,
+you can checkout the latest source using the following command:
+
+    svn checkout http://svn.apache.org/repos/asf/incubator/sling/trunk/contrib/commons/compiler
+
+See the Subversion documentation for other source control features.
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..4a09993
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>5-incubator-SNAPSHOT</version>
+        <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.sling.commons.compiler</artifactId>
+    <version>0.9.0-incubator-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <name>Apache Sling Commons Java Compiler</name>
+    <description>
+        The Sling Commons Java Compiler bundle provides platform independant Java Compilation 
+        support using the Eclipse Java Compiler (org.eclipse.jdt).
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/contrib/commons/compiler</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/contrib/commons/compiler</developerConnection>
+        <url>http://svn.apache.org/viewvc/incubator/sling/trunk/contrib/commons/compiler</url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Export-Package>
+                            org.apache.sling.commons.compiler;version=${pom.version},
+                        </Export-Package>
+                        <Embed-Dependency>
+                            core
+                        </Embed-Dependency>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.eclipse.jdt</groupId>
+            <artifactId>core</artifactId>
+            <version>3.2.0.666</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+        <!-- testing -->
+        <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
new file mode 100644
index 0000000..7ab2da0
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/compiler/ClassWriter.java
@@ -0,0 +1,29 @@
+/*
+ * $URL$
+ * $Id$
+ *
+ * Copyright 1997-2007 Day Management AG
+ * Barfuesserplatz 6, 4001 Basel, Switzerland
+ * All Rights Reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * Day Management AG, ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with Day.
+ */
+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/CompileUnit.java
new file mode 100644
index 0000000..9fbd2f0
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/compiler/CompileUnit.java
@@ -0,0 +1,42 @@
+/*
+ * 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 CompileUnit {
+
+    /**
+     *
+     * @return
+     */
+    String getSourceFileName();
+
+    /**
+     *
+     * @return
+     */
+    char[] getSourceFileContents();
+
+    /**
+     * Returns the name of the top level public type.
+     *
+     * @return the name of the top level public type.
+     */
+    String getMainTypeName();
+}
diff --git a/src/main/java/org/apache/sling/commons/compiler/CompilerEnvironment.java b/src/main/java/org/apache/sling/commons/compiler/CompilerEnvironment.java
new file mode 100644
index 0000000..b8c827b
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/compiler/CompilerEnvironment.java
@@ -0,0 +1,51 @@
+/*
+ * 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 {
+
+    /**
+     *
+     * @param className
+     * @return
+     * @throws Exception
+     */
+    byte[] findClass(String className) throws Exception;
+
+    /**
+     *
+     * @param className
+     * @return
+     * @throws Exception
+     */
+    char[] findSource(String className) throws Exception;
+
+    /**
+     *  
+     * @param packageName
+     * @return
+     */
+    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
new file mode 100644
index 0000000..40cf544
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/compiler/ErrorHandler.java
@@ -0,0 +1,41 @@
+/*
+ * 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 ErrorHandler {
+
+    /**
+     *
+     * @param msg
+     * @param sourceFile
+     * @param line
+     * @param position
+     */
+    void onError(String msg, String sourceFile, int line, int position);
+
+    /**
+     *
+     * @param msg
+     * @param sourceFile
+     * @param line
+     * @param position
+     */
+    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
new file mode 100644
index 0000000..a92b9ed
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/compiler/JavaCompiler.java
@@ -0,0 +1,38 @@
+/*
+ * 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 <code>JavaCompiler</code> provides platform independant Java Compilation 
+ * support.
+ */
+public interface JavaCompiler {
+
+	/**
+     *
+     * @param units
+     * @param env
+     * @param classWriter
+     * @param errorHandler
+     * @param generateDebugInfo
+     * @param sourceVersion
+     * @return
+     */
+    boolean compile(CompileUnit[] units, CompilerEnvironment env,
+                        ClassWriter classWriter, 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
new file mode 100644
index 0000000..23b0625
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/compiler/Options.java
@@ -0,0 +1,56 @@
+/*
+ * 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 class Options {
+
+    public static final String VERSION_RUNTIME = null;
+    public static final String VERSION_1_1 = "1.1";
+    public static final String VERSION_1_2 = "1.2";
+    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"; 
+
+    protected String sourceVersion;
+    protected boolean generateDebugInfo;
+
+    public Options() {
+        this(VERSION_RUNTIME, true);
+    }
+    
+    public Options(String sourceVersion, boolean generateDebugInfo) {
+        this.sourceVersion = sourceVersion;
+        this.generateDebugInfo = generateDebugInfo;
+    }
+
+    public String getSourceVersion() {
+        return sourceVersion;
+    }
+
+    public void setSourceVersion(String sourceVersion) {
+        this.sourceVersion = sourceVersion;
+    }
+
+    public boolean isGenerateDebugInfo() {
+        return generateDebugInfo;
+    }
+
+    public void setGenerateDebugInfo(boolean generateDebugInfo) {
+        this.generateDebugInfo = generateDebugInfo;
+    }
+}
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
new file mode 100644
index 0000000..7a49601
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
@@ -0,0 +1,303 @@
+/*
+ * 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 org.apache.sling.commons.compiler.ClassWriter;
+import org.apache.sling.commons.compiler.CompileUnit;
+import org.apache.sling.commons.compiler.JavaCompiler;
+import org.apache.sling.commons.compiler.CompilerEnvironment;
+import org.apache.sling.commons.compiler.ErrorHandler;
+import org.apache.sling.commons.compiler.Options;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
+import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
+import org.eclipse.jdt.internal.compiler.IProblemFactory;
+import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
+import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
+import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.ClassFile;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Locale;
+import java.util.HashMap;
+import java.io.PrintWriter;
+import java.io.CharArrayReader;
+import java.io.BufferedReader;
+import java.io.IOException;
+
+/**
+ * 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"
+ */
+public class EclipseJavaCompiler implements JavaCompiler {
+
+    /** Logger instance */
+    private static final Logger log = LoggerFactory.getLogger(JavaCompiler.class);
+
+    // the static problem factory
+    private static IProblemFactory PROBLEM_FACTORY =
+        new DefaultProblemFactory(Locale.getDefault());
+
+    public EclipseJavaCompiler() {
+    }
+
+    /**
+     *
+     * @param units
+     * @param env
+     * @param classWriter
+     * @param errorHandler
+     * @param options
+     * @return
+     */
+    public boolean compile(CompileUnit[] units, CompilerEnvironment env,
+            ClassWriter classWriter, ErrorHandler errorHandler,
+            Options options) {
+
+        IErrorHandlingPolicy policy =
+            DefaultErrorHandlingPolicies.proceedWithAllProblems();
+
+        // output for non-error log messages
+        PrintWriter logWriter = null;
+
+        if (options == null) {
+            options = new Options();
+        }
+        
+        HashMap props = new HashMap();
+        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);
+        }
+        //options.put("org.eclipse.jdt.core.encoding", "UTF8");
+        CompilerOptions settings = new CompilerOptions(props);
+        
+        CompileContext context = new CompileContext(units, env, errorHandler, classWriter);
+
+        if (log.isDebugEnabled()) {
+            log.debug(settings.toString());
+        }
+        
+        org.eclipse.jdt.internal.compiler.Compiler compiler =
+                new org.eclipse.jdt.internal.compiler.Compiler(
+                        context,
+                        policy,
+                        settings,
+                        context,
+                        PROBLEM_FACTORY,
+                        logWriter);
+
+        compiler.compile(context.sourceUnits());
+
+        context.cleanup();
+        
+        return !context.hadErrors;
+    }
+
+    //--------------------------------------------------------< inner classes >
+
+    private class CompileContext implements ICompilerRequestor, INameEnvironment {
+
+        boolean hadErrors;
+        HashMap<String,ICompilationUnit> compUnits;
+
+        ErrorHandler errorHandler;
+        ClassWriter classWriter;
+
+        CompilerEnvironment compEnv;
+
+        CompileContext(CompileUnit[] units,
+        		CompilerEnvironment compEnv,
+        		ErrorHandler errorHandler, 
+        		ClassWriter classWriter) {
+            
+        	compUnits = new HashMap<String,ICompilationUnit>(units.length);
+            for (int i = 0; i < units.length; i++) {
+                CompilationUnitAdapter cua = new CompilationUnitAdapter(units[i]);
+                char[][] compoundName = CharOperation.arrayConcat(cua.getPackageName(), cua.getMainTypeName());
+                compUnits.put(CharOperation.toString(compoundName), new CompilationUnitAdapter(units[i]));
+            }
+        	
+        	this.compEnv = compEnv;
+        	this.errorHandler = errorHandler;
+            this.classWriter = classWriter;
+            hadErrors = false;
+        }
+
+        ICompilationUnit[] sourceUnits() {
+        	return (ICompilationUnit[]) compUnits.values().toArray(
+        			new ICompilationUnit[compUnits.size()]);
+        }
+        
+        //---------------------------------------------------< ICompilerRequestor >
+        /**
+         * {@inheritDoc}
+         */
+        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++) {
+                    CategorizedProblem problem = problems[i];
+                    String msg = problem.getMessage();
+                    String fileName = CharOperation.charToString(problem.getOriginatingFileName());
+                    int line = problem.getSourceLineNumber();
+                    int pos = problem.getSourceStart();
+
+                    if (problem.isError()) {
+                        errorHandler.onError(msg, fileName, line, pos);
+                    } else if (problem.isWarning()) {
+                        errorHandler.onWarning(msg, fileName, line, pos);
+                    } else {
+                        log.debug("unknown problem category: " + problem.toString());
+                    }
+                }
+            }
+            ClassFile[] classFiles = result.getClassFiles();
+            for (int i = 0; i < classFiles.length; i++) {
+                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);
+                }
+            }
+        }
+
+        //-------------------------------------------------< INameEnvironment >
+        /**
+         * {@inheritDoc}
+         */
+        public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
+            // check 1st if type corresponds with any of current compilation units
+            String fqn = CharOperation.toString(compoundTypeName);
+            ICompilationUnit cu = (ICompilationUnit) compUnits.get(fqn);
+            if (cu != null) {
+                return new NameEnvironmentAnswer(cu, null);
+            }
+
+            // locate the class through the class loader
+            try {
+                byte[] bytes = compEnv.findClass(CharOperation.toString(compoundTypeName));
+                if (bytes == null) {
+                    return null;
+                }
+                ClassFileReader classFileReader =
+                        new ClassFileReader(bytes, fqn.toCharArray(), true);
+                return new NameEnvironmentAnswer(classFileReader, null);
+            } catch (Exception e) {
+                return null;
+            }
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
+            return findType(CharOperation.arrayConcat(packageName, typeName));
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        public boolean isPackage(char[][] parentPackageName, char[] packageName) {
+            String fqn = CharOperation.toString(
+                    CharOperation.arrayConcat(parentPackageName, packageName));
+            return compUnits.get(fqn) == null && compEnv.isPackage(fqn);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        public void cleanup() {
+            compEnv.cleanup();
+        }
+    }
+    
+    private class CompilationUnitAdapter implements ICompilationUnit {
+
+        CompileUnit compUnit;
+        char[][] packageName;
+
+        CompilationUnitAdapter(CompileUnit compUnit) {
+            this.compUnit = compUnit;
+        }
+
+        String extractPackageName(char[] contents) {
+            BufferedReader reader = new BufferedReader(new CharArrayReader(contents));
+            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();
+                    }
+                }
+            } catch (IOException e) {
+                // should never get here...
+            }
+
+            // no package declaration found
+            return "";
+        }
+
+        //-------------------------------------------------< ICompilationUnit >
+
+        public char[] getContents() {
+            return compUnit.getSourceFileContents();
+        }
+
+        public char[] getMainTypeName() {
+            return compUnit.getMainTypeName().toCharArray();
+        }
+
+        public char[][] getPackageName() {
+            if (packageName == null) {
+                String s = extractPackageName(compUnit.getSourceFileContents());
+                packageName = CharOperation.splitOn('.', s.toCharArray());
+            }
+            return packageName;
+        }
+
+        public char[] getFileName() {
+            return compUnit.getSourceFileName().toCharArray();
+        }
+    }
+}
diff --git a/src/main/resources/META-INF/DISCLAIMER b/src/main/resources/META-INF/DISCLAIMER
new file mode 100644
index 0000000..90850c2
--- /dev/null
+++ b/src/main/resources/META-INF/DISCLAIMER
@@ -0,0 +1,7 @@
+Apache Sling is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Jackrabbit PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other
+successful ASF projects. While incubation status is not necessarily a reflection of
+the completeness or stability of the code, it does indicate that the project has yet
+to be fully endorsed by the ASF.
\ No newline at end of file
diff --git a/src/main/resources/META-INF/LICENSE b/src/main/resources/META-INF/LICENSE
new file mode 100644
index 0000000..1b63f8d
--- /dev/null
+++ b/src/main/resources/META-INF/LICENSE
@@ -0,0 +1,233 @@
+
+                                 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
new file mode 100644
index 0000000..d7953a3
--- /dev/null
+++ b/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,8 @@
+Apache Sling Java Compiler
+Copyright 2008-2009 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/test/java/org/apache/sling/commons/compiler/impl/CompilerJava5Test.java b/src/test/java/org/apache/sling/commons/compiler/impl/CompilerJava5Test.java
new file mode 100644
index 0000000..3af2998
--- /dev/null
+++ b/src/test/java/org/apache/sling/commons/compiler/impl/CompilerJava5Test.java
@@ -0,0 +1,159 @@
+/*
+ * 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.io.ByteArrayOutputStream;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+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.compiler.ErrorHandler;
+import org.apache.sling.commons.compiler.Options;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case for java 5 support
+ */
+public class CompilerJava5Test extends TestCase
+        implements CompilerEnvironment, ErrorHandler, ClassWriter {
+
+    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));
+    }
+
+    //---------------------------------------------------------< 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);
+    }
+
+    //--------------------------------------------------< CompilerEnvironment >
+
+    public byte[] findClass(String className) throws Exception {
+        System.out.println("findClass('" + className + "')");
+        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();
+        }
+
+        return out.toByteArray();
+    }
+
+    public char[] findSource(String className) throws Exception {
+        System.out.println("findSource('" + className + "')");
+        return new char[0];
+    }
+
+    public boolean isPackage(String packageName) {
+        System.out.println("isPackage('" + packageName + "')");
+
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        InputStream in = cl.getResourceAsStream(packageName.replace('.', '/') + ".class");
+        if (in != null) {
+            try {
+                in.close();
+            } catch (IOException ignore) {
+            }
+            return false;
+        }
+        return true;
+    }
+
+    public void cleanup() {
+    }
+
+    //----------------------------------------------------------< ClassWriter >
+
+    public void write(String className, byte[] data) throws Exception {
+        System.out.println("compiled class " + className + ", " + data.length + " bytes");
+    }
+
+    //--------------------------------------------------------< misc. helpers >
+
+    private CompileUnit createCompileUnit(final String sourceFile) throws Exception {
+        final char[] chars = readTextResource(sourceFile);
+
+        return new CompileUnit() {
+
+            public String getSourceFileName() {
+                return sourceFile;
+            }
+
+            public char[] getSourceFileContents() {
+                return chars;
+            }
+
+            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);
+            }
+        };
+    }
+
+    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();
+        }
+    }
+}
diff --git a/src/test/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompilerTest.java b/src/test/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompilerTest.java
new file mode 100644
index 0000000..f27b4c5
--- /dev/null
+++ b/src/test/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompilerTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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 org.apache.sling.commons.compiler.JavaCompiler;
+
+import junit.framework.TestCase;
+
+public class EclipseJavaCompilerTest extends TestCase {
+
+    private JavaCompiler compiler;
+    
+    @Override
+    protected void setUp() throws Exception {
+        compiler = new EclipseJavaCompiler();
+        
+        super.setUp();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        compiler = null;
+        
+        super.tearDown();
+    }
+    
+    public void testCompileJava5() throws Exception {
+        
+    }
+
+}
diff --git a/src/test/resources/Java5Test b/src/test/resources/Java5Test
new file mode 100644
index 0000000..83bf4ac
--- /dev/null
+++ b/src/test/resources/Java5Test
@@ -0,0 +1,31 @@
+/*
+ * 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.test ;
+
+import java.util.List;
+
+/**
+ * Class to test to compile Java 5 specific code
+ */
+public class Java5Test {
+    public int sum(List<Integer> intList) {
+	int result = 0;
+	for(int i=0;i<intList.size();i++)
+	    result += intList.get(i).intValue();
+	return result;
+    }
+}

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

Mime
View raw message