SLING-9320 - Allow precompiled units to access objects from the same bundle through the Use API
* extended the JsUseProvider to allow finding dependencies belonging to the same
resource type even if the dependencies are served by different providers
diff --git a/examples/org-apache-sling-scripting-examplebundle-extend2/pom.xml b/examples/org-apache-sling-scripting-examplebundle-extend2/pom.xml
index 9338145..4f0c2e5 100644
--- a/examples/org-apache-sling-scripting-examplebundle-extend2/pom.xml
+++ b/examples/org-apache-sling-scripting-examplebundle-extend2/pom.xml
@@ -67,7 +67,8 @@
${org.apache.sling.scriptingbundle.maven.plugin.Require-Capability}
</Require-Capability>
<Sling-Initial-Content>
- SLING-INF/content;overwrite:=true;path:=/content/bundled-scripts/examplebundle-extend2
+ SLING-INF/content;overwrite:=true;path:=/content/bundled-scripts/examplebundle-extend2,
+ SLING-INF/apps/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0;overwrite:=true;path:=/apps/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0
</Sling-Initial-Content>
</instructions>
</configuration>
diff --git a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/SLING-INF/apps/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/use-script-repo.js b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/SLING-INF/apps/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/use-script-repo.js
new file mode 100644
index 0000000..b0252f7
--- /dev/null
+++ b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/SLING-INF/apps/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/use-script-repo.js
@@ -0,0 +1,23 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/*global use*/
+use(function() {
+ 'use strict';
+ return 'use-script-repo.js says hello';
+});
diff --git a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html
index ad48b9c..63d3480 100644
--- a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html
+++ b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html
@@ -28,3 +28,4 @@
data-sly-use.absolutePathTemplates2="/apps/sling/scripting/examplebundle/hello/templates.html"
data-sly-call="${absolutePathTemplates2.exampledBundleAppsHello @ name = 'Jack Schitt'}"></div>
<div class="js-use" data-sly-use.js="use-script.js">${js}</div>
+<div class="js-use-resource-type-repository" data-sly-use.jsrepo="use-script-repo.js">${jsrepo}</div>
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2IT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2IT.java
index 51e3f8c..b808c70 100644
--- a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2IT.java
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2IT.java
@@ -114,6 +114,9 @@
Elements jsUse = document.select("div.js-use");
assertEquals("Expected a js-use script to have rendered content", "Hello, Jack Black!", jsUse.html());
+
+ Elements jsUseRepo = document.select("div.js-use-resource-type-repository");
+ assertEquals("Expected a js-use script to have rendered content", "use-script-repo.js says hello", jsUseRepo.html());
}
@Test
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2TeleportedIT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2TeleportedIT.java
index f475038..90a0c65 100644
--- a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2TeleportedIT.java
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2TeleportedIT.java
@@ -68,7 +68,7 @@
assertNotNull(main);
assertEquals("org.apache.sling.scripting.examplebundle.extend2.one/1.0.0", main.getResourceSuperType());
Map<String, Resource> children = collectResourceChildren(main);
- assertEquals(5, children.size());
+ assertEquals(6, children.size());
Set<String> expectedChildren = getChildrenForServletResource(
"/apps/" + expectedRT,
@@ -76,7 +76,8 @@
"two.html",
"two.html.servlet",
"two-templates.html",
- "two-templates.html.servlet"
+ "two-templates.html.servlet",
+ "use-script-repo.js"
);
assertEquals(expectedChildren, children.keySet());