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


The following commit(s) were added to refs/heads/master by this push:
     new 203e515  SLING-9394 - html scripts should be used to generate the 
resource type
203e515 is described below

commit 203e515382d48b063a3cc7b4e7fea1d901996823
Author: Radu Cotescu <[email protected]>
AuthorDate: Thu Apr 23 19:02:27 2020 +0200

    SLING-9394 - html scripts should be used to generate the resource type
---
 .../sling/scriptingbundle/maven/plugin/Script.java     | 11 ++++++++---
 .../scriptingbundle/maven/plugin/MetadataMojoTest.java |  3 ++-
 .../sling/scriptingbundle/maven/plugin/ScriptTest.java |  3 ++-
 .../src/main/scripts/libs/sling/test2/html.jsp         | 18 ++++++++++++++++++
 4 files changed, 30 insertions(+), 5 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/scriptingbundle/maven/plugin/Script.java 
b/src/main/java/org/apache/sling/scriptingbundle/maven/plugin/Script.java
index 071a822..e412483 100644
--- a/src/main/java/org/apache/sling/scriptingbundle/maven/plugin/Script.java
+++ b/src/main/java/org/apache/sling/scriptingbundle/maven/plugin/Script.java
@@ -66,9 +66,14 @@ class Script {
         String scriptExtension = parts[parts.length - 1];
         String requestExtension = null;
         String requestMethod = null;
-        if (parts.length == 2 && MetadataMojo.METHODS.contains(name)) {
-            requestMethod = name;
-            name = null;
+        if (parts.length == 2) {
+            if (MetadataMojo.METHODS.contains(name)) {
+                requestMethod = name;
+                name = null;
+            } else if (name.equalsIgnoreCase("html")) {
+                requestExtension = name;
+                name = null;
+            }
         }
         if (parts.length == 3) {
             String middle = parts[1];
diff --git 
a/src/test/java/org/apache/sling/scriptingbundle/maven/plugin/MetadataMojoTest.java
 
b/src/test/java/org/apache/sling/scriptingbundle/maven/plugin/MetadataMojoTest.java
index e8d4c02..8555dfc 100644
--- 
a/src/test/java/org/apache/sling/scriptingbundle/maven/plugin/MetadataMojoTest.java
+++ 
b/src/test/java/org/apache/sling/scriptingbundle/maven/plugin/MetadataMojoTest.java
@@ -131,7 +131,8 @@ public class MetadataMojoTest {
         Map<String, String> scriptEngineMappings =  
mojoProject.mojo.getScriptEngineMappings();
         Set<ProvidedResourceTypeCapability> pExpected = new 
HashSet<>(Arrays.asList(
                 
ProvidedResourceTypeCapability.builder().withResourceType("libs/sling/test").withScriptEngine("thymeleaf").withScriptExtension("html").build(),
-                
ProvidedResourceTypeCapability.builder().withResourceType("libs/sling/test").withScriptEngine("rhino").withScriptExtension("js").withSelectors(new
 HashSet<>(Arrays.asList("merged"))).build()
+                
ProvidedResourceTypeCapability.builder().withResourceType("libs/sling/test").withScriptEngine("rhino").withScriptExtension("js").withSelectors(new
 HashSet<>(Arrays.asList("merged"))).build(),
+                
ProvidedResourceTypeCapability.builder().withResourceType("libs/sling/test2").withScriptEngine("jsp").withScriptExtension("jsp").withRequestExtension("html").build()
         ));
         Set<ProvidedScriptCapability> expectedScriptCapabilities = new 
HashSet<>(Arrays.asList(
                 
ProvidedScriptCapability.builder(scriptEngineMappings).withPath("/libs/sling/commons/template.html").build(),
diff --git 
a/src/test/java/org/apache/sling/scriptingbundle/maven/plugin/ScriptTest.java 
b/src/test/java/org/apache/sling/scriptingbundle/maven/plugin/ScriptTest.java
index b168c82..22bce8b 100644
--- 
a/src/test/java/org/apache/sling/scriptingbundle/maven/plugin/ScriptTest.java
+++ 
b/src/test/java/org/apache/sling/scriptingbundle/maven/plugin/ScriptTest.java
@@ -50,7 +50,8 @@ public class ScriptTest {
     public void parseTwoPartScriptRequestExtension() {
         Script script = Script.parseScript("html.html");
         assertNotNull(script);
-        assertEquals("html", script.getName());
+        assertNull("html", script.getName());
+        assertEquals("html", script.getRequestExtension());
         assertNull(script.getRequestMethod());
         assertEquals("html", script.getScriptExtension());
     }
diff --git 
a/src/test/resources/project-2/src/main/scripts/libs/sling/test2/html.jsp 
b/src/test/resources/project-2/src/main/scripts/libs/sling/test2/html.jsp
new file mode 100644
index 0000000..40d389e
--- /dev/null
+++ b/src/test/resources/project-2/src/main/scripts/libs/sling/test2/html.jsp
@@ -0,0 +1,18 @@
+<%--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ 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.
+  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--%>

Reply via email to