sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [sling-scriptingbundle-maven-plugin] 12/17: make the scripts directory configurable
Date Mon, 10 Dec 2018 12:01:17 GMT
This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-scriptingbundle-maven-plugin.git

commit 11500edcea5baafcb2b6624074d7c868acf6836d
Author: Radu Cotescu <radu@apache.org>
AuthorDate: Tue Aug 14 11:39:54 2018 +0200

    make the scripts directory configurable
---
 .../scripting/maven/plugin/ScriptingMavenPlugin.java      | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPlugin.java
b/src/main/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPlugin.java
index 6f95a42..422fa36 100644
--- a/src/main/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPlugin.java
+++ b/src/main/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPlugin.java
@@ -51,20 +51,23 @@ public class ScriptingMavenPlugin extends AbstractMojo
     @Parameter(defaultValue = "${session}", readonly = true)
     private MavenSession session;
 
+    @Parameter(defaultValue = "${project.basedir}/src/main/resources/javax.script")
+    private String scriptsDirectory;
+
     private static final Set<String> METHODS = new HashSet<>(Arrays.asList(new
String[]{"TRACE", "OPTIONS", "GET", "HEAD", "POST", "PUT",
             "DELETE", "PATCH"}));
 
     public void execute() throws MojoExecutionException
     {
         DirectoryScanner scanner = new DirectoryScanner();
-        scanner.setBasedir(project.getBuild().getOutputDirectory());
-        scanner.setIncludes("javax.script/**");
+        scanner.setBasedir(scriptsDirectory);
+        scanner.setIncludes("**");
         scanner.setExcludes("**/*.class");
         scanner.addDefaultExcludes();
         scanner.scan();
 
-        List<String> scriptPaths = Stream.of(scanner.getIncludedFiles()).map(path ->
new File(project.getBuild().getOutputDirectory(), path))
-            .map(file -> file.getPath().substring((new File(project.getBuild().getOutputDirectory(),
"javax.script").getPath() + File.pathSeparatorChar).length()))
+        List<String> scriptPaths = Stream.of(scanner.getIncludedFiles()).map(path ->
new File(scriptsDirectory, path))
+            .map(file -> file.getPath().substring((scriptsDirectory + File.pathSeparatorChar).length()))
             .collect(Collectors.toList());
 
 
@@ -87,7 +90,7 @@ public class ScriptingMavenPlugin extends AbstractMojo
                     }
                     else
                     {
-                        try (BufferedReader input = new BufferedReader(new FileReader(new
File(new File(project.getBuild().getOutputDirectory(), "javax.script"), scriptPath))))
+                        try (BufferedReader input = new BufferedReader(new FileReader(new
File(new File(scriptsDirectory), scriptPath))))
                         {
                             String extend = input.readLine();
 
@@ -102,7 +105,7 @@ public class ScriptingMavenPlugin extends AbstractMojo
                 }
                 else
                 {
-                    try (BufferedReader input = new BufferedReader(new FileReader(new File(new
File(project.getBuild().getOutputDirectory(), "javax.script"), scriptPath))))
+                    try (BufferedReader input = new BufferedReader(new FileReader(new File(new
File(scriptsDirectory), scriptPath))))
                     {
                         for (String line = input.readLine(); line != null; line = input.readLine())
                         {


Mime
View raw message