incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1401229 - in /sling/trunk/contrib: commons/compiler/ commons/compiler/src/main/java/org/apache/sling/commons/compiler/ commons/compiler/src/main/java/org/apache/sling/commons/compiler/impl/ scripting/java/ scripting/java/src/main/java/org/...
Date Tue, 23 Oct 2012 09:57:07 GMT
Author: justin
Date: Tue Oct 23 09:57:07 2012
New Revision: 1401229

URL: http://svn.apache.org/viewvc?rev=1401229&view=rev
Log:
SLING-1732 - adding ability to explicitly define the source file name

Added:
    sling/trunk/contrib/commons/compiler/src/main/java/org/apache/sling/commons/compiler/CompilationUnitWithSource.java
  (with props)
Modified:
    sling/trunk/contrib/commons/compiler/pom.xml
    sling/trunk/contrib/commons/compiler/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
    sling/trunk/contrib/scripting/java/pom.xml
    sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java

Modified: sling/trunk/contrib/commons/compiler/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/compiler/pom.xml?rev=1401229&r1=1401228&r2=1401229&view=diff
==============================================================================
--- sling/trunk/contrib/commons/compiler/pom.xml (original)
+++ sling/trunk/contrib/commons/compiler/pom.xml Tue Oct 23 09:57:07 2012
@@ -59,7 +59,7 @@
                             !org.eclipse.*,*
                         </Import-Package>
                         <Export-Package>
-                            org.apache.sling.commons.compiler;version=2.0.0
+                            org.apache.sling.commons.compiler;version=2.1.0
                         </Export-Package>
                         <Private-Package>
                             org.apache.sling.commons.compiler.impl

Added: sling/trunk/contrib/commons/compiler/src/main/java/org/apache/sling/commons/compiler/CompilationUnitWithSource.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/compiler/src/main/java/org/apache/sling/commons/compiler/CompilationUnitWithSource.java?rev=1401229&view=auto
==============================================================================
--- sling/trunk/contrib/commons/compiler/src/main/java/org/apache/sling/commons/compiler/CompilationUnitWithSource.java
(added)
+++ sling/trunk/contrib/commons/compiler/src/main/java/org/apache/sling/commons/compiler/CompilationUnitWithSource.java
Tue Oct 23 09:57:07 2012
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+/**
+ * Extension of the CompilationUnit interface which allows for the explicit
+ * declaration of the source file name.
+ * @since 2.1
+ */
+public interface CompilationUnitWithSource extends CompilationUnit {
+
+    String getFileName();
+}

Propchange: sling/trunk/contrib/commons/compiler/src/main/java/org/apache/sling/commons/compiler/CompilationUnitWithSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/contrib/commons/compiler/src/main/java/org/apache/sling/commons/compiler/CompilationUnitWithSource.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/trunk/contrib/commons/compiler/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/compiler/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java?rev=1401229&r1=1401228&r2=1401229&view=diff
==============================================================================
--- sling/trunk/contrib/commons/compiler/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
(original)
+++ sling/trunk/contrib/commons/compiler/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
Tue Oct 23 09:57:07 2012
@@ -33,6 +33,7 @@ import org.apache.felix.scr.annotations.
 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.CompilationUnitWithSource;
 import org.apache.sling.commons.compiler.JavaCompiler;
 import org.apache.sling.commons.compiler.Options;
 import org.eclipse.jdt.core.compiler.CategorizedProblem;
@@ -453,7 +454,11 @@ public class EclipseJavaCompiler impleme
          * @see org.eclipse.jdt.internal.compiler.env.IDependent#getFileName()
          */
         public char[] getFileName() {
-            return (this.packageName.replace('.', '/') + '/' + this.mainTypeName + ".java").toCharArray();
+            if (compUnit instanceof CompilationUnitWithSource) {
+                return ((CompilationUnitWithSource)compUnit).getFileName().toCharArray();
+            } else {
+                return (this.packageName.replace('.', '/') + '/' + this.mainTypeName + ".java").toCharArray();
+            }
         }
     }
 }

Modified: sling/trunk/contrib/scripting/java/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/java/pom.xml?rev=1401229&r1=1401228&r2=1401229&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/java/pom.xml (original)
+++ sling/trunk/contrib/scripting/java/pom.xml Tue Oct 23 09:57:07 2012
@@ -99,7 +99,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.compiler</artifactId>
-            <version>2.0.0</version>
+            <version>2.0.7-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
 

Modified: sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java?rev=1401229&r1=1401228&r2=1401229&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java
(original)
+++ sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java
Tue Oct 23 09:57:07 2012
@@ -23,7 +23,7 @@ import java.io.Reader;
 
 
 public class CompilationUnit
-    implements org.apache.sling.commons.compiler.CompilationUnit {
+    implements org.apache.sling.commons.compiler.CompilationUnitWithSource {
 
     private final SlingIOProvider ioProvider;
     private final String className;
@@ -66,4 +66,17 @@ public class CompilationUnit
     public long getLastModified() {
         return this.ioProvider.lastModified(this.sourceFile);
     }
+
+
+    /**
+     * @see org.apache.sling.commons.compiler.CompilationUnitWithSource#getLastModified()
+     */
+    public String getFileName() {
+        final int idx = this.sourceFile.lastIndexOf('/');
+        if (idx == -1) {
+            return this.sourceFile;
+        } else {
+            return this.sourceFile.substring(idx + 1);
+        }
+    }
 }



Mime
View raw message