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:21:16 UTC
[sling-org-apache-sling-commons-compiler] 05/08: SLING-1732 -
adding ability to explicitly define the source file name
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.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git
commit dade7453e45b9cd71f47f26af3bddb764078ae9c
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Tue Oct 23 09:57:07 2012 +0000
SLING-1732 - adding ability to explicitly define the source file name
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/compiler@1401229 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
.../compiler/CompilationUnitWithSource.java | 27 ++++++++++++++++++++++
.../commons/compiler/impl/EclipseJavaCompiler.java | 7 +++++-
3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index edc953c..35fe2c1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -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
diff --git a/src/main/java/org/apache/sling/commons/compiler/CompilationUnitWithSource.java b/src/main/java/org/apache/sling/commons/compiler/CompilationUnitWithSource.java
new file mode 100644
index 0000000..9a4921b
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/compiler/CompilationUnitWithSource.java
@@ -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();
+}
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 0f4e49f..76dda71 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
@@ -33,6 +33,7 @@ import org.apache.felix.scr.annotations.Service;
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 implements JavaCompiler {
* @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();
+ }
}
}
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.