You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by an...@apache.org on 2019/05/26 21:21:56 UTC

[sling-org-apache-sling-feature-modelconverter] branch standalone-app created (now c299162)

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

andysch pushed a change to branch standalone-app
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-modelconverter.git.


      at c299162  Created a CLI tool based on picocli and added some adjustments to work better with Features

This branch includes the following new commits:

     new c299162  Created a CLI tool based on picocli and added some adjustments to work better with Features

The 1 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-org-apache-sling-feature-modelconverter] 01/01: Created a CLI tool based on picocli and added some adjustments to work better with Features

Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

andysch pushed a commit to branch standalone-app
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-modelconverter.git

commit c2991620477b10d7638dbf4e588cac80abf3d097
Author: Andreas Schaefer <ac...@Andreass-iMac.local>
AuthorDate: Sun May 26 14:21:40 2019 -0700

    Created a CLI tool based on picocli and added some adjustments to work better with Features
    
    - bundle version variables are resolved as this is not supported by Feature Maven Plugin and Launcher (PM to FM conversion)
    - Overwrites are ignored when output file last modifiction is greater or equal to source file last modification (tests might fail on fast computers) and adjusted the log statement to reflect that (both for PM to FM and FM to PM conversions)
    - Allow to set Maven properties for the FM Model Id and move the name to become a classifier if name is provided
    - Repoinit is not of type TEXT instead of JSON as JSON is not supported
    - Added SLF4J simple logging configuration and migrated test output to log statements
---
 pom.xml                                            |  93 +++++++-
 readme.md                                          | 126 +++++++++++
 src/main/assembly/README.md                        | 149 +++++++++++++
 src/main/assembly/bin.xml                          |  71 +++++++
 .../modelconverter/FeatureToProvisioning.java      |   4 +-
 .../apache/sling/feature/modelconverter/Main.java  | 129 ++++++++++++
 .../modelconverter/ProvisioningToFeature.java      |  95 +++++++--
 src/main/legal/LICENSE-with-deps                   | 233 +++++++++++++++++++++
 src/main/legal/NOTICE-with-deps                    |   5 +
 src/main/legal/license-header                      |  14 ++
 .../feature/modelconverter/ModelConverterTest.java | 109 ++++++++--
 src/test/resources/boot.json                       |   6 +-
 src/test/resources/boot_gav.json                   |   6 +-
 src/test/resources/more/repoinit-multiple.json     |   2 +-
 src/test/resources/oak.json                        |  12 +-
 src/test/resources/repoinit.json                   |   2 +-
 src/test/resources/simplelogger.properties         |   5 +
 17 files changed, 1005 insertions(+), 56 deletions(-)

diff --git a/pom.xml b/pom.xml
index f695b50..e26922c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,9 +49,83 @@
                     <excludes>
                         <exclude>readme.md</exclude>
                         <exclude>src/test/resources/**</exclude>
+                        <exclude>src/main/legal/NOTICE-with-deps</exclude>
                     </excludes>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>license-maven-plugin</artifactId>
+                <version>1.16</version>
+                <executions>
+                    <execution>
+                        <id>add-third-party</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>add-third-party</goal>
+                        </goals>
+                        <configuration>
+                            <fileTemplate>${basedir}/src/main/legal/LICENSE-with-deps</fileTemplate>
+                            <thirdPartyFilename>LICENSE-with-deps</thirdPartyFilename>
+                            <sortArtifactByName>true</sortArtifactByName>
+                            <excludedScopes>test</excludedScopes>
+                            <licenseMerges>
+                                <licenseMerge>The Apache Software License, Version 2.0|Apache License, Version 2.0|Apache Public License 2.0</licenseMerge>
+                            </licenseMerges>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>appassembler-maven-plugin</artifactId>
+                <version>2.0.0</version>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>assemble</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <repositoryLayout>flat</repositoryLayout>
+                    <repositoryName>lib</repositoryName>
+                    <useWildcardClassPath>true</useWildcardClassPath>
+                    <extraJvmArguments>-Dproject.artifactId=${project.artifactId} -Dproject.version=${project.version} -Dbuild.timestamp=${maven.build.timestamp} -Duser.timezone=UTC -Dfile.encoding=UTF-8</extraJvmArguments>
+                    <defaultJvmSettings>-Xms500m -Xmx500m -XX:PermSize=128m -XX:-UseGCOverheadLimit</defaultJvmSettings>
+                    <licenseHeaderFile>${basedir}/src/main/legal/license-header</licenseHeaderFile>
+                    <programs>
+                        <program>
+                            <mainClass>org.apache.sling.feature.modelconverter.Main</mainClass>
+                            <name>pm2fm</name>
+                        </program>
+                    </programs>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>3.1.0</version>
+                <executions>
+                    <execution>
+                        <id>assembly</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <finalName>${project.build.finalName}</finalName>
+                    <tarLongFileMode>gnu</tarLongFileMode>
+                    <appendAssemblyId>false</appendAssemblyId>
+                    <descriptors>
+                        <descriptor>${basedir}/src/main/assembly/bin.xml</descriptor>
+                    </descriptors>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
     
@@ -67,6 +141,11 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.feature</artifactId>
             <version>1.0.2</version>
@@ -90,7 +169,14 @@
             <version>1.0.0</version>
             <scope>provided</scope>
         </dependency>
-        
+
+        <dependency>
+            <groupId>info.picocli</groupId>
+            <artifactId>picocli</artifactId>
+            <version>3.6.0</version>
+            <scope>provided</scope>
+        </dependency>
+
         <!-- Testing -->
         <dependency>
             <groupId>junit</groupId>
@@ -115,10 +201,5 @@
             <version>2.18.3</version>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 </project>
diff --git a/readme.md b/readme.md
index ee54b23..813a661 100644
--- a/readme.md
+++ b/readme.md
@@ -7,3 +7,129 @@
 The Model Converter can convert between the Sling Provisioning Model and the Sling Feature Model and back.
 
 For further documentation see: https://github.com/apache/sling-org-apache-sling-feature/blob/master/readme.md
+
+## Building
+
+This tool can be built using `mvn clean install`. For testing purposes these
+arguments can be provided:
+* **test.prov.files.tempdir**: test output folder that must exist before the build
+* **test.prov.no.delete**: if no output folder is provided this flag indicates
+that the files inside the temporary test output folder is not deleted
+
+## The CLI Tool
+
+**Attention**: as of now the CLI tool is only supporting conversions from
+Provisioning Model to Feature Model.
+
+The tool is distributed with a commodity package containing all is needed
+in order to convert Provisioning Models into Feature Model files. It will
+launch the `ProvisioningToFeature` form the shell:
+
+```
+$ unzip -l target/org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT.zip 
+Archive:  target/org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT.zip
+  Length      Date    Time    Name
+---------  ---------- -----   ----
+        0  05-23-2019 08:36   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/
+        0  05-23-2019 08:36   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/bin/
+        0  05-23-2019 08:36   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/lib/
+     5998  05-23-2019 06:47   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/README.md
+    26081  03-09-2019 13:08   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/lib/geronimo-json_1.0_spec-1.0-alpha-1.jar
+    12783  05-23-2019 08:36   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/LICENSE
+    32266  05-23-2019 08:36   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/lib/org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT.jar
+      178  05-23-2019 06:47   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/NOTICE
+   242435  04-04-2019 14:00   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/lib/picocli-3.6.0.jar
+     3802  05-23-2019 08:36   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/bin/pm2fm
+     3257  05-23-2019 08:36   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/bin/pm2fm.bat
+    14769  03-29-2019 06:30   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/lib/org.osgi.annotation.versioning-1.0.0.jar
+    41203  03-09-2019 13:15   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/lib/slf4j-api-1.7.25.jar
+    15257  03-29-2019 06:30   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/lib/slf4j-simple-1.7.25.jar
+   115234  05-14-2019 11:38   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/lib/org.apache.sling.feature-1.0.2.jar
+   164176  05-14-2019 11:39   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/lib/org.apache.sling.feature.io-1.0.2.jar
+    76683  04-03-2019 09:41   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/lib/org.apache.sling.provisioning.model-1.8.2.jar
+   106841  03-29-2019 06:30   org.apache.sling.feature.modelconverter-1.0.3-SNAPSHOT/lib/org.apache.sling.commons.johnzon-1.0.0.jar
+---------                     -------
+   860963                     18 files
+```
+
+once the package is decompressed, open the shell and type:
+
+```
+$ ./bin/pm2fm -h
+Usage: pm2fm [-DhV] [-g=<groupId>] -i=<provisioningModelsInputDirectory>
+             [-n=<name>] -o=<featureModelsOutputDirectory> [-v=<version>]
+             [-a=<addFrameworkProperties>]... [-d=<dropVariables>]...
+Apache Sling Provisioning Model to Sling Feature Model converter
+  -a, --addFrameworkProperties=<addFrameworkProperties>
+                             Adds Framework Properties to Feature Models. Format:
+                               <Model Name>:<Property Name>=<value>
+  -d, --dropVariables=<dropVariables>
+                             All matching Variables (by name) in a Feature Model are
+                               dropped
+  -D, --noProvisioningModelName
+                             If flagged then the Provisioning Model Name is not
+                               added'
+  -g, --group-id=<groupId>   Overwriting the Group Id of the Model ID
+  -h, --help                 Display the usage message.
+  -i, --provisining-input-directory=<provisioningModelsInputDirectory>
+                             The input directory where the Provisioning File are.
+  -n, --name=<name>          Sets a general Name for all converted Models. This also
+                               means that the name is placed in the classifier
+  -o, --features-output-directory=<featureModelsOutputDirectory>
+                             The output directory where the Feature File will be
+                               generated.
+  -v, --version=<version>    Overwriting the Version of the Model ID
+  -V, --useProvidedVersion   If flagged then the provided version will override any
+                               given version from Provisioning Model'
+Copyright(c) 2019 The Apache Software Foundation.
+```
+
+to see all the available options; a sample execution could look like:
+
+```
+$sh ./bin/pm2fm \
+    -i $SLING_DEV_HOME/sling-org-apache-sling-starter/src/main/provisioning \
+    -o fm.out \
+    -g "\${project.groupId}" \
+    -v "\${project.version}" \
+    -V \
+    -n "\${project.artifactId}" \
+    -D \
+    -a "launchpad:felix.systempackages.substitution=true" \
+    -a "launchpad:felix.systempackages.calculate.uses=true"
+```
+
+**Note**: this will generate all the Feature Models for the current Sling
+Provisioning (Sling (PM) Starter). The groupId, artifactId and version is
+set to a placeholder and with it the model name is placed inside the classifier.
+In addition the Provisioning Model Name is dropped (duplicates) and two
+framework properties are added to the launchpad FM to make bundles that uses
+Java dependencies activate.
+
+Argument Files for Long Command Lines:
+
+```
+# argfile to convert Sling Provisioning Model to Feature Model
+
+# SLING_DEV_HOME points to the sling development folder
+-i $SLING_DEV_HOME/sling-org-apache-sling-starter/src/main/provisioning
+# Will be created if it does not exists
+-o fm.out
+# Set the Model Id parts and add the name as classifier 
+-g "\${project.groupId}"
+-v "\${project.version}"
+-n "\${project.artifactId}"
+# Override any existing version number
+-V
+# Delete Provisioning Model Name to avoid duplicates
+-D
+# Add Launchpad Framework Properties to make bundles with Java dependencies activate
+-a "launchpad:felix.systempackages.substitution=true"
+-a "launchpad:felix.systempackages.calculate.uses=true"
+```
+
+then execute the command
+
+```
+$ ./bin/pm2fm @arfile
+````
diff --git a/src/main/assembly/README.md b/src/main/assembly/README.md
new file mode 100644
index 0000000..4f743d5
--- /dev/null
+++ b/src/main/assembly/README.md
@@ -0,0 +1,149 @@
+```
+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.name} - ${project.inceptionYear}
+
+## What is it?
+
+  ${project.description}
+
+## Licensing
+
+  Please see the files called LICENSE and NOTICE
+
+## Documentation
+
+  The most up-to-date documentation can be found at ${project.url}.
+
+## Useful URLs
+
+  Home Page:          ${project.url}/
+  Source Code:        ${project.scm.url}
+  Issue Tracking:     ${project.issueManagement.url}
+
+## System Requirements
+
+### JDK
+
+    ${sling.java.version} or above. (see http://www.oracle.com/technetwork/java/)
+
+### Memory
+
+    No minimum requirement.
+
+### Disk
+
+    No minimum requirement.
+
+###  Operating System
+
+    No minimum requirement. On Windows, Windows NT and above or Cygwin is required for
+    the startup scripts. Tested on Windows XP, Fedora Core and Mac OS X.
+
+---
+
+## Installation
+
+### Windows 2000/XP
+
+  1) Unzip the distribution archive, i.e. `${project.build.finalName}.zip` to the directory you wish to install `${project.name} ${project.version}`.
+These instructions assume you chose `C:\Program Files`.
+The subdirectory `${project.build.finalName}` will be created from the archive.
+
+  2) Add the `SFA_HOME` environment variable by opening up the system properties (WinKey + Pause), selecting the "Advanced" tab, and the "Environment Variables" button, then adding the `SFA_HOME` variable in the user variables with the value `C:\Program Files\${project.build.finalName}`.
+
+  3) In the same dialog, add the SFA environment variable in the user variables with the value `%SFA_HOME%\bin`.
+
+  4) In the same dialog, update/create the _Path_ environment variable in the user variables and prepend the value `%SFA%` to add `${project.name}` available in the command line.
+
+  5) In the same dialog, make sure that `JAVA_HOME` exists in your user variables or in the system variables and it is set to the location of your JDK, e.g. `C:\Program Files\Java\1.8.0_152` and that `%JAVA_HOME%\bin` is in your _Path_ environment variable.
+
+  6) Open a new command prompt (Winkey + R then type cmd) and run `sfa --version` to verify that it is correctly installed.
+
+## Unix-based Operating Systems (Linux, Solaris and Mac OS X)
+
+  1) Extract the distribution archive, i.e. `${project.build.finalName}.tar.gz` to the directory you wish to install `${project.name} ${project.version}`.
+These instructions assume you chose `/usr/local`.
+The subdirectory `${project.build.finalName}` will be created from the archive.
+
+  2) In a command terminal, add the `SFA_HOME` environment variable, e.g.
+        `export SFA_HOME=/usr/local/${project.build.finalName}`.
+
+  3) Add the `SFA` environment variable, e.g. `export SFA=$SFA_HOME/bin`.
+
+  4) Add `SFA` environment variable to your path, e.g. `export PATH=$SFA:$PATH`.
+
+  5) Make sure that `JAVA_HOME` is set to the location of your JDK, e.g. `export JAVA_HOME=/usr/java/1.8.0_152` and that `$JAVA_HOME/bin` is in your `PATH` environment variable.
+
+  6) Run `sfa --version` to verify that it is correctly installed.
+
+---
+
+## Execution
+
+  Open the shell and type `cp2sf -h` to see the available commands:
+
+```
+$ ./cp2sf -h
+Usage: cp2fm [-hmqsvX] [-b=<bundlesStartOrder>] -c=<contentPackage>
+             -o=<outputDirectory> [-f=<filteringPatterns>]...
+Apache Sling Content Package to Sling Feature converter
+  -b, --bundles-start-order=<bundlesStartOrder>
+                            The order to start detected bundles.
+  -c, --content-package=<contentPackage>
+                            The content-package input file.
+  -f, --filtering-patterns=<filteringPatterns>
+                            Regex based pattern(s) to reject content-package archive
+                              entries.
+  -h, --help                Display the usage message.
+  -m, --merge-configurations
+                            Flag to mark OSGi configurations with same PID will be
+                              merged, the tool will fail otherwise.
+  -o, --output-directory=<outputDirectory>
+                            The output directory where the Feature File and the
+                              bundles will be deployed.
+  -q, --quiet               Log errors only.
+  -s, --strict-validation   Flag to mark the content-package input file being strict
+                              validated.
+  -v, --version             Display version information.
+  -X, --verbose             Produce execution debug output.
+Copyright(c) 2019 The Apache Software Foundation.
+```
+
+a sample execution could look like:
+
+```
+$ ./bin/cp2sf -v -b 20 -c /content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/test-content-package.zip -o /tmp
+```
+
+### Argument Files for Long Command Lines
+
+```
+# argfile
+# comments are supported
+
+-v
+-b 20
+-c /content-package-2-feature-model/src/test/resources/org/apache/sling/cp2fm/test-content-package.zip
+-o /tmp
+```
+
+then execute the command
+
+```
+$ ./bin/cp2sf @arfile
+````
diff --git a/src/main/assembly/bin.xml b/src/main/assembly/bin.xml
new file mode 100644
index 0000000..482f4cd
--- /dev/null
+++ b/src/main/assembly/bin.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.
+-->
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd">
+
+  <id>${project.build.finalName}</id>
+  <formats>
+    <format>tar.gz</format>
+    <format>zip</format>
+  </formats>
+  <includeBaseDirectory>true</includeBaseDirectory>
+  <baseDirectory>${project.build.finalName}</baseDirectory>
+
+  <files>
+    <file>
+      <source>${basedir}/src/main/assembly/README.md</source>
+      <filtered>true</filtered>
+      <outputDirectory>/</outputDirectory>
+      <fileMode>666</fileMode>
+    </file>
+
+    <!--
+     | Use the N&L files which apply to the included dependencies
+    -->
+    <file>
+      <source>${project.build.directory}/generated-sources/license/LICENSE-with-deps</source>
+      <destName>LICENSE</destName>
+    </file>
+    <file>
+      <source>${basedir}/src/main/legal/NOTICE-with-deps</source>
+      <destName>NOTICE</destName>
+    </file>
+  </files>
+
+  <fileSets>
+    <!--
+     | shell scripts
+    -->
+    <fileSet>
+      <directory>${project.build.directory}/appassembler/bin/</directory>
+      <outputDirectory>/bin</outputDirectory>
+      <fileMode>755</fileMode>
+      <directoryMode>755</directoryMode>
+    </fileSet>
+  </fileSets>
+
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>/lib</outputDirectory>
+      <scope>provided</scope>
+      <useTransitiveDependencies>true</useTransitiveDependencies>
+      <useProjectArtifact>true</useProjectArtifact>
+    </dependencySet>
+  </dependencySets>
+
+</assembly>
diff --git a/src/main/java/org/apache/sling/feature/modelconverter/FeatureToProvisioning.java b/src/main/java/org/apache/sling/feature/modelconverter/FeatureToProvisioning.java
index dca1a69..6cca47d 100644
--- a/src/main/java/org/apache/sling/feature/modelconverter/FeatureToProvisioning.java
+++ b/src/main/java/org/apache/sling/feature/modelconverter/FeatureToProvisioning.java
@@ -68,8 +68,8 @@ public class FeatureToProvisioning {
 
     public static void convert(File inputFile, File outputFile, FeatureProvider fp, File ... additionalInputFiles) throws UncheckedIOException {
         if (outputFile.exists()) {
-            if (outputFile.lastModified() > inputFile.lastModified()) {
-                LOGGER.debug("Skipping the generation of {} as this file already exists and is newer.", outputFile);
+            if (outputFile.lastModified() >= inputFile.lastModified()) {
+                LOGGER.debug("Skipping the generation of {} as this file already exists and is not older.", outputFile);
                 return;
             }
         }
diff --git a/src/main/java/org/apache/sling/feature/modelconverter/Main.java b/src/main/java/org/apache/sling/feature/modelconverter/Main.java
new file mode 100644
index 0000000..91158ad
--- /dev/null
+++ b/src/main/java/org/apache/sling/feature/modelconverter/Main.java
@@ -0,0 +1,129 @@
+/*
+ * 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.feature.modelconverter;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+@Command(
+    name = "pm2fm",
+    description = "Apache Sling Provisioning Model to Sling Feature Model converter",
+    footer = "Copyright(c) 2019 The Apache Software Foundation."
+)
+public class Main implements Runnable {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
+
+    @Option(names = { "-h", "--help" }, usageHelp = true, description = "Display the usage message.")
+    private boolean helpRequested;
+
+    @Option(names = { "-i", "--provisining-input-directory" }, description = "The input directory where the Provisioning File are.", required = true)
+    private File provisioningModelsInputDirectory;
+
+    @Option(names = { "-o", "--features-output-directory" }, description = "The output directory where the Feature File will be generated.", required = true)
+    private File featureModelsOutputDirectory;
+
+    @Option(names = { "-g", "--group-id" }, description = "Overwriting the Group Id of the Model ID")
+    private String groupId;
+
+    @Option(names = { "-v", "--version" }, description = "Overwriting the Version of the Model ID")
+    private String version;
+
+    @Option(names = { "-V", "--useProvidedVersion" }, description = "If flagged then the provided version will override any given version from Provisioning Model'")
+    private boolean useProvidedVersion;
+
+    @Option(names = { "-n", "--name" }, description = "Sets a general Name for all converted Models. This also means that the name is placed in the classifier")
+    private String name;
+
+    @Option(names = { "-d", "--dropVariables" }, description = "All matching Variables (by name) in a Feature Model are dropped")
+    private List<String> dropVariables;
+
+    @Option(names = { "-a", "--addFrameworkProperties" }, description = "Adds Framework Properties to Feature Models. Format: <Model Name>:<Property Name>=<value>")
+    private List<String> addFrameworkProperties;
+
+    @Option(names = { "-D", "--noProvisioningModelName" }, description = "If flagged then the Provisioning Model Name is not added'")
+    private boolean noProvisioningModelName;
+
+    private Pattern pattern = Pattern.compile("^(.*?):(.*?)=(.*?)$");
+
+    @Override
+    public void run() {
+        try {
+            if(!provisioningModelsInputDirectory.isDirectory()) { throw new IllegalArgumentException("Input Folder is not a directory"); }
+            if(!provisioningModelsInputDirectory.canRead()) { throw new IllegalArgumentException("Input Folder is not readable"); }
+            if(!featureModelsOutputDirectory.exists()) {
+                File parent = featureModelsOutputDirectory.getParentFile();
+                if(parent == null || !parent.exists()) { throw new IllegalArgumentException("Parent Folder (" + parent + ") of output folder (" + featureModelsOutputDirectory + ") does not exist"); }
+                featureModelsOutputDirectory.mkdir();
+            }
+            if(!featureModelsOutputDirectory.isDirectory()) { throw new IllegalArgumentException("Output Folder is not a directory"); }
+            if(!featureModelsOutputDirectory.canWrite()) { throw new IllegalArgumentException("Output Folder is not writable"); }
+            List<File> provisioningFiles = Arrays.asList(provisioningModelsInputDirectory.listFiles());
+            Map<String,Object> options = new HashMap<>();
+            if(groupId != null && !groupId.isEmpty()) { options.put("groupId", groupId); }
+            if(version != null && !version.isEmpty()) { options.put("version", version); }
+            // Todo: do we have a way to check the name?
+            if(name != null && !name.isEmpty()) { options.put("name", name); }
+            LOGGER.info("Use Provided Version Flag: '{}'", useProvidedVersion);
+            options.put("useProvidedVersion", useProvidedVersion);
+            options.put("noProvisioningModelName", noProvisioningModelName);
+            options.put("dropVariables", dropVariables);
+            Map<String,Map<String,String>> frameworkPropertiesMap = new HashMap<>();
+            for(String value: addFrameworkProperties) {
+                // Separate Model from Property Name Value pair. Create Sub Map if needed and then add
+                LOGGER.info("Check Add Framework Properties Line: '{}'", value);
+                Matcher matcher = pattern.matcher(value);
+                LOGGER.info("Pattern Group Matches: '{}', Count: '{}'", matcher.matches(), matcher.groupCount());
+                if(matcher.matches() && matcher.groupCount() == 3) {
+                    String modelName = matcher.group(1);
+                    String propName = matcher.group(2);
+                    String propValue = matcher.group(3);
+                    LOGGER.info("Model Name: '{}', Prop Name: '{}', Value: '{}'", modelName, propName, propValue);
+                    Map<String,String> modelMap = frameworkPropertiesMap.get(modelName);
+                    if(modelMap == null) {
+                        modelMap = new HashMap<>();
+                        frameworkPropertiesMap.put(modelName, modelMap);
+                    }
+                    modelMap.put(propName, propValue);
+                }
+            }
+            options.put("addFrameworkProperties", frameworkPropertiesMap);
+            for(File file: provisioningFiles) {
+                LOGGER.info("Handle File: '{}'", file.getAbsolutePath());
+                ProvisioningToFeature.convert(file, featureModelsOutputDirectory, options);
+            }
+        } catch(Throwable t) {
+            LOGGER.error("Failed to Convert", t);
+        }
+    }
+
+    public static void main(String[] args) {
+        CommandLine.run(new Main(), args);
+    }
+}
diff --git a/src/main/java/org/apache/sling/feature/modelconverter/ProvisioningToFeature.java b/src/main/java/org/apache/sling/feature/modelconverter/ProvisioningToFeature.java
index 961b22a..35b0750 100644
--- a/src/main/java/org/apache/sling/feature/modelconverter/ProvisioningToFeature.java
+++ b/src/main/java/org/apache/sling/feature/modelconverter/ProvisioningToFeature.java
@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -78,15 +79,22 @@ public class ProvisioningToFeature {
             id = id.replaceAll("[:]","");
             id = bareFileName + "_" + id;
 
+            boolean noProvisioningModelName = getOption(options, "noProvisioningModelName", false);
+            if(noProvisioningModelName) {
+                // Provisioning Model Names create a conflict is provided in multiple PM files so it is dropped by request
+                f.getVariables().remove(FeatureToProvisioning.PROVISIONING_MODEL_NAME_VARIABLE);
+            }
+
             File outFile = new File(outDir, id + ".json");
             files.add(outFile);
 
             if (outFile.exists()) {
-                if (outFile.lastModified() > file.lastModified()) {
-                    LOGGER.debug("Skipping the generation of {} as this file already exists and is newer.", outFile);
+                // On a very fast computer the generated file might have the same timestamp if the file was previously copied
+                if (outFile.lastModified() >= file.lastModified()) {
+                    LOGGER.debug("Skipping the generation of {} as this file already exists and is not older.", outFile);
                     continue;
                 } else {
-                    LOGGER.debug("Deleting existing file {} as source is newer", outFile);
+                    LOGGER.debug("Deleting existing file {} as source is newer, modified: out: '{}', source: '{}'", outFile, outFile.lastModified(), file.lastModified());
                     outFile.delete();
                 }
             }
@@ -293,20 +301,38 @@ public class ProvisioningToFeature {
 
     private static void buildFromFeature(final Feature feature,
             final Map<String,String> variables,
+            final List<String> dropVariables,
             final Bundles bundles,
             final Configurations configurations,
             final Extensions extensions,
             final Map<String,String> properties) {
         for (Iterator<Map.Entry<String, String>> it = feature.getVariables().iterator(); it.hasNext(); ) {
             Entry<String, String> entry = it.next();
-            variables.put(entry.getKey(), entry.getValue());
+            boolean found = false;
+            if(dropVariables != null) {
+                for (String variableName : dropVariables) {
+                    // Look if variable is in the list of Variables to be dropped
+                    if (entry.getKey().equals(variableName)) {
+                        found = true;
+                    }
+                }
+            }
+            if(!found) { variables.put(entry.getKey(), entry.getValue()); }
         }
 
         Extension cpExtension = extensions.getByName(Extension.EXTENSION_NAME_CONTENT_PACKAGES);
         for(final RunMode runMode : feature.getRunModes() ) {
             for(final ArtifactGroup group : runMode.getArtifactGroups()) {
                 for(final Artifact artifact : group) {
-                    final ArtifactId id = ArtifactId.fromMvnUrl(artifact.toMvnUrl());
+                    ArtifactId id = ArtifactId.fromMvnUrl(artifact.toMvnUrl());
+                    String version = id.getVersion();
+                    if(version.startsWith("${") && version.endsWith("}")) {
+                        // Replace Variable with value if found
+                        String versionFromVariable = variables.get(version.substring(2, version.length() - 1));
+                        if (versionFromVariable != null && !versionFromVariable.isEmpty()) {
+                            id = new ArtifactId(id.getGroupId(), id.getArtifactId(), versionFromVariable, id.getClassifier(), id.getType());
+                        }
+                    }
                     final org.apache.sling.feature.Artifact newArtifact = new org.apache.sling.feature.Artifact(id);
 
                     for(final Map.Entry<String, String> entry : artifact.getMetadata().entrySet()) {
@@ -389,9 +415,12 @@ public class ProvisioningToFeature {
             Extension repoExtension = extensions.getByName(Extension.EXTENSION_NAME_REPOINIT);
 
             if ( repoExtension == null ) {
-                repoExtension = new Extension(ExtensionType.JSON, Extension.EXTENSION_NAME_REPOINIT, true);
+                // TODO: As of now only TEXT is accepted for Repoinit -> verify and adjust 
+//                repoExtension = new Extension(ExtensionType.JSON, Extension.EXTENSION_NAME_REPOINIT, true);
+                repoExtension = new Extension(ExtensionType.TEXT, Extension.EXTENSION_NAME_REPOINIT, true);
                 extensions.add(repoExtension);
-                repoExtension.setJSON(textToJSON(repoinitText.toString()));
+//                repoExtension.setText(textToJSON(repoinitText.toString()));
+                repoExtension.setText(repoinitText.toString());
             } else {
                 throw new IllegalStateException("Repoinit sections already processed");
             }
@@ -425,29 +454,55 @@ public class ProvisioningToFeature {
 
         String groupId = getOption(options, "groupId", "generated");
         String version = getOption(options, "version", "1.0.0");
+        String nameOption = getOption(options, "name", "");
+        boolean useProvidedVersion = getOption(options, "useProvidedVersion", false);
+        List<String> dropVariables = getOption(options, "dropVariables", new ArrayList<>());
+        Map<String,Map<String,String>> addFrameworkProperties = getOption(options, "addFrameworkProperties", new HashMap<String,Map<String, String>>());
 
         for(final Feature feature : model.getFeatures() ) {
             final String idString;
             String name = feature.getName();
-            if ( name != null ) {
-                name = name.replaceAll("[:]", "");
+            if (name == null) { name = "feature"; }
+            name = name.replaceAll("[:]", "");
 
-                if (!name.equals(bareFileName)) {
-                    name = bareFileName + "_" + name;
-                }
+            if (!"feature".equals(name) && !name.equals(bareFileName)) {
+                name = bareFileName + "_" + name;
+            }
 
-                if ( feature.getVersion() != null ) {
-                    idString = groupId + "/" + name + "/" + feature.getVersion();
-                } else {
-                    idString = groupId + "/" + name + "/" + version;
-                }
-            } else {
-                idString = groupId + "/feature/" + version;
+            // Todo: shouldn't a provided Version overwrite the Feature Version ?
+            if ( feature.getVersion() != null && !useProvidedVersion ) {
+                version = feature.getVersion();
             }
+
+            // When providing a classifier a type must be provided and so we set it to 'slingfeature'
+            idString =
+                groupId + "/" +
+                (nameOption.isEmpty() ? name : nameOption) + "/" +
+                version +
+                (nameOption.isEmpty() ? "" :
+                    "/slingfeature/" + name );
             final org.apache.sling.feature.Feature f = new org.apache.sling.feature.Feature(ArtifactId.parse(idString));
             features.add(f);
 
-            buildFromFeature(feature, f.getVariables(), f.getBundles(), f.getConfigurations(), f.getExtensions(), f.getFrameworkProperties());
+            Map<String,String> variables = f.getVariables();
+            if(dropVariables != null) {
+                for (String variableName : dropVariables) {
+                    if (variables.containsKey(variableName)) {
+                        variables.remove(variableName);
+                    }
+                }
+            }
+            Map<String,String> frameworkProperties = f.getFrameworkProperties();
+            String simpleName = feature.getName().replaceAll("[:]", "");
+            if(addFrameworkProperties.containsKey(simpleName)) {
+                Map<String,String> modelFeatureProperties = addFrameworkProperties.get(simpleName);
+                if(modelFeatureProperties != null) {
+                    for(Entry<String,String> entry: modelFeatureProperties.entrySet()) {
+                        frameworkProperties.put(entry.getKey(), entry.getValue());
+                    }
+                }
+            }
+            buildFromFeature(feature, variables, dropVariables, f.getBundles(), f.getConfigurations(), f.getExtensions(), frameworkProperties);
 
             if (!f.getId().getArtifactId().equals(feature.getName())) {
                 f.getVariables().put(FeatureToProvisioning.PROVISIONING_MODEL_NAME_VARIABLE, feature.getName());
diff --git a/src/main/legal/LICENSE-with-deps b/src/main/legal/LICENSE-with-deps
new file mode 100644
index 0000000..75545a9
--- /dev/null
+++ b/src/main/legal/LICENSE-with-deps
@@ -0,0 +1,233 @@
+
+                                 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.
+
+<#function licenseFormat licenses>
+    <#assign result = ""/>
+    <#list licenses as license>
+        <#if result?length &gt; 0>
+            <#assign result = result + ", " />
+        </#if>
+        <#assign result = result + license />
+    </#list>
+    <#return result>
+</#function>
+
+<#function artifactFormat p>
+    <#if p.name?index_of('Unnamed') &gt; -1>
+        <#return p.groupId + ":" + p.artifactId + ":" + p.version + " (" + (p.url!"no url defined") + ")">
+    <#else>
+        <#return p.name + " v" + p.version + " (" + (p.url!"no url defined") + ")">
+    </#if>
+</#function>
+
+<#if dependencyMap?size == 0>
+The project has no dependencies.
+<#else>
+    <#list dependencyMap as e>
+        <#assign project = e.getKey()/>
+        <#assign licenses = e.getValue()/>
+For the ${artifactFormat(project)} component
+This is licensed under ${licenseFormat(licenses)}
+
+    </#list>
+</#if>
diff --git a/src/main/legal/NOTICE-with-deps b/src/main/legal/NOTICE-with-deps
new file mode 100644
index 0000000..e7f7780
--- /dev/null
+++ b/src/main/legal/NOTICE-with-deps
@@ -0,0 +1,5 @@
+Apache Sling Feature Analyser
+Copyright 2018 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/src/main/legal/license-header b/src/main/legal/license-header
new file mode 100644
index 0000000..d323a71
--- /dev/null
+++ b/src/main/legal/license-header
@@ -0,0 +1,14 @@
+  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. 
diff --git a/src/test/java/org/apache/sling/feature/modelconverter/ModelConverterTest.java b/src/test/java/org/apache/sling/feature/modelconverter/ModelConverterTest.java
index 498cb2e..81905b7 100644
--- a/src/test/java/org/apache/sling/feature/modelconverter/ModelConverterTest.java
+++ b/src/test/java/org/apache/sling/feature/modelconverter/ModelConverterTest.java
@@ -42,10 +42,14 @@ import org.apache.sling.provisioning.model.Section;
 import org.apache.sling.provisioning.model.io.ModelReader;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TestName;
 import org.mockito.Mockito;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.io.FileReader;
@@ -68,6 +72,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Random;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -76,18 +81,33 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 public class ModelConverterTest {
+
+    private static Logger LOGGER = LoggerFactory.getLogger(ModelConverterTest.class);
+
+    @Rule
+    public TestName name = new TestName();
+
     private Path tempDir;
     private ArtifactManager artifactManager;
     private FeatureProvider featureProvider;
 
+    // If there is a test output folder provided (test.prov.files.tempdir) then the tests can fail because of conflicts
+    // and it is hard to figure out what the test did. So we place them in their own folder
+    private static Random random = new Random(System.currentTimeMillis());
+
     @Before
     public void setup() throws Exception {
         String tmpDir = System.getProperty("test.prov.files.tempdir");
+        Path parent;
         if (tmpDir != null) {
-            tempDir = Paths.get(tmpDir);
-            System.out.println("*** Using directory for generated files: " + tempDir);
+            parent = Paths.get(tmpDir);
+            LOGGER.info("Using provided directory for generated files: '{}'", parent);
+            // Create sub folder with test method name in it to separate the test output from each other
+            File child = new File(parent.toFile(), "test-" + name.getMethodName() + "-" + random.nextInt(1000));
+            if(!child.mkdir()) { fail("Could not create sub folder: " + child.getPath()); }
+            tempDir = child.toPath();
         } else {
-            tempDir = Files.createTempDirectory(getClass().getSimpleName());
+            tempDir = Files.createTempDirectory(getClass().getSimpleName() + "-" + name.getMethodName());
         }
         artifactManager = ArtifactManager.getArtifactManager(
                 new ArtifactManagerConfig());
@@ -106,7 +126,10 @@ public class ModelConverterTest {
 
     @After
     public void tearDown() throws Exception {
-        if(System.getProperty("test.prov.files.tempdir") == null) {
+        boolean doDelete = System.getProperty("test.prov.files.tempdir") == null;
+        String noDelete = System.getProperty("test.prov.no.delete");
+        doDelete = doDelete && !"true".equalsIgnoreCase(noDelete);
+        if(doDelete) {
             // Delete the temp dir again
             Files.walk(tempDir)
                 .sorted(Comparator.reverseOrder())
@@ -248,6 +271,7 @@ public class ModelConverterTest {
         }
 
         for (File f : filesDir.listFiles((d, n) -> n.endsWith(".txt"))) {
+            LOGGER.info(name.getMethodName() + ", test file: '{}'", f);
             testConvertFromProvModelRoundTrip(f);
         }
     }
@@ -304,8 +328,10 @@ public class ModelConverterTest {
 
     @Test
     public void testConvertToFeature() throws Exception {
+        System.out.println("*** Convert to Feature: " + tempDir.toString());
         File inFile = new File(getClass().getResource("/boot.txt").toURI());
 
+        // If this test is run with others it might conflict with existing files -> create sub folder
         List<File> files = ProvisioningToFeature.convert(inFile, tempDir.toFile(), Collections.emptyMap());
         assertEquals("The testing code expects a single output file here", 1, files.size());
         File outFile = files.get(0);
@@ -316,10 +342,12 @@ public class ModelConverterTest {
         // Append to the output file:
         Files.write(outFile.toPath(), "\nmodified!".getBytes(), StandardOpenOption.APPEND);
 
+        System.out.println("*** Convert Again ***");
         // Convert again and see that the output file is not modified
         List<File> files2 = ProvisioningToFeature.convert(inFile, tempDir.toFile(), Collections.emptyMap());
         assertEquals("Should return the same file list", files, files2);
 
+        System.out.println("*** Check if not overwritten ***");
         List<String> lines = Files.readAllLines(outFile.toPath());
         assertEquals("modified!", lines.get(lines.size() - 1));
 
@@ -339,7 +367,7 @@ public class ModelConverterTest {
     }
 
     public void testConvertFromProvModelRoundTrip(File orgProvModel) throws Exception {
-        System.out.println("*** Roundtrip converting: " + orgProvModel.getName());
+        LOGGER.info("Roundtrip converting of file: '{}'", orgProvModel.getName());
         List<File> allGenerateProvisioningModelFiles = new ArrayList<>();
 
         List<File> generated = ProvisioningToFeature.convert(orgProvModel, tempDir.toFile(), Collections.emptyMap());
@@ -405,6 +433,8 @@ public class ModelConverterTest {
         List<File> generatedFiles1 = convertFeatureFilesToProvisioningModel(jsonFiles1);
         List<File> generatedFiles2 = convertFeatureFilesToProvisioningModel(jsonFiles2);
 
+        LOGGER.debug("Generated Files 1: '{}'", generatedFiles1);
+        LOGGER.debug("Generated Files 2: '{}'", generatedFiles2);
         Model actual1 = readProvisioningModel(generatedFiles1);
         Model actual2 = readProvisioningModel(generatedFiles2);
         assertModelsEqual(actual1, actual2);
@@ -540,17 +570,17 @@ public class ModelConverterTest {
         assertEquals(expected.getName(), actual.getName());
         assertEquals(expected.getVersion(), actual.getVersion());
         assertEquals(expected.getType(), actual.getType());
-        assertRunModesEqual(expected.getName(), expected.getRunModes(), actual.getRunModes());
+        assertRunModesEqual(expected.getName(), expected.getRunModes(), actual.getRunModes(), actual.getVariables());
         assertKVMapEquals(expected.getVariables(), actual.getVariables());
         assertSectionsEqual(expected.getAdditionalSections(), actual.getAdditionalSections());
     }
 
-    private void assertRunModesEqual(String featureName, List<RunMode> expected, List<RunMode> actual) {
+    private void assertRunModesEqual(String featureName, List<RunMode> expected, List<RunMode> actual, KeyValueMap<String> actualVariables) {
         assertEquals(expected.size(), actual.size());
         for (RunMode rm : expected) {
             boolean found = false;
             for (RunMode arm : actual) {
-                if (runModesEqual(featureName, rm, arm)) {
+                if (runModesEqual(featureName, rm, arm, actualVariables)) {
                     found = true;
                     break;
                 }
@@ -562,7 +592,7 @@ public class ModelConverterTest {
         }
     }
 
-    private boolean runModesEqual(String featureName, RunMode rm1, RunMode rm2) {
+    private boolean runModesEqual(String featureName, RunMode rm1, RunMode rm2, KeyValueMap<String> variables2) {
         if (rm1.getNames() == null) {
             if (rm2.getNames() != null)
                 return false;
@@ -572,20 +602,21 @@ public class ModelConverterTest {
 
             HashSet<String> names1 = new HashSet<>(Arrays.asList(rm1.getNames()));
             HashSet<String> names2 = new HashSet<>(Arrays.asList(rm2.getNames()));
-
+            LOGGER.debug("Check Run Modes Name: first: '{}', second: '{}'", names1, names2);
             if (!names1.equals(names2))
                 return false;
         }
 
         List<ArtifactGroup> ag1 = rm1.getArtifactGroups();
         List<ArtifactGroup> ag2 = rm2.getArtifactGroups();
+        LOGGER.debug("Check Artifact Group Size: first: '{}', second: '{}'", ag1.size(), ag2.size());
         if (ag1.size() != ag2.size())
             return false;
 
         for (ArtifactGroup g1 : ag1) {
             boolean found = false;
             for (ArtifactGroup g2 : ag2) {
-                if (artifactGroupsEquals(featureName, g1, g2)) {
+                if (artifactGroupsEquals(featureName, g1, g2, variables2)) {
                     found = true;
                     break;
                 }
@@ -598,6 +629,7 @@ public class ModelConverterTest {
         rm1.getConfigurations().iterator().forEachRemaining(configs1::add);
         List<Configuration> configs2 = new ArrayList<>();
         rm2.getConfigurations().iterator().forEachRemaining(configs2::add);
+        LOGGER.debug("Check Artifact Configuration Size: first: '{}', second: '{}'", configs1.size(), configs2.size());
         if (configs1.size() != configs2.size())
             return false;
 
@@ -636,6 +668,7 @@ public class ModelConverterTest {
         Map<String, String> m1 = kvToMap(rm1.getSettings());
         Map<String, String> m2 = kvToMap(rm2.getSettings());
 
+        LOGGER.debug("Check Artifact KV to Map: first: '{}', second: '{}'", m1, m2);
         return m1.equals(m2);
     }
 
@@ -649,9 +682,10 @@ public class ModelConverterTest {
         return m;
     }
 
-    private boolean artifactGroupsEquals(String featureName, ArtifactGroup g1, ArtifactGroup g2) {
+    private boolean artifactGroupsEquals(String featureName, ArtifactGroup g1, ArtifactGroup g2, KeyValueMap<String> variables2) {
         int sl1 = effectiveStartLevel(featureName, g1.getStartLevel());
         int sl2 = effectiveStartLevel(featureName, g2.getStartLevel());
+        LOGGER.debug("Check Artifact Group Start Level, feature name: '{}', first: '{}', second: '{}'", featureName, sl1, sl2);
         if (sl1 != sl2)
             return false;
 
@@ -663,12 +697,51 @@ public class ModelConverterTest {
 
         for (int i=0; i<al1.size(); i++) {
             Artifact a1 = al1.get(i);
+            String a1Version = a1.getVersion();
+            String resolvedVersion = a1Version;
+            Artifact a1Resolved = null;
+            if(a1Version.startsWith("${") && a1Version.endsWith("}")) {
+                String variableName = a1Version.substring(2, a1Version.length() - 1);
+                String variableValue = variables2.get(variableName);
+                LOGGER.debug("AG Variable Name: '{}', Variable Value: '{}'", variableName, variableValue);
+                if(variableName != null) {
+                    a1Resolved = new Artifact(a1.getGroupId(), a1.getArtifactId(), variableValue, a1.getClassifier(), a1.getType());
+                }
+            }
             boolean found = false;
             for (Iterator<Artifact> it = al2.iterator(); it.hasNext(); ) {
                 Artifact a2 = it.next();
+//                LOGGER.debug("Check Artifacts, first: '{}', second: '{}'", a1, a2);
+                String a2Version = a2.getVersion();
+                String resolvedVersion2 = a2Version;
+                Artifact a2Resolved = null;
+                if(a2Version.startsWith("${") && a2Version.endsWith("}")) {
+                    String variableName = a2Version.substring(2, a2Version.length() - 1);
+                    String variableValue = variables2.get(variableName);
+                    LOGGER.debug("AG 2 Variable Name: '{}', Variable Value: '{}'", variableName, variableValue);
+                    if(variableName != null) {
+                        a2Resolved = new Artifact(a2.getGroupId(), a2.getArtifactId(), variableValue, a2.getClassifier(), a2.getType());
+                    }
+                }
+                LOGGER.debug("Check Artifacts\nfirst  MVN URL: '{}'\nsecond MVN URL: '{}'", a1.toMvnUrl(), a2.toMvnUrl());
                 if (a1.compareTo(a2) == 0) {
                     found = true;
                     it.remove();
+                } else {
+                    // If we have a resolved AG 1 then compare this one as well
+                    if (a1Resolved != null) {
+                        if (a1Resolved.compareTo(a2) == 0) {
+                            LOGGER.debug("Resolved AG matches: '{}' -> remove", a1Resolved);
+                            found = true;
+                            it.remove();
+                        }
+                    } else if (a2Resolved != null) {
+                        if (a1.compareTo(a2Resolved) == 0) {
+                            LOGGER.debug("Resolved AG 2 matches: '{}' -> remove", a2Resolved);
+                            found = true;
+                            it.remove();
+                        }
+                    }
                 }
             }
             if (!found) {
@@ -677,6 +750,7 @@ public class ModelConverterTest {
         }
 
         // Should have found all artifacts
+        LOGGER.debug("Not found AGs: '{}'", al2);
         return (al2.size() == 0);
     }
 
@@ -708,8 +782,15 @@ public class ModelConverterTest {
             assertEquals(ex.isRequired(), ac.isRequired());
 
             if (ex.getType() == ExtensionType.TEXT) {
-                String exTxt = ex.getText().replaceAll("\\s+", "");
-                String acTxt = ac.getText().replaceAll("\\s+", "");
+                String exTxt;
+                String acTxt;
+                if("repoinit".equals(ex.getName())) {
+                    exTxt = ex.getText().replaceAll("\\s+", "").replaceAll("\"\",", "");
+                    acTxt = ac.getText().replaceAll("\\s+", "").replaceAll("\"\",", "");
+                } else {
+                    exTxt = ex.getText().replaceAll("\\s+", "");
+                    acTxt = ac.getText().replaceAll("\\s+", "");
+                }
                 assertEquals(exTxt, acTxt);
             } else if (ex.getType() == ExtensionType.JSON) {
                 String exJson = ex.getJSON().replaceAll("\\s+", "").replaceAll("\"\",", "");
diff --git a/src/test/resources/boot.json b/src/test/resources/boot.json
index 313fec9..6111623 100644
--- a/src/test/resources/boot.json
+++ b/src/test/resources/boot.json
@@ -11,7 +11,7 @@
     },
     "bundles": [
         {
-            "id": "org.slf4j/slf4j-api/${slf4j.version}",
+            "id": "org.slf4j/slf4j-api/1.7.25",
             "start-level": 1
         },
         {
@@ -23,11 +23,11 @@
             "start-level": 1
         },
         {
-            "id": "org.slf4j/jcl-over-slf4j/${slf4j.version}",
+            "id": "org.slf4j/jcl-over-slf4j/1.7.25",
             "start-level": 1
         },
         {
-            "id": "org.slf4j/log4j-over-slf4j/${slf4j.version}",
+            "id": "org.slf4j/log4j-over-slf4j/1.7.25",
             "start-level": 1
         },
         {
diff --git a/src/test/resources/boot_gav.json b/src/test/resources/boot_gav.json
index 1d997f8..a399637 100644
--- a/src/test/resources/boot_gav.json
+++ b/src/test/resources/boot_gav.json
@@ -11,7 +11,7 @@
     },
     "bundles": [
         {
-            "id": "org.slf4j/slf4j-api/${slf4j.version}",
+            "id": "org.slf4j/slf4j-api/1.7.25",
             "start-level": 1
         },
         {
@@ -23,11 +23,11 @@
             "start-level": 1
         },
         {
-            "id": "org.slf4j/jcl-over-slf4j/${slf4j.version}",
+            "id": "org.slf4j/jcl-over-slf4j/1.7.25",
             "start-level": 1
         },
         {
-            "id": "org.slf4j/log4j-over-slf4j/${slf4j.version}",
+            "id": "org.slf4j/log4j-over-slf4j/1.7.25",
             "start-level": 1
         },
         {
diff --git a/src/test/resources/more/repoinit-multiple.json b/src/test/resources/more/repoinit-multiple.json
index 9a97bc4..a2e8dc6 100644
--- a/src/test/resources/more/repoinit-multiple.json
+++ b/src/test/resources/more/repoinit-multiple.json
@@ -2,7 +2,7 @@
     "#": "this is a comment",
 
     "id": "generated/repoinit-multiple/1.0.0",
-    "repoinit:JSON|true": [
+    "repoinit:TEXT|true": [
         "create service user one",
         "create service user two",
         "create service user three"
diff --git a/src/test/resources/oak.json b/src/test/resources/oak.json
index f054113..c5aad76 100644
--- a/src/test/resources/oak.json
+++ b/src/test/resources/oak.json
@@ -11,27 +11,27 @@
             "start-level": 10
         },
         {
-            "id": "org.apache.jackrabbit/oak-core/${oak.version}",
+            "id": "org.apache.jackrabbit/oak-core/1.6.8",
             "start-level": 15
         },
         {
-            "id": "org.apache.jackrabbit/oak-commons/${oak.version}",
+            "id": "org.apache.jackrabbit/oak-commons/1.6.8",
             "start-level": 15
         },
         {
-            "id": "org.apache.jackrabbit/oak-lucene/${oak.version}",
+            "id": "org.apache.jackrabbit/oak-lucene/1.6.8",
             "start-level": 15
         },
         {
-            "id": "org.apache.jackrabbit/oak-blob/${oak.version}",
+            "id": "org.apache.jackrabbit/oak-blob/1.6.8",
             "start-level": 15
         },
         {
-            "id": "org.apache.jackrabbit/oak-jcr/${oak.version}",
+            "id": "org.apache.jackrabbit/oak-jcr/1.6.8",
             "start-level": 15
         },
         {
-            "id": "org.apache.jackrabbit/oak-segment-tar/${oak.version}",
+            "id": "org.apache.jackrabbit/oak-segment-tar/1.6.8",
             "start-level": 15,
             "run-modes": "oak_tar"
         },
diff --git a/src/test/resources/repoinit.json b/src/test/resources/repoinit.json
index 779de77..24e6ae4 100644
--- a/src/test/resources/repoinit.json
+++ b/src/test/resources/repoinit.json
@@ -21,7 +21,7 @@
             "references":"model@repoinit:context:/resources/provisioning/model.txt"
         }
     },
-    "repoinit:JSON|true": [
+    "repoinit:TEXT|true": [
         "# general",
         "create path (sling:OrderedFolder) /content",
         "set ACL for everyone",
diff --git a/src/test/resources/simplelogger.properties b/src/test/resources/simplelogger.properties
new file mode 100644
index 0000000..4e352bd
--- /dev/null
+++ b/src/test/resources/simplelogger.properties
@@ -0,0 +1,5 @@
+# Adjust the Simple SLF4J Logger if needed
+
+#org.slf4j.simpleLogger.defaultLogLevel=debug
+
+org.slf4j.simpleLogger.defaultLogLevel=info
\ No newline at end of file