You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by da...@apache.org on 2018/11/13 14:43:48 UTC

[sling-org-apache-sling-feature-modelconverter] branch master updated: SLING-8103 Model Converter should not embed all its dependencies

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

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


The following commit(s) were added to refs/heads/master by this push:
     new e7b9c50  SLING-8103 Model Converter should not embed all its dependencies
e7b9c50 is described below

commit e7b9c50ecc1b8d9d9df68239fe231a0712790ef2
Author: David Bosschaert <bo...@adobe.com>
AuthorDate: Tue Nov 13 14:42:56 2018 +0000

    SLING-8103 Model Converter should not embed all its dependencies
---
 pom.xml                                            |  31 ----
 .../sling/feature/modelconverter/impl/Main.java    | 201 ---------------------
 2 files changed, 232 deletions(-)

diff --git a/pom.xml b/pom.xml
index ea6d789..9ecc7e4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,37 +43,6 @@
     <build>
         <plugins>
             <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-dependency-plugin</artifactId>
-                <executions>
-                <execution>
-                    <id>unpack-dependencies</id>
-                    <phase>prepare-package</phase>
-                    <goals>
-                        <goal>unpack-dependencies</goal>
-                    </goals>
-                    <configuration>
-                        <excludes>META-INF/**</excludes>
-                        <outputDirectory>${project.build.directory}/classes</outputDirectory>
-                        <overWriteReleases>false</overWriteReleases>
-                        <overWriteSnapshots>true</overWriteSnapshots>
-                        <includeArtifactIds>commons-cli,org.apache.sling.feature,org.apache.sling.feature.io,org.apache.sling.commons.johnzon,org.apache.sling.provisioning.model,slf4j-api,slf4j-simple,osgi.core</includeArtifactIds>
-                    </configuration>
-                </execution>
-            </executions>
-            </plugin>
-                <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
-                <configuration>
-                    <archive>
-                        <manifest>
-                            <mainClass>org.apache.sling.feature.modelconverter.impl.Main</mainClass>
-                        </manifest>
-                    </archive>
-                </configuration>
-            </plugin>
-            <plugin>
                 <groupId>org.apache.rat</groupId>
                 <artifactId>apache-rat-plugin</artifactId>
                 <configuration>
diff --git a/src/main/java/org/apache/sling/feature/modelconverter/impl/Main.java b/src/main/java/org/apache/sling/feature/modelconverter/impl/Main.java
deleted file mode 100644
index 69651db..0000000
--- a/src/main/java/org/apache/sling/feature/modelconverter/impl/Main.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * 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.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.DefaultParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.sling.feature.io.file.ArtifactManager;
-import org.apache.sling.feature.io.file.ArtifactManagerConfig;
-import org.apache.sling.feature.modelconverter.ProvisioningToFeature;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class Main {
-
-    private static Logger LOGGER;
-
-    private static String runModes;
-
-    private static String output;
-
-    private static String input;
-
-    private static boolean createApp = false;
-
-    private static boolean includeModelInfo = false;
-
-    private static String repoUrls;
-
-    private static String propsFile;
-
-    /**
-     * Parse the command line parameters and update a configuration object.
-     * @param args Command line parameters
-     * @return Configuration object.
-     */
-    private static void parseArgs(final String[] args) {
-        final Option repoOption =  Option.builder("u").hasArg().argName("Set repository url")
-                .desc("repository url").build();
-
-        final Option modelOption =  new Option("f", true, "Set feature files/directories");
-        final Option propsOption =  new Option("p", true, "sling.properties file");
-        final Option runModeOption =  new Option("r", true, "Set run modes (comma separated)");
-        final Option createAppOption = new Option("a", false, "If enabled, create application json");
-        createAppOption.setArgs(0);
-        final Option includeModelOption = new Option("i", false, "Include model filename as metadata for artifacts");
-        includeModelOption.setArgs(0);
-
-        final Option outputOption = Option.builder("o").hasArg().argName("Set output file")
-                .desc("output file").build();
-
-        final Options options = new Options();
-        options.addOption(repoOption);
-        options.addOption(modelOption);
-        options.addOption(createAppOption);
-        options.addOption(outputOption);
-        options.addOption(includeModelOption);
-        options.addOption(propsOption);
-        options.addOption(runModeOption);
-
-        final CommandLineParser parser = new DefaultParser();
-        try {
-            final CommandLine cl = parser.parse(options, args);
-
-            if ( cl.hasOption(repoOption.getOpt()) ) {
-                repoUrls = cl.getOptionValue(repoOption.getOpt());
-            }
-            if ( cl.hasOption(modelOption.getOpt()) ) {
-                input = cl.getOptionValue(modelOption.getOpt());
-            }
-            if ( cl.hasOption(createAppOption.getOpt()) ) {
-                createApp = true;
-            }
-            if ( cl.hasOption(includeModelOption.getOpt()) ) {
-                includeModelInfo = true;
-            }
-            if ( cl.hasOption(runModeOption.getOpt()) ) {
-                runModes = cl.getOptionValue(runModeOption.getOpt());
-            }
-            if ( cl.hasOption(outputOption.getOpt()) ) {
-                output = cl.getOptionValue(outputOption.getOpt());
-            }
-            if ( cl.hasOption(propsOption.getOpt()) ) {
-                propsFile = cl.getOptionValue(propsOption.getOpt());
-            }
-        } catch ( final ParseException pe) {
-            LOGGER.error("Unable to parse command line: {}", pe.getMessage(), pe);
-            help(options);
-            System.exit(1);
-        }
-        if ( input == null ) {
-            LOGGER.error("Required argument missing: model file or directory");
-            help(options);
-            System.exit(1);
-        }
-    }
-
-    private static void help(Options options) {
-        final HelpFormatter formatter = new HelpFormatter();
-        formatter.printHelp("launcher", options);
-    }
-
-    private static ArtifactManager getArtifactManager() {
-        final ArtifactManagerConfig amConfig = new ArtifactManagerConfig();
-        if ( repoUrls != null ) {
-            amConfig.setRepositoryUrls(repoUrls.split(","));
-        }
-        try {
-            return ArtifactManager.getArtifactManager(amConfig);
-        } catch ( IOException ioe) {
-            LOGGER.error("Unable to create artifact manager " + ioe.getMessage(), ioe);
-            System.exit(1);
-        }
-        // we never reach this, but have to keep the compiler happy
-        return null;
-    }
-
-    public static void main(final String[] args) {
-        // setup logging
-        System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "info");
-        System.setProperty("org.slf4j.simpleLogger.showThreadName", "false");
-        System.setProperty("org.slf4j.simpleLogger.levelInBrackets", "true");
-        System.setProperty("org.slf4j.simpleLogger.showLogName", "false");
-
-        LOGGER = LoggerFactory.getLogger("modelconverter");
-
-        LOGGER.info("Apache Sling Provisiong Model to Feature Application Converter");
-        LOGGER.info("");
-
-        parseArgs(args);
-
-        final File f = new File(input);
-        final List<File> files = new ArrayList<>();
-        if ( f.isDirectory() ) {
-            for(final File file : f.listFiles()) {
-                if ( file.isFile() && !file.getName().startsWith(".") ) {
-                    files.add(file);
-                }
-            }
-            if ( files.isEmpty() ) {
-                LOGGER.error("No files found in {}", f);
-                System.exit(1);
-            }
-            Collections.sort(files);
-        } else {
-            files.add(f);
-        }
-        boolean isJson = false;
-        boolean isTxt = false;
-        for(final File t : files) {
-            if ( t.getName().endsWith(".json") ) {
-                if ( isTxt ) {
-                    LOGGER.error("Input files are a mixture of JSON and txt");
-                    System.exit(1);
-                }
-                isJson = true;
-            } else {
-                if ( isJson ) {
-                    LOGGER.error("Input files are a mixture of JSON and txt");
-                    System.exit(1);
-                }
-                isTxt = true;
-            }
-        }
-
-        if ( isTxt ) {
-            if ( output == null ) {
-                output = createApp ? "application.json" : "feature.json";
-            }
-            ProvisioningToFeature.convert(files, output, runModes, createApp, includeModelInfo, propsFile);
-        } else {
-            LOGGER.error("Conversion to provisioning model not supported");
-            System.exit(1);
-        }
-    }
-
-}