Repository: flex-utilities Updated Branches: refs/heads/develop 4933ddf85 -> 691016f58
- Removed the old, empty "mavenizer" module - Renamed the "core" module to "cli" - Extended the DownloadRetriever with functionality to list all available versions - Extended the CLI to output a list of available versions (and platforms) Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/691016f5 Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/691016f5 Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/691016f5 Branch: refs/heads/develop Commit: 691016f58343e5da290b21a9a8a6fcfd86f6dfca Parents: 4933ddf Author: Christofer Dutz <[email protected]> Authored: Wed Apr 8 14:51:46 2015 +0200 Committer: Christofer Dutz <[email protected]> Committed: Wed Apr 8 14:51:46 2015 +0200 ---------------------------------------------------------------------- .../converter/core/SdkConverterCLI.java | 316 +++++++++++++++++++ mavenizer/core/pom.xml | 96 ------ .../converter/core/SdkConverterCLI.java | 244 -------------- mavenizer/mavenizer/pom.xml | 118 ------- mavenizer/pom.xml | 6 +- mavenizer/retrievers/download/pom.xml | 5 + .../retrievers/download/DownloadRetriever.java | 147 ++++----- 7 files changed, 392 insertions(+), 540 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/691016f5/mavenizer/cli/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java ---------------------------------------------------------------------- diff --git a/mavenizer/cli/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java b/mavenizer/cli/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java new file mode 100644 index 0000000..e72d4f0 --- /dev/null +++ b/mavenizer/cli/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java @@ -0,0 +1,316 @@ +package org.apache.flex.utilities.converter.core; + +import org.apache.commons.cli.*; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.SystemUtils; +import org.apache.flex.utilities.converter.air.AirConverter; +import org.apache.flex.utilities.converter.deployer.aether.AetherDeployer; +import org.apache.flex.utilities.converter.flash.FlashConverter; +import org.apache.flex.utilities.converter.flex.FlexConverter; +import org.apache.flex.utilities.converter.fontkit.FontkitConverter; +import org.apache.flex.utilities.converter.retrievers.download.DownloadRetriever; +import org.apache.flex.utilities.converter.retrievers.types.PlatformType; +import org.apache.flex.utilities.converter.retrievers.types.SdkType; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; + +import java.io.File; +import java.io.IOException; +import java.util.*; + +/** + * Created by christoferdutz on 07.04.15. + */ +public class SdkConverterCLI { + + public static void main(String[] args) throws Exception { + Options options = new Options(); + options.addOption(OptionBuilder.withDescription("List the versions currently available for download."). + create("list")); + options.addOption(OptionBuilder. + withDescription("Tells the Converter to download and extract (parts of) an FDK."). + create("download")); + options.addOption(OptionBuilder. + withDescription("Tells the Converter to convert an FDK into a mavenized artifacts."). + create("convert")); + options.addOption(OptionBuilder. + withDescription("Tells the Converter to deploy mavenized artfifacts to a remote repository."). + create("deploy")); + + options.addOption(OptionBuilder.withArgName("version").hasArg(). + withDescription("(Optional and Only valid for download) Version of the " + + "FDK which should be downloaded."). + isRequired(false). + create("flexVersion")); + options.addOption(OptionBuilder.withArgName("version(s)").hasArg(). + withValueSeparator(','). + withDescription("(Optional and Only valid for download) Version(s) of the " + + "Adobe Flash SDK which should be downloaded. Multiple versions can " + + "be separated by \",\"."). + isRequired(false). + create("flashVersion")); + options.addOption(OptionBuilder.withArgName("version").hasArg(). + withDescription("(Optional and Only valid for download) Version of the " + + "Adobe Air SDK which should be downloaded."). + isRequired(false). + create("airVersion")); + options.addOption(OptionBuilder. + withDescription("(Optional and Only valid for download) If provided, the " + + "Converter will also download the Fontkit libraries needed for font " + + "encoding."). + isRequired(false). + create("fontkit")); + options.addOption(OptionBuilder.withArgName("platform(s)").hasArg(). + withValueSeparator(','). + withDescription("(Optional and Only valid for download) Platform the artifacts " + + "should be downloaded for. If omitted the platform this process is run " + + "on will be used. Valid options are: \"WINDOWS\", \"MAC\" and \"LNX\". " + + "Multiple versions can be separated by \",\"."). + isRequired(false). + create("platform")); + options.addOption(OptionBuilder.withArgName("dir").hasArg(). + withDescription("(Optional) Directory that the mavenized artifacts will be located in. " + + "If omitted, a temporary directory will be used."). + isRequired(false). + create("mavenDir")); + options.addOption(OptionBuilder.withArgName("dir").hasArg(). + withDescription("(Optional) Directory that the FDK will be located in. " + + "If omitted, a temporary directory will be used."). + isRequired(false). + create("fdkDir")); + options.addOption(OptionBuilder.withArgName("url").hasArg(). + withDescription("(Optional and only valid for deploy) Url of the remote Maven " + + "repository that the generated Maven artifacts should be deployed to."). + isRequired(false). + create("repoUrl")); + options.addOption(OptionBuilder.withArgName("username").hasArg(). + withDescription("(Optional and only valid for deploy) Username used to authenticate " + + "on the remote Maven repository that the generated Maven artifacts should be " + + "deployed to."). + isRequired(false). + create("repoUsername")); + options.addOption(OptionBuilder.withArgName("password").hasArg(). + withDescription("(Optional and only valid for deploy) Password used to authenticate " + + "on the remote Maven repository that the generated Maven artifacts should be " + + "deployed to."). + isRequired(false). + create("repoPassword")); + + CommandLineParser parser = new BasicParser(); + try { + CommandLine cmd = parser.parse(options, args); + if(cmd.getArgList().isEmpty() || cmd.getArgList().contains("help")) { + printHelp(options); + } + + // Find out the desired platform(s). + List<PlatformType> platforms = new ArrayList<PlatformType>(); + String platformParam = cmd.getOptionValue("platform"); + if((platformParam != null) && !platformParam.isEmpty()) { + String[] platformNames = platformParam.split(","); + for(String platformName : platformNames) { + platforms.add(PlatformType.valueOf(platformName)); + } + } + if(platforms.isEmpty()) { + if(SystemUtils.IS_OS_WINDOWS) { + platforms.add(PlatformType.WINDOWS); + } else if(SystemUtils.IS_OS_MAC) { + platforms.add(PlatformType.MAC); + } else if(SystemUtils.IS_OS_LINUX) { + platforms.add(PlatformType.LINUX); + } else { + System.err.println("Unsupported OS type. Provide manually using 'platform' parameter."); + System.exit(1); + } + } + + // Find out where to download or convert from. + File fdkDir = cmd.hasOption("fdkDir") ? + new File(cmd.getOptionValue("fdkDir")) : getTempDir("FLEX-DOWNLOAD"); + + // Find out where to convert to or deploy from. + File mavenDir = cmd.hasOption("mavenDir") ? + new File(cmd.getOptionValue("mavenDir")) : getTempDir("FLEX-MAVEN"); + + //////////////////////////////////////////////////////////////////////////// + // Exectute operations + //////////////////////////////////////////////////////////////////////////// + + // Output a list of all available downloads. + if(cmd.getArgList().contains("list")) { + System.out.println("-----------------------------------------------"); + System.out.println("- Available downloads"); + System.out.println("-----------------------------------------------"); + + DownloadRetriever retriever = new DownloadRetriever(); + System.out.println("Apache Flex:"); + List<DefaultArtifactVersion> versions = new ArrayList<DefaultArtifactVersion>( + retriever.getAvailableVersions(SdkType.FLEX).keySet()); + Collections.sort(versions); + for(DefaultArtifactVersion version : versions) { + System.out.println(" - " + version.toString()); + } + System.out.println(); + + System.out.println("Adobe Flash:"); + versions = new ArrayList<DefaultArtifactVersion>( + retriever.getAvailableVersions(SdkType.FLASH).keySet()); + Collections.sort(versions); + for(DefaultArtifactVersion version : versions) { + System.out.println(" - " + version.toString()); + } + System.out.println(); + + System.out.println("Adobe AIR:"); + Map<DefaultArtifactVersion, Collection<PlatformType>> versionData = + retriever.getAvailableVersions(SdkType.AIR); + versions = new ArrayList<DefaultArtifactVersion>(versionData.keySet()); + Collections.sort(versions); + for(DefaultArtifactVersion version : versions) { + StringBuilder sb = new StringBuilder(); + sb.append(" - ").append(version.toString()).append(" ("); + boolean firstOption = true; + for(PlatformType platformType : versionData.get(version)) { + if(!firstOption) { + sb.append(", "); + } + sb.append(platformType.name()); + firstOption = false; + } + sb.append(")"); + System.out.println(sb.toString()); + } + } + + // Handle the downloading of atifacts. + if(cmd.getArgList().contains("download")) { + System.out.println("-----------------------------------------------"); + System.out.println("- Downloading"); + System.out.println("-----------------------------------------------"); + + DownloadRetriever retriever = new DownloadRetriever(); + + String flexVersion = cmd.getOptionValue("flexVersion", null); + if(flexVersion != null) { + System.out.println("- Downloading Flex SDK version: " + flexVersion + + " to directory: " + fdkDir.getAbsolutePath()); + File fdkDownloadDirectory = retriever.retrieve(SdkType.FLEX, flexVersion); + // Unpack the archive to the FDK directory. + mergeDirectories(fdkDownloadDirectory, fdkDir); + } + + String flashVersions = cmd.getOptionValue("flashVersion", ""); + if(!flashVersions.isEmpty()) { + for(String flashVersion : flashVersions.split(",")) { + System.out.println("- Downloading Flash SDK version: " + flashVersion + + " to directory: " + fdkDir.getAbsolutePath()); + File flashDownloadDiretory = retriever.retrieve(SdkType.FLASH, flashVersion); + // Integrate the download into the FDK directory. + mergeDirectories(flashDownloadDiretory, fdkDir); + } + } + + String airVersions = cmd.getOptionValue("airVersion", ""); + if(!airVersions.isEmpty()) { + for(String airVersion : airVersions.split(",")) { + for(PlatformType platformType : platforms) { + System.out.println("- Downloading Air SDK version: " + airVersion + + " and platform " + platformType.name() + + " to directory: " + fdkDir.getAbsolutePath()); + File airDownloadDirectory = retriever.retrieve(SdkType.AIR, airVersion, platformType); + // Integrate the download into the FDK directory. + mergeDirectories(airDownloadDirectory, fdkDir); + } + } + } + + if(cmd.hasOption("fontkit")) { + System.out.println("- Downloading Flex Fontkit libraries" + + " to directory: " + fdkDir.getAbsolutePath()); + File fontkitDownloadDirectory = retriever.retrieve(SdkType.FONTKIT); + // Integrate the download into the FDK directory. + mergeDirectories(fontkitDownloadDirectory, fdkDir); + } + + System.out.println("Finished downloads."); + } + + // Handle the conversion. + if(cmd.getArgList().contains("convert")) { + System.out.println("-----------------------------------------------"); + System.out.println("- Conversion"); + System.out.println("-----------------------------------------------"); + + System.out.println("- Converting Flex SDK from " + fdkDir.getAbsolutePath() + + " to " + mavenDir.getAbsolutePath()); + FlexConverter flexConverter = new FlexConverter(fdkDir, mavenDir); + flexConverter.convert(); + + System.out.println("- Converting Flash SDKs from " + fdkDir.getAbsolutePath() + + " to " + mavenDir.getAbsolutePath()); + FlashConverter flashConverter = new FlashConverter(fdkDir, mavenDir); + flashConverter.convert(); + + System.out.println("- Converting Air SDKs from " + fdkDir.getAbsolutePath() + + " to " + mavenDir.getAbsolutePath()); + AirConverter airConverter = new AirConverter(fdkDir, mavenDir); + airConverter.convert(); + + System.out.println("- Converting Fontkit libraries from " + fdkDir.getAbsolutePath() + + " to " + mavenDir.getAbsolutePath()); + FontkitConverter fontkitConverter = new FontkitConverter(fdkDir, mavenDir); + fontkitConverter.convert(); + + System.out.println("Finished conversion."); + } + + // Handle the deployment. + if(cmd.getArgList().contains("deploy")) { + System.out.println("-----------------------------------------------"); + System.out.println("- Deployment"); + System.out.println("-----------------------------------------------"); + + if(!cmd.hasOption("repoUrl")) { + System.err.println("Parameter 'repoUrl' required for task 'deploy'."); + System.exit(1); + } + + String repoUrl = cmd.getOptionValue("repoUrl"); + String repoUsername = cmd.getOptionValue("repoUsername", null); + String repoPassword = cmd.getOptionValue("repoPassword", null); + + System.out.println("- Deploying libraries to " + repoUrl + " from " + mavenDir.getAbsolutePath()); + + AetherDeployer deployer = new AetherDeployer(mavenDir, repoUrl, repoUsername, repoPassword); + deployer.deploy(); + + System.out.println("Finished deploying."); + } + System.out.println("-----------------------------------------------"); + } catch (ParseException e) { + System.err.println("Parsing failed. Reason: " + e.getMessage()); + printHelp(options); + } + } + + protected static void printHelp(Options options) { + HelpFormatter helpFormatter = new HelpFormatter(); + helpFormatter.printHelp("[download] [convert] [deploy]", options); + } + + protected static File getTempDir(String prefix) throws IOException { + File tempFile = File.createTempFile(prefix, ".TMP"); + tempFile.delete(); + File tempDir = new File(tempFile.getParentFile(), + tempFile.getName().substring(0, tempFile.getName().length() - 4)); + if(!tempDir.exists()) { + tempDir.mkdirs(); + } + return tempDir; + } + + protected static void mergeDirectories(File sourceDir, File targetDir) throws IOException { + FileUtils.copyDirectory(sourceDir, targetDir); + } + +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/691016f5/mavenizer/core/pom.xml ---------------------------------------------------------------------- diff --git a/mavenizer/core/pom.xml b/mavenizer/core/pom.xml deleted file mode 100644 index d0eae20..0000000 --- a/mavenizer/core/pom.xml +++ /dev/null @@ -1,96 +0,0 @@ -<?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"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>flex-sdk-converter</artifactId> - <version>1.1.0-SNAPSHOT</version> - </parent> - - <artifactId>core</artifactId> - <version>1.1.0-SNAPSHOT</version> - <packaging>jar</packaging> - - <build> - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <version>2.4</version> - <configuration> - <archive> - <manifest> - <addDefaultImplementationEntries>true</addDefaultImplementationEntries> - <addClasspath>true</addClasspath> - <mainClass>org.apache.flex.utilities.converter.core.SdkConverterCLI</mainClass> - </manifest> - <manifestEntries> - <Implementation-Build>${project.version}</Implementation-Build> - </manifestEntries> - </archive> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - <finalName>flex-sdk-converter-${project.version}</finalName> - <appendAssemblyId>false</appendAssemblyId> - </configuration> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>download-retriever</artifactId> - <version>1.1.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>flex-converter</artifactId> - <version>1.1.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>aether-deployer</artifactId> - <version>1.1.0-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>commons-cli</groupId> - <artifactId>commons-cli</artifactId> - <version>1.2</version> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - <version>3.3.2</version> - </dependency> - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/691016f5/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java ---------------------------------------------------------------------- diff --git a/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java b/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java deleted file mode 100644 index f5263c0..0000000 --- a/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java +++ /dev/null @@ -1,244 +0,0 @@ -package org.apache.flex.utilities.converter.core; - -import org.apache.commons.cli.*; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.SystemUtils; -import org.apache.flex.utilities.converter.air.AirConverter; -import org.apache.flex.utilities.converter.deployer.aether.AetherDeployer; -import org.apache.flex.utilities.converter.flash.FlashConverter; -import org.apache.flex.utilities.converter.flex.FlexConverter; -import org.apache.flex.utilities.converter.fontkit.FontkitConverter; -import org.apache.flex.utilities.converter.retrievers.download.DownloadRetriever; -import org.apache.flex.utilities.converter.retrievers.types.PlatformType; -import org.apache.flex.utilities.converter.retrievers.types.SdkType; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by christoferdutz on 07.04.15. - */ -public class SdkConverterCLI { - - public static void main(String[] args) throws Exception { - Options options = new Options(); - options.addOption(OptionBuilder.withDescription("Tells the Converter to download and extract (parts of) an FDK.").create("download")); - options.addOption(OptionBuilder.withDescription("Tells the Converter to convert an FDK into a mavenized artifacts.").create("convert")); - options.addOption(OptionBuilder.withDescription("Tells the Converter to deploy mavenized artfifacts to a remote repository.").create("deploy")); - - options.addOption(OptionBuilder.withArgName("version").hasArg(). - withValueSeparator(','). - withDescription("(Optional and Only valid for download) Version of the FDK which should be downloaded."). - isRequired(false). - create("flexVersion")); - options.addOption(OptionBuilder.withArgName("version(s)").hasArg(). - withValueSeparator(','). - withDescription("(Optional and Only valid for download) Version(s) of the Adobe Flash SDK which should be downloaded. Multiple versions can be separated by \",\"."). - isRequired(false). - create("flashVersion")); - options.addOption(OptionBuilder.withArgName("version(s)").hasArg(). - withValueSeparator(','). - withDescription("(Optional and Only valid for download) Version(s) of the Adobe Air SDK which should be downloaded. Multiple versions can be separated by \",\"."). - isRequired(false). - create("airVersion")); - options.addOption(OptionBuilder.withDescription("(Optional and Only valid for download) If provided, the Converter will also download the Fontkit libraries needed for font encoding."). - isRequired(false). - create("fontkit")); - options.addOption(OptionBuilder.withArgName("platform(s)").hasArg(). - withValueSeparator(','). - withDescription("(Optional and Only valid for download) Platform the artifacts should be downloaded for. If omitted the platform this process is run on will be used. Valid options are: \"WIN\", \"MAC\" and \"LNX\". Multiple versions can be separated by \",\"."). - isRequired(false). - create("platform")); - options.addOption(OptionBuilder.withArgName("dir").hasArg(). - withDescription("(Optional) Directory that the mavenized artifacts will be located in. If omitted, a temporary directory will be used."). - isRequired(false). - create("mavenDir")); - options.addOption(OptionBuilder.withArgName("dir").hasArg(). - withDescription("(Optional) Directory that the FDK will be located in. If omitted, a temporary directory will be used."). - isRequired(false). - create("fdkDir")); - options.addOption(OptionBuilder.withArgName("url").hasArg(). - withDescription("(Optional and only valid for deploy) Url of the remote Maven repository that the generated Maven artifacts should be deployed to."). - isRequired(false). - create("repoUrl")); - options.addOption(OptionBuilder.withArgName("username").hasArg(). - withDescription("(Optional and only valid for deploy) Username used to authenticate on the remote Maven repository that the generated Maven artifacts should be deployed to."). - isRequired(false). - create("repoUsername")); - options.addOption(OptionBuilder.withArgName("password").hasArg(). - withDescription("(Optional and only valid for deploy) Password used to authenticate on the remote Maven repository that the generated Maven artifacts should be deployed to."). - isRequired(false). - create("repoPassword")); - - CommandLineParser parser = new BasicParser(); - try { - CommandLine cmd = parser.parse(options, args); - if(cmd.getArgList().isEmpty() || cmd.getArgList().contains("help")) { - printHelp(options); - } - - // Find out the desired platform(s). - List<PlatformType> platforms = new ArrayList<PlatformType>(); - String platformParam = cmd.getOptionValue("platform"); - if((platformParam != null) && !platformParam.isEmpty()) { - String[] platformNames = platformParam.split(","); - for(String platformName : platformNames) { - platforms.add(PlatformType.valueOf(platformName)); - } - } - if(platforms.isEmpty()) { - if(SystemUtils.IS_OS_WINDOWS) { - platforms.add(PlatformType.WINDOWS); - } else if(SystemUtils.IS_OS_MAC) { - platforms.add(PlatformType.MAC); - } else if(SystemUtils.IS_OS_LINUX) { - platforms.add(PlatformType.LINUX); - } else { - System.err.println("Unsupported OS type. Provide manually using 'platform' parameter."); - System.exit(1); - } - } - - // Find out where to download or convert from. - File fdkDir = cmd.hasOption("fdkDir") ? - new File(cmd.getOptionValue("fdkDir")) : getTempDir("FLEX-DOWNLOAD"); - - // Find out where to convert to or deploy from. - File mavenDir = cmd.hasOption("mavenDir") ? - new File(cmd.getOptionValue("mavenDir")) : getTempDir("FLEX-MAVEN"); - - //////////////////////////////////////////////////////////////////////////// - // Exectute operations - //////////////////////////////////////////////////////////////////////////// - - // Handle the downloading of atifacts. - if(cmd.getArgList().contains("download")) { - System.out.println("-----------------------------------------------"); - System.out.println("Starting downloads"); - - DownloadRetriever retriever = new DownloadRetriever(); - - String flexVersion = cmd.getOptionValue("flexVersion", null); - if(flexVersion != null) { - System.out.println("- Downloading Flex SDK version: " + flexVersion + - " to directory: " + fdkDir.getAbsolutePath()); - File fdkDownloadDirectory = retriever.retrieve(SdkType.FLEX, flexVersion); - // Unpack the archive to the FDK directory. - mergeDirectories(fdkDownloadDirectory, fdkDir); - } - - String flashVersions = cmd.getOptionValue("flashVersion", ""); - if(!flashVersions.isEmpty()) { - for(String flashVersion : flashVersions.split(",")) { - System.out.println("- Downloading Flash SDK version: " + flashVersion + - " to directory: " + fdkDir.getAbsolutePath()); - File flashDownloadDiretory = retriever.retrieve(SdkType.FLASH, flashVersion); - // Integrate the download into the FDK directory. - mergeDirectories(flashDownloadDiretory, fdkDir); - } - } - - String airVersions = cmd.getOptionValue("airVersion", ""); - if(!airVersions.isEmpty()) { - for(String airVersion : airVersions.split(",")) { - for(PlatformType platformType : platforms) { - System.out.println("- Downloading Air SDK version: " + airVersion + - " and platform " + platformType.name() + - " to directory: " + fdkDir.getAbsolutePath()); - File airDownloadDirectory = retriever.retrieve(SdkType.AIR, airVersion, platformType); - // Integrate the download into the FDK directory. - mergeDirectories(airDownloadDirectory, fdkDir); - } - } - } - - if(cmd.hasOption("fontkit")) { - System.out.println("- Downloading Flex Fontkit libraries" + - " to directory: " + fdkDir.getAbsolutePath()); - File fontkitDownloadDirectory = retriever.retrieve(SdkType.FONTKIT); - // Integrate the download into the FDK directory. - mergeDirectories(fontkitDownloadDirectory, fdkDir); - } - - System.out.println("Finished downloads."); - } - - // Handle the conversion. - if(cmd.getArgList().contains("convert")) { - System.out.println("-----------------------------------------------"); - System.out.println("Starting conversion"); - - System.out.println("- Converting Flex SDK from " + fdkDir.getAbsolutePath() + - " to " + mavenDir.getAbsolutePath()); - FlexConverter flexConverter = new FlexConverter(fdkDir, mavenDir); - flexConverter.convert(); - - System.out.println("- Converting Flash SDKs from " + fdkDir.getAbsolutePath() + - " to " + mavenDir.getAbsolutePath()); - FlashConverter flashConverter = new FlashConverter(fdkDir, mavenDir); - flashConverter.convert(); - - System.out.println("- Converting Air SDKs from " + fdkDir.getAbsolutePath() + - " to " + mavenDir.getAbsolutePath()); - AirConverter airConverter = new AirConverter(fdkDir, mavenDir); - airConverter.convert(); - - System.out.println("- Converting Fontkit libraries from " + fdkDir.getAbsolutePath() + - " to " + mavenDir.getAbsolutePath()); - FontkitConverter fontkitConverter = new FontkitConverter(fdkDir, mavenDir); - fontkitConverter.convert(); - - System.out.println("Finished conversion."); - } - - // Handle the deployment. - if(cmd.getArgList().contains("deploy")) { - System.out.println("-----------------------------------------------"); - System.out.println("Starting deployment"); - - if(!cmd.hasOption("repoUrl")) { - System.err.println("Parameter 'repoUrl' required for task 'deploy'."); - System.exit(1); - } - - String repoUrl = cmd.getOptionValue("repoUrl"); - String repoUsername = cmd.getOptionValue("repoUsername", null); - String repoPassword = cmd.getOptionValue("repoPassword", null); - - System.out.println("- Deploying libraries to " + repoUrl + " from " + mavenDir.getAbsolutePath()); - - AetherDeployer deployer = new AetherDeployer(mavenDir, repoUrl, repoUsername, repoPassword); - deployer.deploy(); - - System.out.println("Finished deploying."); - } - System.out.println("-----------------------------------------------"); - } catch (ParseException e) { - System.err.println("Parsing failed. Reason: " + e.getMessage()); - printHelp(options); - } - } - - protected static void printHelp(Options options) { - HelpFormatter helpFormatter = new HelpFormatter(); - helpFormatter.printHelp("[download] [convert] [deploy]", options); - } - - protected static File getTempDir(String prefix) throws IOException { - File tempFile = File.createTempFile(prefix, ".TMP"); - tempFile.delete(); - File tempDir = new File(tempFile.getParentFile(), - tempFile.getName().substring(0, tempFile.getName().length() - 4)); - if(!tempDir.exists()) { - tempDir.mkdirs(); - } - return tempDir; - } - - protected static void mergeDirectories(File sourceDir, File targetDir) throws IOException { - FileUtils.copyDirectory(sourceDir, targetDir); - } - -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/691016f5/mavenizer/mavenizer/pom.xml ---------------------------------------------------------------------- diff --git a/mavenizer/mavenizer/pom.xml b/mavenizer/mavenizer/pom.xml deleted file mode 100644 index e875807..0000000 --- a/mavenizer/mavenizer/pom.xml +++ /dev/null @@ -1,118 +0,0 @@ -<?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"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>flex-sdk-converter</artifactId> - <version>1.1.0-SNAPSHOT</version> - </parent> - - <artifactId>mavenizer</artifactId> - <version>1.1.0-SNAPSHOT</version> - <packaging>jar</packaging> - - <name>Apache Flex Mavenizer</name> - <description>Ueber jar containing all libraries needed to use the Mavenizer.</description> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-shade-plugin</artifactId> - <version>2.3</version> - <configuration> - <transformers> - <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> - <mainClass>org.apache.flex.utilities.converter.core.SdkConverter</mainClass> - </transformer> - </transformers> - <filters> - <filter> - <artifact>*:*</artifact> - </filter> - </filters> - <finalName>mavenizer</finalName> - </configuration> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>shade</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>core</artifactId> - <version>1.1.0-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>base-converter</artifactId> - <version>1.1.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>air-converter</artifactId> - <version>1.1.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>flash-converter</artifactId> - <version>1.1.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>flex-converter</artifactId> - <version>1.1.0-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>aether-deployer</artifactId> - <version>1.1.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>maven-deployer</artifactId> - <version>1.1.0-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>base-retriever</artifactId> - <version>1.1.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>download-retriever</artifactId> - <version>1.1.0-SNAPSHOT</version> - </dependency> - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/691016f5/mavenizer/pom.xml ---------------------------------------------------------------------- diff --git a/mavenizer/pom.xml b/mavenizer/pom.xml index 010ccde..6c4642d 100644 --- a/mavenizer/pom.xml +++ b/mavenizer/pom.xml @@ -27,7 +27,7 @@ </parent> <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>flex-sdk-converter</artifactId> + <artifactId>apache-flex-sdk-converter</artifactId> <version>1.1.0-SNAPSHOT</version> <packaging>pom</packaging> @@ -57,12 +57,10 @@ </scm> <modules> - <module>core</module> <module>retrievers</module> <module>converters</module> <module>deployers</module> - - <module>mavenizer</module> + <module>cli</module> </modules> <build> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/691016f5/mavenizer/retrievers/download/pom.xml ---------------------------------------------------------------------- diff --git a/mavenizer/retrievers/download/pom.xml b/mavenizer/retrievers/download/pom.xml index dbaf098..2b0cc99 100644 --- a/mavenizer/retrievers/download/pom.xml +++ b/mavenizer/retrievers/download/pom.xml @@ -42,6 +42,11 @@ <artifactId>httpclient</artifactId> <version>4.2.3</version> </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-artifact</artifactId> + <version>3.2.3</version> + </dependency> </dependencies> </project> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/691016f5/mavenizer/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java ---------------------------------------------------------------------- diff --git a/mavenizer/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java b/mavenizer/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java index e09abfa..115898d 100644 --- a/mavenizer/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java +++ b/mavenizer/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java @@ -28,8 +28,10 @@ import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; @@ -44,8 +46,7 @@ import java.io.*; import java.net.*; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; -import java.util.Properties; -import java.util.UUID; +import java.util.*; /** * Created by cdutz on 18.05.2014. @@ -55,6 +56,15 @@ public class DownloadRetriever extends BaseRetriever { public static final String FLEX_INSTALLER_CONFIG_URL = "http://flex.apache.org/installer/sdk-installer-config-4.0.xml"; + /** + * Wrapper to allow simple overriding of this property. + * + * @return URL from which the version information should be loaded. + */ + protected String getFlexInstallerConfigUrl() { + return FLEX_INSTALLER_CONFIG_URL; + } + public File retrieve(SdkType type) throws RetrieverException { return retrieve(type, null, null); } @@ -229,7 +239,7 @@ public class DownloadRetriever extends BaseRetriever { try { final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); final DocumentBuilder builder = factory.newDocumentBuilder(); - final Document doc = builder.parse(FLEX_INSTALLER_CONFIG_URL); + final Document doc = builder.parse(getFlexInstallerConfigUrl()); //Evaluate XPath against Document itself final String expression = getUrlXpath(sdkType, version, platformType); @@ -346,83 +356,64 @@ public class DownloadRetriever extends BaseRetriever { } } + public Map<DefaultArtifactVersion, Collection<PlatformType>> getAvailableVersions(SdkType type) { + Map<DefaultArtifactVersion, Collection<PlatformType>> result = + new HashMap<DefaultArtifactVersion, Collection<PlatformType>>(); + try { + final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + final DocumentBuilder builder = factory.newDocumentBuilder(); + final Document doc = builder.parse(getFlexInstallerConfigUrl()); + final XPath xPath = XPathFactory.newInstance().newXPath(); + String expression; + NodeList nodes = null; + switch (type) { + case FLEX: + expression = "/config/products/ApacheFlexSDK/versions/*"; + nodes = (NodeList) xPath.evaluate(expression, doc.getDocumentElement(), XPathConstants.NODESET); + break; + case FLASH: + expression = "/config/flashsdk/versions/*"; + nodes = (NodeList) xPath.evaluate(expression, doc.getDocumentElement(), XPathConstants.NODESET); + break; + case AIR: + expression = "/config/airsdk/*/versions/*"; + nodes = (NodeList) xPath.evaluate(expression, doc.getDocumentElement(), XPathConstants.NODESET); + break; + } - public static void main(String[] args) throws Exception { - final DownloadRetriever retriever = new DownloadRetriever(); - - // Test the retrieval of Flex SDKs - /*retriever.retrieve(SdkType.FLEX, "4.9.1"); - retriever.retrieve(SdkType.FLEX, "4.10.0"); - retriever.retrieve(SdkType.FLEX, "4.11.0"); - retriever.retrieve(SdkType.FLEX, "4.12.0"); - retriever.retrieve(SdkType.FLEX, "4.12.1"); - retriever.retrieve(SdkType.FLEX, "4.13.0");*/ - retriever.retrieve(SdkType.FLEX, "4.14.1"); - //retriever.retrieve(SdkType.FLEX, "Nightly"); - - // Test the retrieval of Fontkit libraries - retriever.retrieve(SdkType.FONTKIT); - - // Test the retrieval of AIR SDKs - /*retriever.retrieve(SdkType.AIR, "2.6", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "2.6", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "2.6", PlatformType.LINUX); - retriever.retrieve(SdkType.AIR, "2.7", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "2.7", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "3.0", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "3.0", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "3.1", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "3.1", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "3.2", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "3.2", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "3.3", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "3.3", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "3.4", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "3.4", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "3.5", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "3.5", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "3.6", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "3.6", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "3.7", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "3.7", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "3.8", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "3.8", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "3.9", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "3.9", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "4.0", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "4.0", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "13.0", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "13.0", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "14.0", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "14.0", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "15.0", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "15.0", PlatformType.MAC); - retriever.retrieve(SdkType.AIR, "16.0", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "16.0", PlatformType.MAC);*/ - retriever.retrieve(SdkType.AIR, "17.0", PlatformType.WINDOWS); - retriever.retrieve(SdkType.AIR, "17.0", PlatformType.MAC); - - // Test the retrieval of Flash SDKs - /*retriever.retrieve(SdkType.FLASH, "10.2"); - retriever.retrieve(SdkType.FLASH, "10.3"); - retriever.retrieve(SdkType.FLASH, "11.0"); - retriever.retrieve(SdkType.FLASH, "11.1"); - retriever.retrieve(SdkType.FLASH, "11.2"); - retriever.retrieve(SdkType.FLASH, "11.3"); - retriever.retrieve(SdkType.FLASH, "11.4"); - retriever.retrieve(SdkType.FLASH, "11.5"); - retriever.retrieve(SdkType.FLASH, "11.6"); - retriever.retrieve(SdkType.FLASH, "11.7"); - retriever.retrieve(SdkType.FLASH, "11.8"); - retriever.retrieve(SdkType.FLASH, "11.9"); - retriever.retrieve(SdkType.FLASH, "12.0"); - retriever.retrieve(SdkType.FLASH, "13.0"); - retriever.retrieve(SdkType.FLASH, "14.0"); - retriever.retrieve(SdkType.FLASH, "15.0"); - retriever.retrieve(SdkType.FLASH, "16.0");*/ - retriever.retrieve(SdkType.FLASH, "17.0"); - + if (nodes != null) { + for(int i = 0; i < nodes.getLength(); i++) { + Element element = (Element) nodes.item(i); + DefaultArtifactVersion version = new DefaultArtifactVersion(element.getAttribute("version")); + if(type == SdkType.AIR) { + PlatformType platformType = PlatformType.valueOf( + element.getParentNode().getParentNode().getNodeName().toUpperCase()); + if(!result.containsKey(version)) { + result.put(version, new ArrayList<PlatformType>()); + } + result.get(version).add(platformType); + } else { + result.put(version, null); + } + } + } + } catch (ParserConfigurationException e) { + e.printStackTrace(); + } catch (SAXException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (XPathExpressionException e) { + e.printStackTrace(); + } + return result; } + public static void main(String[] args) throws Exception { + DownloadRetriever downloadRetriever = new DownloadRetriever(); + //downloadRetriever.getAvailableVersions(SdkType.FLEX); + //downloadRetriever.getAvailableVersions(SdkType.FLASH); + downloadRetriever.getAvailableVersions(SdkType.AIR); + } }
