sling-commits mailing list archives

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

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

commit 45736dcbf34eed370a4ae622b4584ec394fcf41c
Author: Radu Cotescu <radu@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>
 


Mime
View raw message