You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2017/12/04 10:53:45 UTC
[sling-htl-maven-plugin] branch master updated: SLING-7287
htl-maven-plugin:validate fails with windows path names
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-htl-maven-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 8d8b140 SLING-7287 htl-maven-plugin:validate fails with windows path names
8d8b140 is described below
commit 8d8b140baaac52974733f9c552ee01669a6ae53c
Author: sseifert <ss...@pro-vision.de>
AuthorDate: Mon Dec 4 11:53:35 2017 +0100
SLING-7287 htl-maven-plugin:validate fails with windows path names
---
src/main/java/org/apache/sling/maven/htl/ValidateMojo.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/sling/maven/htl/ValidateMojo.java b/src/main/java/org/apache/sling/maven/htl/ValidateMojo.java
index e4d1973..a1e6ebb 100644
--- a/src/main/java/org/apache/sling/maven/htl/ValidateMojo.java
+++ b/src/main/java/org/apache/sling/maven/htl/ValidateMojo.java
@@ -27,7 +27,9 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.regex.Matcher;
+import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -249,10 +251,16 @@ public class ValidateMojo extends AbstractMojo {
JavaClassBackendCompiler backendCompiler = new JavaClassBackendCompiler(javaImportsAnalyzer);
ScriptCompilationUnit compilationUnit = new ScriptCompilationUnit(sourceDirectory, script);
compilationResult.put(script, compiler.compile(compilationUnit, backendCompiler));
- ClassInfo classInfo = new HTLClassInfo(script.getPath().replaceFirst(sourceDirectory.getAbsolutePath(), ""));
+
+ // strip off source directory path from script path for class info
+ File scriptFile = new File(script.getPath());
+ File sourceDirectoryDir = new File(sourceDirectory.getAbsolutePath());
+ String shortenedScriptPath = StringUtils.substringAfter(scriptFile.getCanonicalPath(), sourceDirectoryDir.getCanonicalPath());
+
+ ClassInfo classInfo = new HTLClassInfo(shortenedScriptPath);
String javaSourceCode = backendCompiler.build(classInfo);
File generatedClassFile = new File(generatedJavaClassesDirectory, classInfo.getFullyQualifiedClassName()
- .replaceAll("\\.", File.separator) + ".java");
+ .replaceAll("\\.", Matcher.quoteReplacement(File.separator)) + ".java");
generatedClassFile.getParentFile().mkdirs();
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(generatedClassFile), _16K));
out.write(javaSourceCode);
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].