You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2018/12/10 12:01:05 UTC

[sling-scriptingbundle-maven-plugin] branch master created (now aa48030)

This is an automated email from the ASF dual-hosted git repository.

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


      at aa48030  refactored the code in order to move it to its own repository

This branch includes the following new commits:

     new 0dc9172  Add a maven plugin for generating caps/reqs
     new b9b0ace  Refactor a bit and add some tests.
     new 3123bcb  Register services using extended bundles bundlecontext and only register for required methods.
     new 03bf39a  Make the extends requirement filter out selectors.
     new 45736dc  reorganised project
     new 02072a5  corrected link
     new 395b999  corrected more relative links
     new 0463cea  corrected more relative links
     new 15948fb  corrected more relative links
     new 876e3d1  corrected more relative links
     new 6e681b0  Improvements
     new 11500ed  make the scripts directory configurable
     new be9341c  corrected scripts folder handling
     new bb072ae  made script file handling OS-independent
     new ef02e8d  made script file handling OS-independent - attempt 2
     new 2a5dc67  made script file handling OS-independent - attempt 3
     new aa48030  refactored the code in order to move it to its own repository

The 17 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[sling-scriptingbundle-maven-plugin] 17/17: refactored the code in order to move it to its own repository

Posted by ra...@apache.org.
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 aa48030170f7a565bbf51b4f2ad0096a6ed308ae
Author: Radu Cotescu <co...@adobe.com>
AuthorDate: Mon Dec 10 12:58:06 2018 +0100

    refactored the code in order to move it to its own repository
---
 .gitignore                                         |   9 +
 CODE_OF_CONDUCT.md                                 |  22 +++
 CONTRIBUTING.md                                    |  24 +++
 LICENSE                                            | 202 +++++++++++++++++++++
 README.md                                          |  18 +-
 pom.xml                                            |  75 ++++----
 .../maven/plugin/ScriptingMavenPlugin.java         |   2 +-
 .../maven/plugin/ScriptingMavenPluginTest.java     |   2 +-
 8 files changed, 309 insertions(+), 45 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f7422e7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+.project
+.classpath
+.settings
+target
+bin
+*.iml
+.idea
+.DS_Store
+dependency-reduced-pom.xml
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..0fa18e5
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,22 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ 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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+Apache Software Foundation Code of Conduct
+====
+
+Being an Apache project, Apache Sling adheres to the Apache Software Foundation's [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..ac82a1a
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,24 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ 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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+Contributing
+====
+
+Thanks for choosing to contribute!
+
+You will find all the necessary details about how you can do this at https://sling.apache.org/contributing.html.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
diff --git a/README.md b/README.md
index d35bf64..5fa87ea 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Apache Sling Scripting Maven Plugin (WIP, name not final)
 ## What
 This plugin provides support for deriving `sling.resourceType` `Requirements` and `Capabilities` from
 the file-system layout of scripts. Bundles that get extended by the
-[`org.apache.sling.scripting.resolver`](../org-apache-sling-scripting-resolver) with these `Requirements` and
+[`org.apache.sling.scripting.bundle.tracker`](https://github.com/apache/sling-org-apache-sling-scripting-bundle-tracker) with these `Requirements` and
 `Capabilities` will have their scripts made available automatically with added versioning and dependency
 support.
 
@@ -52,8 +52,8 @@ sling.resourceType;
 
 For a bigger example providing several versions and using an `extends` file consider the following two projects: 
 
-  * [example](../examples/org-apache-sling-scripting-examplebundle);
-  * [example.hi](../examples/org-apache-sling-scripting-examplebundle.hi).
+  * [example](https://github.com/apache/sling-org-apache-sling-scripting-bundle-tracker-it/tree/master/examples/org-apache-sling-scripting-examplebundle);
+  * [example.hi](https://github.com/apache/sling-org-apache-sling-scripting-bundle-tracker-it/tree/master/examples/org-apache-sling-scripting-examplebundle.hi).
 
 ## So how do I use the plugin?
 
@@ -61,8 +61,8 @@ The plugin doesn't currently integrate with the `maven-bundle-plugin`. The gener
 `Provide-Capability` headers values are simply made available via properties:
 
 ```
-${org.apache.sling.scripting.maven.plugin.Provide-Capability}
-${org.apache.sling.scripting.maven.plugin.Require-Capability}
+${org.apache.sling.scriptingbundle.maven.plugin.Provide-Capability}
+${org.apache.sling.scriptingbundle.maven.plugin.Require-Capability}
 ```
 
 However, that makes it reasonable straightforward to use the plugin by just adding it into your build in the 
@@ -72,7 +72,7 @@ the `maven-bundle-plugin`:
 ```
     <plugin>
     <groupId>org.apache.sling</groupId>
-        <artifactId>org.apache.sling.scripting.maven.plugin</artifactId>
+        <artifactId>scriptingbundle-maven-plugin</artifactId>
         <version>0.0.1-SNAPSHOT</version>
         <executions>
             <execution>
@@ -90,15 +90,15 @@ the `maven-bundle-plugin`:
         <configuration>
             <instructions>
                 <Provide-Capability>
-                    ${org.apache.sling.scripting.maven.plugin.Provide-Capability}
+                    ${org.apache.sling.scriptingbundle.maven.plugin.Provide-Capability}
                 </Provide-Capability>
                 <Require-Capability>
                     osgi.extender;filter:="(&amp;(osgi.extender=sling.scripting)(version>=1.0.0)(!(version>=2.0.0)))",
-                    ${org.apache.sling.scripting.maven.plugin.Require-Capability}
+                    ${org.apache.sling.scriptingbundle.maven.plugin.Require-Capability}
                 </Require-Capability>
             </instructions>
         </configuration>
     </plugin>
 ```
 
-You can find an example in [here](../examples/org-apache-sling-scripting-examplebundle/pom.xml).
+You can find an example in [here](https://github.com/apache/sling-org-apache-sling-scripting-bundle-tracker-it/tree/master/examples/org-apache-sling-scripting-examplebundle/pom.xml).
diff --git a/pom.xml b/pom.xml
index 1d8872e..d1e24a0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,49 +23,56 @@
 
     <parent>
         <groupId>org.apache.sling</groupId>
-        <artifactId>org.apache.sling.scripting.resolver.reactor</artifactId>
-        <version>0.0.1-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
+        <artifactId>sling</artifactId>
+        <version>34</version>
+        <relativePath/>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>org.apache.sling.scripting.maven.plugin</artifactId>
+    <artifactId>scriptingbundle-maven-plugin</artifactId>
     <version>0.0.1-SNAPSHOT</version>
     <packaging>maven-plugin</packaging>
 
+        <scm>
+            <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scriptingbundle-maven-plugin.git</connection>
+            <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scriptingbundle-maven-plugin.git</developerConnection>
+            <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-scriptingbundle-maven-plugin.git</url>
+            <tag>HEAD</tag>
+        </scm>
+
     <properties>
         <sling.java.version>8</sling.java.version>
     </properties>
 
 
-<dependencies>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-plugin-api</artifactId>
-      <version>3.0</version>
-    </dependency>
- 
-    <!-- dependencies to annotations -->
-    <dependency>
-      <groupId>org.apache.maven.plugin-tools</groupId>
-      <artifactId>maven-plugin-annotations</artifactId>
-      <version>3.4</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-        <groupId>org.apache.maven</groupId>
-        <artifactId>maven-project</artifactId>
-        <version>2.2.1</version>
-    </dependency>
-    <dependency>
-        <groupId>org.apache.maven</groupId>
-        <artifactId>maven-core</artifactId>
-        <version>3.5.0</version>
-    </dependency>
-    <dependency>
-        <groupId>org.osgi</groupId>
-        <artifactId>osgi.core</artifactId>
-        <scope>compile</scope>
-    </dependency>
-</dependencies>
+    <dependencies>
+        <dependency>
+          <groupId>org.apache.maven</groupId>
+          <artifactId>maven-plugin-api</artifactId>
+          <version>3.0</version>
+        </dependency>
+
+        <!-- dependencies to annotations -->
+        <dependency>
+          <groupId>org.apache.maven.plugin-tools</groupId>
+          <artifactId>maven-plugin-annotations</artifactId>
+          <version>3.4</version>
+          <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-project</artifactId>
+            <version>2.2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-core</artifactId>
+            <version>3.5.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.core</artifactId>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
 </project>
diff --git a/src/main/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPlugin.java b/src/main/java/org/apache/sling/scriptingbundle/maven/plugin/ScriptingMavenPlugin.java
similarity index 99%
rename from src/main/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPlugin.java
rename to src/main/java/org/apache/sling/scriptingbundle/maven/plugin/ScriptingMavenPlugin.java
index 25842ab..33881f0 100644
--- a/src/main/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPlugin.java
+++ b/src/main/java/org/apache/sling/scriptingbundle/maven/plugin/ScriptingMavenPlugin.java
@@ -16,7 +16,7 @@
  ~ specific language governing permissions and limitations
  ~ under the License.
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-package org.apache.sling.scripting.maven.plugin;
+package org.apache.sling.scriptingbundle.maven.plugin;
 
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
diff --git a/src/test/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPluginTest.java b/src/test/java/org/apache/sling/scriptingbundle/maven/plugin/ScriptingMavenPluginTest.java
similarity index 98%
rename from src/test/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPluginTest.java
rename to src/test/java/org/apache/sling/scriptingbundle/maven/plugin/ScriptingMavenPluginTest.java
index b6ec709..2dd2a95 100644
--- a/src/test/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPluginTest.java
+++ b/src/test/java/org/apache/sling/scriptingbundle/maven/plugin/ScriptingMavenPluginTest.java
@@ -16,7 +16,7 @@
  ~ specific language governing permissions and limitations
  ~ under the License.
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-package org.apache.sling.scripting.maven.plugin;
+package org.apache.sling.scriptingbundle.maven.plugin;
 
 import org.junit.Assert;
 import org.junit.Test;


[sling-scriptingbundle-maven-plugin] 13/17: corrected scripts folder handling

Posted by ra...@apache.org.
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 be9341c665134ce797a1ae153f7ac129c60debd0
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Tue Aug 14 14:06:54 2018 +0200

    corrected scripts folder handling
---
 .../scripting/maven/plugin/ScriptingMavenPlugin.java | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 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 422fa36..875133c 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
@@ -38,6 +38,7 @@ import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -59,15 +60,24 @@ public class ScriptingMavenPlugin extends AbstractMojo
 
     public void execute() throws MojoExecutionException
     {
+        File sdFile = new File(scriptsDirectory);
+        if (!sdFile.exists()) {
+            sdFile = new File(project.getBasedir(), scriptsDirectory);
+            if (!sdFile.exists()) {
+                throw new MojoExecutionException("Cannot find file " + scriptsDirectory + ".");
+            }
+        }
+        final AtomicReference<File> scriptsDirectoryReference = new AtomicReference<>();
+        scriptsDirectoryReference.set(sdFile);;
         DirectoryScanner scanner = new DirectoryScanner();
-        scanner.setBasedir(scriptsDirectory);
+        scanner.setBasedir(sdFile);
         scanner.setIncludes("**");
         scanner.setExcludes("**/*.class");
         scanner.addDefaultExcludes();
         scanner.scan();
 
-        List<String> scriptPaths = Stream.of(scanner.getIncludedFiles()).map(path -> new File(scriptsDirectory, path))
-            .map(file -> file.getPath().substring((scriptsDirectory + File.pathSeparatorChar).length()))
+        List<String> scriptPaths = Stream.of(scanner.getIncludedFiles()).map(path -> new File(scriptsDirectoryReference.get(), path))
+            .map(file -> file.getPath().substring((scriptsDirectoryReference.get().getPath() + File.pathSeparatorChar).length()))
             .collect(Collectors.toList());
 
 
@@ -90,7 +100,7 @@ public class ScriptingMavenPlugin extends AbstractMojo
                     }
                     else
                     {
-                        try (BufferedReader input = new BufferedReader(new FileReader(new File(new File(scriptsDirectory), scriptPath))))
+                        try (BufferedReader input = new BufferedReader(new FileReader(new File(scriptsDirectoryReference.get(), scriptPath))))
                         {
                             String extend = input.readLine();
 
@@ -105,7 +115,7 @@ public class ScriptingMavenPlugin extends AbstractMojo
                 }
                 else
                 {
-                    try (BufferedReader input = new BufferedReader(new FileReader(new File(new File(scriptsDirectory), scriptPath))))
+                    try (BufferedReader input = new BufferedReader(new FileReader(new File(scriptsDirectoryReference.get(), scriptPath))))
                     {
                         for (String line = input.readLine(); line != null; line = input.readLine())
                         {


[sling-scriptingbundle-maven-plugin] 03/17: Register services using extended bundles bundlecontext and only register for required methods.

Posted by ra...@apache.org.
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 3123bcb6f706ce22ccc6a86d5e174cc2b927724c
Author: Karl Pauls <pa...@apache.org>
AuthorDate: Mon Apr 16 15:45:20 2018 +0200

    Register services using extended bundles bundlecontext and only register for required methods.
---
 .../sling/scripting/maven/plugin/ScriptingMavenPlugin.java    | 11 +++++++----
 .../scripting/maven/plugin/ScriptingMavenPluginTest.java      |  6 +++---
 2 files changed, 10 insertions(+), 7 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 701cd70..1a49bcb 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
@@ -114,7 +114,10 @@ public class ScriptingMavenPlugin extends AbstractMojo
                     }
                 }
             }
-            capability += ";sling.resourceType.extensions:List<String>=\"" + script.extension.replace("\"", "\\\"") + "\"";
+            if (script.extension != null)
+            {
+                capability += ";sling.resourceType.extensions:List<String>=\"" + script.extension.replace("\"", "\\\"") + "\"";
+            }
 
             if (script.method != null)
             {
@@ -177,14 +180,14 @@ public class ScriptingMavenPlugin extends AbstractMojo
         {
             result.extension = result.name.substring(idx + 1);
             result.name = result.name.substring(0, idx);
-            if (result.extension.isEmpty())
+            if (result.extension.isEmpty() || result.extension.equalsIgnoreCase("html"))
             {
-                result.extension = "html";
+                result.extension = null;
             }
         }
         else
         {
-            result.extension = "html";
+            result.extension = null;
         }
 
         idx = result.name.indexOf('.');
diff --git a/src/test/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPluginTest.java b/src/test/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPluginTest.java
index e6a4262..b6ec709 100644
--- a/src/test/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPluginTest.java
+++ b/src/test/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPluginTest.java
@@ -49,7 +49,7 @@ public class ScriptingMavenPluginTest
         Assert.assertNull("1.0.0", script.version);
         Assert.assertEquals("foo", script.name);
         Assert.assertNull(script.method);
-        Assert.assertEquals("html", script.extension);
+        Assert.assertNull(script.extension);
         Assert.assertNull(script.scriptExtension);
     }
 
@@ -64,7 +64,7 @@ public class ScriptingMavenPluginTest
         Assert.assertEquals("1.2.0", script.version);
         Assert.assertEquals("", script.name);
         Assert.assertEquals("POST", script.method);
-        Assert.assertEquals("html", script.extension);
+        Assert.assertNull(script.extension);
         Assert.assertEquals("jsp", script.scriptExtension);
     }
 
@@ -79,7 +79,7 @@ public class ScriptingMavenPluginTest
         Assert.assertEquals("1.2.0", script.version);
         Assert.assertEquals("",script.name);
         Assert.assertEquals("POST", script.method);
-        Assert.assertEquals("html", script.extension);
+        Assert.assertNull(script.extension);
         Assert.assertNull(script.scriptExtension);
     }
 }


[sling-scriptingbundle-maven-plugin] 07/17: corrected more relative links

Posted by ra...@apache.org.
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 395b99974985e6e189b84feee83f741b88bda585
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Thu Apr 19 11:49:11 2018 +0200

    corrected more relative links
---
 README.md | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 2bd764d..b998cdd 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Apache Sling Scripting Maven Plugin (WIP, name not final)
 ## What
 This plugin provides support for deriving `sling.resourceType` `Requirements` and `Capabilities` from
 the file-system layout of scripts. Bundles that get extended by the
-[`org.apache.sling.scripting.resolver`](srr/tree/master/org-apache-sling-scripting-resolover/) with these `Requirements` and
+[`org.apache.sling.scripting.resolver`](../org-apache-sling-scripting-resolover/README.md) with these `Requirements` and
 `Capabilities` will have their scripts made available automatically with added versioning and dependency
 support.
 
@@ -20,8 +20,8 @@ expects the following layout:
 javax.script/<sling-resourceType>/<version>/[<METHOD>.]<name>[.<selector>][.<extension>].<script-extension>
 ```
 
-From that, it will create an appropriate `Provide-Capability` (see the ["How"](../org-apache-sling-scripting-resolover/#how) section of
-the scripting resolver) with the following extra assumptions:
+From that, it will create an appropriate `Provide-Capability` (see the ["How"](../org-apache-sling-scripting-resolover/README.md#how)
+section of the scripting resolver) with the following extra assumptions:
 
   * if the `name` part equals the `sling.resourceType` or the last part of it, it is assumed to be the name of the main script;
   otherwise, it is assumed to be a selector;
@@ -52,8 +52,8 @@ sling.resourceType;
 
 For a bigger example providing several versions and using an `extends` file consider the following two projects: 
 
-  * [example](../org-apache-sling-scripting-examplebundle);
-  * [example.hi](../org-apache-sling-scripting-examplebundle.hi).
+  * [example](../examples/org-apache-sling-scripting-examplebundle/README.md);
+  * [example.hi](../examples/org-apache-sling-scripting-examplebundle.hi/README.md).
 
 ## So how do I use the plugin?
 


[sling-scriptingbundle-maven-plugin] 08/17: corrected more relative links

Posted by ra...@apache.org.
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 0463cea8a3320803e6d20f23171de52a381d19f4
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Thu Apr 19 11:53:09 2018 +0200

    corrected more relative links
---
 README.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index b998cdd..275476e 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Apache Sling Scripting Maven Plugin (WIP, name not final)
 ## What
 This plugin provides support for deriving `sling.resourceType` `Requirements` and `Capabilities` from
 the file-system layout of scripts. Bundles that get extended by the
-[`org.apache.sling.scripting.resolver`](../org-apache-sling-scripting-resolover/README.md) with these `Requirements` and
+[`org.apache.sling.scripting.resolver`](../org-apache-sling-scripting-resolver) with these `Requirements` and
 `Capabilities` will have their scripts made available automatically with added versioning and dependency
 support.
 
@@ -52,8 +52,8 @@ sling.resourceType;
 
 For a bigger example providing several versions and using an `extends` file consider the following two projects: 
 
-  * [example](../examples/org-apache-sling-scripting-examplebundle/README.md);
-  * [example.hi](../examples/org-apache-sling-scripting-examplebundle.hi/README.md).
+  * [example](../examples/org-apache-sling-scripting-examplebundle);
+  * [example.hi](../examples/org-apache-sling-scripting-examplebundle.hi).
 
 ## So how do I use the plugin?
 


[sling-scriptingbundle-maven-plugin] 09/17: corrected more relative links

Posted by ra...@apache.org.
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 15948fb1c68342a8baae2738f39c9231b1fb472f
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Thu Apr 19 11:53:50 2018 +0200

    corrected more relative links
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 275476e..ab13d7a 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ expects the following layout:
 javax.script/<sling-resourceType>/<version>/[<METHOD>.]<name>[.<selector>][.<extension>].<script-extension>
 ```
 
-From that, it will create an appropriate `Provide-Capability` (see the ["How"](../org-apache-sling-scripting-resolover/README.md#how)
+From that, it will create an appropriate `Provide-Capability` (see the ["How"](../org-apache-sling-scripting-resolver/README.md#how)
 section of the scripting resolver) with the following extra assumptions:
 
   * if the `name` part equals the `sling.resourceType` or the last part of it, it is assumed to be the name of the main script;


[sling-scriptingbundle-maven-plugin] 06/17: corrected link

Posted by ra...@apache.org.
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 02072a5fc5722af2da75bf63543be21090532984
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Thu Apr 19 11:45:17 2018 +0200

    corrected link
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index b2f280f..2bd764d 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Apache Sling Scripting Maven Plugin (WIP, name not final)
 ## What
 This plugin provides support for deriving `sling.resourceType` `Requirements` and `Capabilities` from
 the file-system layout of scripts. Bundles that get extended by the
-[`org.apache.sling.scripting.resolver`](../org-apache-sling-scripting-resolover/) with these `Requirements` and
+[`org.apache.sling.scripting.resolver`](srr/tree/master/org-apache-sling-scripting-resolover/) with these `Requirements` and
 `Capabilities` will have their scripts made available automatically with added versioning and dependency
 support.
 


[sling-scriptingbundle-maven-plugin] 02/17: Refactor a bit and add some tests.

Posted by ra...@apache.org.
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 b9b0acedddc9338d395579152b6f84e7ec1f3b43
Author: Karl Pauls <pa...@apache.org>
AuthorDate: Mon Apr 16 13:32:40 2018 +0200

    Refactor a bit and add some tests.
---
 .../maven/plugin/ScriptingMavenPlugin.java         | 144 +++++++++++----------
 .../maven/plugin/ScriptingMavenPluginTest.java     |  85 ++++++++++++
 2 files changed, 161 insertions(+), 68 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 5cf84c8..701cd70 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,7 +51,7 @@ public class ScriptingMavenPlugin extends AbstractMojo
     @Parameter(defaultValue = "${session}", readonly = true)
     private MavenSession session;
 
-    private final Set<String> METHODS = new HashSet<>(Arrays.asList(new String[]{"TRACE", "OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE"}));
+    private static final Set<String> METHODS = new HashSet<>(Arrays.asList(new String[]{"TRACE", "OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE"}));
 
     public void execute() throws MojoExecutionException
     {
@@ -62,7 +62,7 @@ public class ScriptingMavenPlugin extends AbstractMojo
         scanner.addDefaultExcludes();
         scanner.scan();
 
-        List<String> scripts = Stream.of(scanner.getIncludedFiles()).map(path -> new File(project.getBuild().getOutputDirectory(), path))
+        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()))
             .collect(Collectors.toList());
 
@@ -70,75 +70,23 @@ public class ScriptingMavenPlugin extends AbstractMojo
         List<String> requires = new ArrayList<>();
 
         List<String> capabilities = new ArrayList<>();
-        for (String script : scripts)
+        for (String scriptPath : scriptPaths)
         {
-            String[] parts = script.split("/");
+            Script script = getScripts(scriptPath);
 
-            String rt = parts[0];
-            String version = parts.length > 2 ? new Version(parts[1]).toString() : null;
-            String name = parts.length > 2 ? parts[2] : parts[1];
-            String scriptExtension;
-            int idx = name.lastIndexOf('.');
-            if (idx != -1)
-            {
-                scriptExtension = name.substring(idx + 1);
-                name = name.substring(0, idx);
-            }
-            else
-            {
-                scriptExtension = null;
-            }
-
-            String extension;
-            idx = name.lastIndexOf('.');
-            if (idx != -1)
-            {
-                extension = name.substring(idx + 1);
-                name = name.substring(0, idx);
-            }
-            else
-            {
-                extension = "html";
-            }
-
-            String method;
-            idx = name.indexOf('.');
-            if (idx != -1)
-            {
-                String methodString = name.substring(0, idx);
-                if (METHODS.contains(methodString.toUpperCase()))
-                {
-                    method = methodString.toUpperCase();
-                    name = name.substring(idx + 1);
-                }
-                else
-                {
-                    method = null;
-                }
-            }
-            else if (METHODS.contains(name.toUpperCase()))
-            {
-                method = name.toUpperCase();
-                name = "";
-            }
-            else
-            {
-                method = null;
-            }
-
-            String capability = "sling.resourceType;sling.resourceType=\"" + rt.replace("\"", "\\\"") + "\"";
+            String capability = "sling.resourceType;sling.resourceType=\"" + script.rt.replace("\"", "\\\"") + "\"";
 
-            if (!(rt.equals(name) || rt.endsWith("." + name) || name.isEmpty()))
+            if (!(script.rt.equals(script.name) || script.rt.endsWith("." + script.name) || script.name.isEmpty()))
             {
-                if (!name.equalsIgnoreCase("requires"))
+                if (!script.name.equalsIgnoreCase("requires"))
                 {
-                    if (!name.equalsIgnoreCase("extends"))
+                    if (!script.name.equalsIgnoreCase("extends"))
                     {
-                        capability += ";sling.resourceType.selectors:List<String>=\"" + name.replace("\"", "\\\"") + "\"";
+                        capability += ";sling.resourceType.selectors:List<String>=\"" + script.name.replace("\"", "\\\"") + "\"";
                     }
                     else
                     {
-                        try (BufferedReader input = new BufferedReader(new FileReader(new File(new File(project.getBuild().getOutputDirectory(), "javax.script"), script))))
+                        try (BufferedReader input = new BufferedReader(new FileReader(new File(new File(project.getBuild().getOutputDirectory(), "javax.script"), scriptPath))))
                         {
                             String extend = input.readLine();
 
@@ -153,7 +101,7 @@ public class ScriptingMavenPlugin extends AbstractMojo
                 }
                 else
                 {
-                    try (BufferedReader input = new BufferedReader(new FileReader(new File(new File(project.getBuild().getOutputDirectory(), "javax.script"), script))))
+                    try (BufferedReader input = new BufferedReader(new FileReader(new File(new File(project.getBuild().getOutputDirectory(), "javax.script"), scriptPath))))
                     {
                         for (String line = input.readLine(); line != null; line = input.readLine())
                         {
@@ -166,15 +114,15 @@ public class ScriptingMavenPlugin extends AbstractMojo
                     }
                 }
             }
-            capability += ";sling.resourceType.extensions:List<String>=\"" + extension.replace("\"", "\\\"") + "\"";
+            capability += ";sling.resourceType.extensions:List<String>=\"" + script.extension.replace("\"", "\\\"") + "\"";
 
-            if (method != null)
+            if (script.method != null)
             {
-                capability += ";sling.servlet.methods:List<String>=\"" + method.replace("\"", "\\\"") + "\"";
+                capability += ";sling.servlet.methods:List<String>=\"" + script.method.replace("\"", "\\\"") + "\"";
             }
-            if (version != null)
+            if (script.version != null)
             {
-                capability += ";version:Version=\"" + version + "\"";
+                capability += ";version:Version=\"" + script.version + "\"";
             }
             capabilities.add(capability);
         }
@@ -196,4 +144,64 @@ public class ScriptingMavenPlugin extends AbstractMojo
         project.getProperties().setProperty(ScriptingMavenPlugin.class.getPackage().getName() + "." + Constants.PROVIDE_CAPABILITY, String.join(",", capabilities));
         project.getProperties().setProperty(ScriptingMavenPlugin.class.getPackage().getName() + "." + Constants.REQUIRE_CAPABILITY, String.join(",", requirements));
     }
+
+    static class Script {
+        String rt;
+        String version;
+        String name;
+        String extension;
+        String scriptExtension;
+        String method;
+    }
+
+    static Script getScripts(String script) {
+        Script result = new Script();
+        String[] parts = script.split("/");
+
+        result.rt = parts[0];
+        result.version = parts.length > 2 ? new Version(parts[1]).toString() : null;
+        result.name = parts.length > 2 ? parts[2] : parts[1];
+        int idx = result.name.lastIndexOf('.');
+        if (idx != -1)
+        {
+            result.scriptExtension = result.name.substring(idx + 1);
+            result.name = result.name.substring(0, idx);
+            if (result.scriptExtension.isEmpty())
+            {
+                result.scriptExtension = null;
+            }
+        }
+
+        idx = result.name.lastIndexOf('.');
+        if (idx != -1)
+        {
+            result.extension = result.name.substring(idx + 1);
+            result.name = result.name.substring(0, idx);
+            if (result.extension.isEmpty())
+            {
+                result.extension = "html";
+            }
+        }
+        else
+        {
+            result.extension = "html";
+        }
+
+        idx = result.name.indexOf('.');
+        if (idx != -1)
+        {
+            String methodString = result.name.substring(0, idx).toUpperCase();
+            if (METHODS.contains(methodString))
+            {
+                result.method = methodString;
+                result.name = result.name.substring(idx + 1);
+            }
+        }
+        else if (METHODS.contains(result.name.toUpperCase()))
+        {
+            result.method = result.name.toUpperCase();
+            result.name = "";
+        }
+        return result;
+    }
 }
diff --git a/src/test/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPluginTest.java b/src/test/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPluginTest.java
new file mode 100644
index 0000000..e6a4262
--- /dev/null
+++ b/src/test/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPluginTest.java
@@ -0,0 +1,85 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scripting.maven.plugin;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ScriptingMavenPluginTest
+{
+    @Test
+    public void testScriptNameFullCalculation()
+    {
+        String scriptPath = "org.apache.foo/1.0.0/POST.hi.xml.jsp";
+
+        ScriptingMavenPlugin.Script script = ScriptingMavenPlugin.getScripts(scriptPath);
+
+        Assert.assertEquals("org.apache.foo", script.rt);
+        Assert.assertEquals("1.0.0", script.version);
+        Assert.assertEquals("hi", script.name);
+        Assert.assertEquals("POST", script.method);
+        Assert.assertEquals("xml", script.extension);
+        Assert.assertEquals("jsp", script.scriptExtension);
+    }
+
+    @Test
+    public void testScriptNameMinCalculation()
+    {
+        String scriptPath = "org.apache.foo/foo";
+
+        ScriptingMavenPlugin.Script script = ScriptingMavenPlugin.getScripts(scriptPath);
+
+        Assert.assertEquals("org.apache.foo", script.rt);
+        Assert.assertNull("1.0.0", script.version);
+        Assert.assertEquals("foo", script.name);
+        Assert.assertNull(script.method);
+        Assert.assertEquals("html", script.extension);
+        Assert.assertNull(script.scriptExtension);
+    }
+
+    @Test
+    public void testScriptNameVersionAndMethodCalculation()
+    {
+        String scriptPath = "org.apache.foo/1.2.0/Post.jsp";
+
+        ScriptingMavenPlugin.Script script = ScriptingMavenPlugin.getScripts(scriptPath);
+
+        Assert.assertEquals("org.apache.foo", script.rt);
+        Assert.assertEquals("1.2.0", script.version);
+        Assert.assertEquals("", script.name);
+        Assert.assertEquals("POST", script.method);
+        Assert.assertEquals("html", script.extension);
+        Assert.assertEquals("jsp", script.scriptExtension);
+    }
+
+    @Test
+    public void testScriptNameVersionAndMethodMinCalculation()
+    {
+        String scriptPath = "org.apache.foo/1.2.0/Post.";
+
+        ScriptingMavenPlugin.Script script = ScriptingMavenPlugin.getScripts(scriptPath);
+
+        Assert.assertEquals("org.apache.foo", script.rt);
+        Assert.assertEquals("1.2.0", script.version);
+        Assert.assertEquals("",script.name);
+        Assert.assertEquals("POST", script.method);
+        Assert.assertEquals("html", script.extension);
+        Assert.assertNull(script.scriptExtension);
+    }
+}


[sling-scriptingbundle-maven-plugin] 16/17: made script file handling OS-independent - attempt 3

Posted by ra...@apache.org.
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 2a5dc673a4262d32534fced5d027ec82796f6528
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Tue Aug 14 17:20:16 2018 +0200

    made script file handling OS-independent - attempt 3
---
 .../sling/scripting/maven/plugin/ScriptingMavenPlugin.java    | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

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 b99bfc3..25842ab 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
@@ -59,6 +59,8 @@ public class ScriptingMavenPlugin extends AbstractMojo
     private static final Set<String> METHODS = new HashSet<>(Arrays.asList(new String[]{"TRACE", "OPTIONS", "GET", "HEAD", "POST", "PUT",
             "DELETE", "PATCH"}));
 
+    private static final Set<String> FILE_SEPARATORS = new HashSet<>(Arrays.asList("\\", "/"));
+
     public void execute() throws MojoExecutionException
     {
         File sdFile = new File(scriptsDirectory);
@@ -177,8 +179,15 @@ public class ScriptingMavenPlugin extends AbstractMojo
     }
 
     static Script getScripts(String script) {
+        String fileSeparator = null;
+        for (String sep : FILE_SEPARATORS) {
+            if (script.contains(sep)) {
+                fileSeparator = sep;
+                break;
+            }
+        }
         Script result = new Script();
-        String[] parts = script.split(Pattern.quote(File.separator));
+        String[] parts = script.split(Pattern.quote(fileSeparator));
 
         result.rt = parts[0];
         result.version = parts.length > 2 ? new Version(parts[1]).toString() : null;


[sling-scriptingbundle-maven-plugin] 15/17: made script file handling OS-independent - attempt 2

Posted by ra...@apache.org.
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 ef02e8dfcd7e22a178db1056132c438c64b073cb
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Tue Aug 14 16:58:39 2018 +0200

    made script file handling OS-independent - attempt 2
---
 .../org/apache/sling/scripting/maven/plugin/ScriptingMavenPlugin.java  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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 bdbded3..b99bfc3 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
@@ -39,6 +39,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -177,7 +178,7 @@ public class ScriptingMavenPlugin extends AbstractMojo
 
     static Script getScripts(String script) {
         Script result = new Script();
-        String[] parts = script.split(File.separator);
+        String[] parts = script.split(Pattern.quote(File.separator));
 
         result.rt = parts[0];
         result.version = parts.length > 2 ? new Version(parts[1]).toString() : null;


[sling-scriptingbundle-maven-plugin] 01/17: Add a maven plugin for generating caps/reqs

Posted by ra...@apache.org.
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 0dc9172f97c24a594d5053998bcc003e193ef823
Author: Karl Pauls <pa...@apache.org>
AuthorDate: Sun Apr 15 23:40:17 2018 +0200

    Add a maven plugin for generating caps/reqs
---
 pom.xml                                            |  71 ++++++++
 .../maven/plugin/ScriptingMavenPlugin.java         | 199 +++++++++++++++++++++
 2 files changed, 270 insertions(+)

diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..fc1bc12
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ 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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <artifactId>sling</artifactId>
+        <groupId>org.apache.sling</groupId>
+        <version>33</version>
+        <relativePath/>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>org.apache.sling.scripting.maven.plugin</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>maven-plugin</packaging>
+
+    <properties>
+        <sling.java.version>8</sling.java.version>
+    </properties>
+
+
+<dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>3.0</version>
+    </dependency>
+ 
+    <!-- dependencies to annotations -->
+    <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>3.4</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.maven</groupId>
+        <artifactId>maven-project</artifactId>
+        <version>2.2.1</version>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.maven</groupId>
+        <artifactId>maven-core</artifactId>
+        <version>3.5.0</version>
+    </dependency>
+    <dependency>
+        <groupId>org.osgi</groupId>
+        <artifactId>osgi.core</artifactId>
+        <scope>compile</scope>
+    </dependency>
+</dependencies>
+</project>
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
new file mode 100644
index 0000000..5cf84c8
--- /dev/null
+++ b/src/main/java/org/apache/sling/scripting/maven/plugin/ScriptingMavenPlugin.java
@@ -0,0 +1,199 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scripting.maven.plugin;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.utils.io.DirectoryScanner;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+import org.osgi.framework.VersionRange;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+@Mojo(name = "metadata", defaultPhase = LifecyclePhase.PACKAGE)
+public class ScriptingMavenPlugin extends AbstractMojo
+{
+
+    @Parameter(defaultValue = "${project}", readonly = true)
+    private MavenProject project;
+
+    @Parameter(defaultValue = "${session}", readonly = true)
+    private MavenSession session;
+
+    private final Set<String> METHODS = new HashSet<>(Arrays.asList(new String[]{"TRACE", "OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE"}));
+
+    public void execute() throws MojoExecutionException
+    {
+        DirectoryScanner scanner = new DirectoryScanner();
+        scanner.setBasedir(project.getBuild().getOutputDirectory());
+        scanner.setIncludes("javax.script/**");
+        scanner.setExcludes("**/*.class");
+        scanner.addDefaultExcludes();
+        scanner.scan();
+
+        List<String> scripts = 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()))
+            .collect(Collectors.toList());
+
+
+        List<String> requires = new ArrayList<>();
+
+        List<String> capabilities = new ArrayList<>();
+        for (String script : scripts)
+        {
+            String[] parts = script.split("/");
+
+            String rt = parts[0];
+            String version = parts.length > 2 ? new Version(parts[1]).toString() : null;
+            String name = parts.length > 2 ? parts[2] : parts[1];
+            String scriptExtension;
+            int idx = name.lastIndexOf('.');
+            if (idx != -1)
+            {
+                scriptExtension = name.substring(idx + 1);
+                name = name.substring(0, idx);
+            }
+            else
+            {
+                scriptExtension = null;
+            }
+
+            String extension;
+            idx = name.lastIndexOf('.');
+            if (idx != -1)
+            {
+                extension = name.substring(idx + 1);
+                name = name.substring(0, idx);
+            }
+            else
+            {
+                extension = "html";
+            }
+
+            String method;
+            idx = name.indexOf('.');
+            if (idx != -1)
+            {
+                String methodString = name.substring(0, idx);
+                if (METHODS.contains(methodString.toUpperCase()))
+                {
+                    method = methodString.toUpperCase();
+                    name = name.substring(idx + 1);
+                }
+                else
+                {
+                    method = null;
+                }
+            }
+            else if (METHODS.contains(name.toUpperCase()))
+            {
+                method = name.toUpperCase();
+                name = "";
+            }
+            else
+            {
+                method = null;
+            }
+
+            String capability = "sling.resourceType;sling.resourceType=\"" + rt.replace("\"", "\\\"") + "\"";
+
+            if (!(rt.equals(name) || rt.endsWith("." + name) || name.isEmpty()))
+            {
+                if (!name.equalsIgnoreCase("requires"))
+                {
+                    if (!name.equalsIgnoreCase("extends"))
+                    {
+                        capability += ";sling.resourceType.selectors:List<String>=\"" + name.replace("\"", "\\\"") + "\"";
+                    }
+                    else
+                    {
+                        try (BufferedReader input = new BufferedReader(new FileReader(new File(new File(project.getBuild().getOutputDirectory(), "javax.script"), script))))
+                        {
+                            String extend = input.readLine();
+
+                            capability += ";extends=\"" + extend.split(";")[0].replace("\"", "\\\"") + "\"";
+                            requires.add(extend);
+                        }
+                        catch (Exception ex)
+                        {
+                            getLog().error(ex);
+                        }
+                    }
+                }
+                else
+                {
+                    try (BufferedReader input = new BufferedReader(new FileReader(new File(new File(project.getBuild().getOutputDirectory(), "javax.script"), script))))
+                    {
+                        for (String line = input.readLine(); line != null; line = input.readLine())
+                        {
+                            requires.add(line);
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        getLog().error(ex);
+                    }
+                }
+            }
+            capability += ";sling.resourceType.extensions:List<String>=\"" + extension.replace("\"", "\\\"") + "\"";
+
+            if (method != null)
+            {
+                capability += ";sling.servlet.methods:List<String>=\"" + method.replace("\"", "\\\"") + "\"";
+            }
+            if (version != null)
+            {
+                capability += ";version:Version=\"" + version + "\"";
+            }
+            capabilities.add(capability);
+        }
+        List<String> requirements = new ArrayList<>();
+        for (String require : requires)
+        {
+            String[] parts = require.split(";");
+            String rt = parts[0];
+            String filter = "(sling.resourceType=\"" + rt.replace("\"", "\\\"") + "\")";
+
+            if (parts.length > 1)
+            {
+                VersionRange range = new VersionRange(parts[1].substring(parts[1].indexOf("=") + 1).replace("\"", "").trim());
+                filter = "(&" + filter + range.toFilterString("version") + ")";
+            }
+            requirements.add("sling.resourceType;filter:=\"" + filter + "\"");
+        }
+
+        project.getProperties().setProperty(ScriptingMavenPlugin.class.getPackage().getName() + "." + Constants.PROVIDE_CAPABILITY, String.join(",", capabilities));
+        project.getProperties().setProperty(ScriptingMavenPlugin.class.getPackage().getName() + "." + Constants.REQUIRE_CAPABILITY, String.join(",", requirements));
+    }
+}


[sling-scriptingbundle-maven-plugin] 11/17: Improvements

Posted by ra...@apache.org.
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 6e681b0d643fe4c5ba21da6e4ed55df0f7689336
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Fri Apr 20 15:03:13 2018 +0200

    Improvements
    
    * allowed scripts to retrieve their own name through the "javax_script_filename" global property
    * added support for HTTP methods script matching in BundledScriptFinder
    * added support for the PATCH HTTP method in the ScriptingMavenPlugin
    * made sure that the Dispatcher servlet from the BundledScriptTracker is registered on the same
    extensions as the BundledScriptServlet for the same sling.resourceType capability
    * moved example endpoints for better understanding of content-to-script mapping
    * updated EndpointIT with the new endpoints plus the Sling Testing Clients mechanism for
    waiting for content to be installed
---
 .../org/apache/sling/scripting/maven/plugin/ScriptingMavenPlugin.java  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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 283b660..6f95a42 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,7 +51,8 @@ public class ScriptingMavenPlugin extends AbstractMojo
     @Parameter(defaultValue = "${session}", readonly = true)
     private MavenSession session;
 
-    private static final Set<String> METHODS = new HashSet<>(Arrays.asList(new String[]{"TRACE", "OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE"}));
+    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
     {


[sling-scriptingbundle-maven-plugin] 14/17: made script file handling OS-independent

Posted by ra...@apache.org.
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 bb072ae9626ceb58c19895b244df065ae2c42515
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Tue Aug 14 16:54:57 2018 +0200

    made script file handling OS-independent
---
 .../org/apache/sling/scripting/maven/plugin/ScriptingMavenPlugin.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 875133c..bdbded3 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
@@ -177,7 +177,7 @@ public class ScriptingMavenPlugin extends AbstractMojo
 
     static Script getScripts(String script) {
         Script result = new Script();
-        String[] parts = script.split("/");
+        String[] parts = script.split(File.separator);
 
         result.rt = parts[0];
         result.version = parts.length > 2 ? new Version(parts[1]).toString() : null;


[sling-scriptingbundle-maven-plugin] 10/17: corrected more relative links

Posted by ra...@apache.org.
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 876e3d12827cea87bd7dbd54e1db2fe5bd01151b
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Thu Apr 19 11:55:20 2018 +0200

    corrected more relative links
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index ab13d7a..d35bf64 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ expects the following layout:
 javax.script/<sling-resourceType>/<version>/[<METHOD>.]<name>[.<selector>][.<extension>].<script-extension>
 ```
 
-From that, it will create an appropriate `Provide-Capability` (see the ["How"](../org-apache-sling-scripting-resolver/README.md#how)
+From that, it will create an appropriate `Provide-Capability` (see the ["How"](../org-apache-sling-scripting-resolver/#how)
 section of the scripting resolver) with the following extra assumptions:
 
   * if the `name` part equals the `sling.resourceType` or the last part of it, it is assumed to be the name of the main script;


[sling-scriptingbundle-maven-plugin] 05/17: reorganised project

Posted by ra...@apache.org.
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 45736dcbf34eed370a4ae622b4584ec394fcf41c
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Thu Apr 19 11:42:16 2018 +0200

    reorganised project
---
 README.md | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 pom.xml   |   6 ++--
 2 files changed, 107 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b2f280f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,104 @@
+Apache Sling Scripting Maven Plugin (WIP, name not final)
+====
+
+## What
+This plugin provides support for deriving `sling.resourceType` `Requirements` and `Capabilities` from
+the file-system layout of scripts. Bundles that get extended by the
+[`org.apache.sling.scripting.resolver`](../org-apache-sling-scripting-resolover/) with these `Requirements` and
+`Capabilities` will have their scripts made available automatically with added versioning and dependency
+support.
+
+## Why
+Manually defining the `Require-Capability` and `Provide-Capability` bundle headers is error-prone and unnecessary,
+as they can be derived from the file-system layout required for scripts by the resolver (for the most part).
+
+## How
+The plugin scans the `javax.script` file-system directory and will generate `Capabilities` for the scripts it finds. It
+expects the following layout:
+
+```
+javax.script/<sling-resourceType>/<version>/[<METHOD>.]<name>[.<selector>][.<extension>].<script-extension>
+```
+
+From that, it will create an appropriate `Provide-Capability` (see the ["How"](../org-apache-sling-scripting-resolover/#how) section of
+the scripting resolver) with the following extra assumptions:
+
+  * if the `name` part equals the `sling.resourceType` or the last part of it, it is assumed to be the name of the main script;
+  otherwise, it is assumed to be a selector;
+  * if the file name is just `extends` it is assumed to be a file containing a single line with the
+  `resourceType` used for the `extends` capability attribute followed by a `;version=<version-range>`; in this case, the
+  plugin will set the `extends` attribute to the given `resourceType` and generate a `Require-Capability` for that
+  `resourceType` with the given version range;
+  * if the file name is just `requires` the plugin will read it line by line (assuming the same syntax as for the `extends` file)
+  and generate a `Require-Capability` for each line based on the given `resourceType` and version range.
+
+### Example
+As an example, let's assume the following layout:
+
+```
+javax.scripting/
+    org.foo/1.0.0
+        POST.foo.html
+```
+
+This will generate following `Provide-Capability`:
+
+```
+sling.resourceType;
+    sling.resourceType="org.foo";
+    sling.servlet.methods:List<String>=POST;
+    version:Version="1.0.0"
+```
+
+For a bigger example providing several versions and using an `extends` file consider the following two projects: 
+
+  * [example](../org-apache-sling-scripting-examplebundle);
+  * [example.hi](../org-apache-sling-scripting-examplebundle.hi).
+
+## So how do I use the plugin?
+
+The plugin doesn't currently integrate with the `maven-bundle-plugin`. The generated `Require-Capability` and 
+`Provide-Capability` headers values are simply made available via properties:
+
+```
+${org.apache.sling.scripting.maven.plugin.Provide-Capability}
+${org.apache.sling.scripting.maven.plugin.Require-Capability}
+```
+
+However, that makes it reasonable straightforward to use the plugin by just adding it into your build in the 
+`prepare-package` phase and use the two properties in the manifest writing instructions of another plugin like 
+the `maven-bundle-plugin`:
+
+```
+    <plugin>
+    <groupId>org.apache.sling</groupId>
+        <artifactId>org.apache.sling.scripting.maven.plugin</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+        <executions>
+            <execution>
+                <phase>prepare-package</phase>
+                <goals>
+                    <goal>metadata</goal>
+                </goals>
+            </execution>
+        </executions>
+    </plugin>
+    <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+            <instructions>
+                <Provide-Capability>
+                    ${org.apache.sling.scripting.maven.plugin.Provide-Capability}
+                </Provide-Capability>
+                <Require-Capability>
+                    osgi.extender;filter:="(&amp;(osgi.extender=sling.scripting)(version>=1.0.0)(!(version>=2.0.0)))",
+                    ${org.apache.sling.scripting.maven.plugin.Require-Capability}
+                </Require-Capability>
+            </instructions>
+        </configuration>
+    </plugin>
+```
+
+You can find an example in [here](../examples/org-apache-sling-scripting-examplebundle/pom.xml).
diff --git a/pom.xml b/pom.xml
index fc1bc12..1d8872e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,10 +22,10 @@
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
     <parent>
-        <artifactId>sling</artifactId>
         <groupId>org.apache.sling</groupId>
-        <version>33</version>
-        <relativePath/>
+        <artifactId>org.apache.sling.scripting.resolver.reactor</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 


[sling-scriptingbundle-maven-plugin] 04/17: Make the extends requirement filter out selectors.

Posted by ra...@apache.org.
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 03bf39a936ad2c2d2d3e03ea624c2684b5080af3
Author: Karl Pauls <pa...@apache.org>
AuthorDate: Mon Apr 16 15:56:15 2018 +0200

    Make the extends requirement filter out selectors.
---
 .../apache/sling/scripting/maven/plugin/ScriptingMavenPlugin.java   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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 1a49bcb..283b660 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
@@ -91,7 +91,7 @@ public class ScriptingMavenPlugin extends AbstractMojo
                             String extend = input.readLine();
 
                             capability += ";extends=\"" + extend.split(";")[0].replace("\"", "\\\"") + "\"";
-                            requires.add(extend);
+                            requires.add(extend + ";extends=true" );
                         }
                         catch (Exception ex)
                         {
@@ -141,6 +141,10 @@ public class ScriptingMavenPlugin extends AbstractMojo
                 VersionRange range = new VersionRange(parts[1].substring(parts[1].indexOf("=") + 1).replace("\"", "").trim());
                 filter = "(&" + filter + range.toFilterString("version") + ")";
             }
+            if (parts.length > 2)
+            {
+                filter = "(&" + filter + "(!(sling.resourceType.selectors=*)))";
+            }
             requirements.add("sling.resourceType;filter:=\"" + filter + "\"");
         }
 


[sling-scriptingbundle-maven-plugin] 12/17: make the scripts directory configurable

Posted by ra...@apache.org.
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 <ra...@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())
                         {