Repository: flex-utilities Updated Branches: refs/heads/develop 0bd96f936 -> 4933ddf85
- Fixed a bug preventing the themes to compile if no playerglobal 11.1 is present in the FDK - Replaced the individual classes in the core module with one multi-purpose CLI implementation Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/4933ddf8 Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/4933ddf8 Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/4933ddf8 Branch: refs/heads/develop Commit: 4933ddf855d1477d93548197bdd95f115cf7714f Parents: 0bd96f9 Author: Christofer Dutz <[email protected]> Authored: Tue Apr 7 22:53:17 2015 +0200 Committer: Christofer Dutz <[email protected]> Committed: Tue Apr 7 22:53:17 2015 +0200 ---------------------------------------------------------------------- .../utilities/converter/flex/FlexConverter.java | 16 ++ mavenizer/core/pom.xml | 20 +- .../utilities/converter/core/AirDownloader.java | 55 ----- .../converter/core/BatchConverter.java | 87 ------- .../converter/core/FlashDownloader.java | 65 ----- .../utilities/converter/core/SdkConverter.java | 77 ------ .../converter/core/SdkConverterCLI.java | 244 +++++++++++++++++++ .../utilities/converter/core/SdkDownloader.java | 45 ---- .../deployer/aether/AetherDeployer.java | 19 +- 9 files changed, 289 insertions(+), 339 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4933ddf8/mavenizer/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java ---------------------------------------------------------------------- diff --git a/mavenizer/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java b/mavenizer/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java index d6d3495..841aec6 100644 --- a/mavenizer/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java +++ b/mavenizer/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java @@ -423,6 +423,11 @@ public class FlexConverter extends BaseConverter implements Converter { try { final File compcLibrary = new File(fdkLibDir, "compc.jar"); final File frameworkDir = new File(rootSourceDirectory, "frameworks"); + final String targetPlayer = getTargetPlayer(new File(frameworkDir, "libs/player")); + if(targetPlayer == null) { + System.out.println("Skipping theme compilation due to missing playerglobl.swc"); + return null; + } processCmd.add("java"); processCmd.add("-Xmx384m"); @@ -430,6 +435,7 @@ public class FlexConverter extends BaseConverter implements Converter { processCmd.add("-jar"); processCmd.add(compcLibrary.getCanonicalPath()); processCmd.add("+flexlib=" + frameworkDir.getCanonicalPath()); + processCmd.add("-target-player=" + targetPlayer); if (themeDirectory.isDirectory()) { // Add all the content files. @@ -614,6 +620,16 @@ public class FlexConverter extends BaseConverter implements Converter { return bundles; } + protected String getTargetPlayer(File playerDir) { + if(playerDir.exists() && playerDir.isDirectory()) { + File[] files = playerDir.listFiles(); + if((files != null) && files.length > 0) { + return files[0].getName(); + } + } + return null; + } + public static class FlexCompilerFilter implements FilenameFilter { private AirConverter.AirCompilerFilter airFilter = new AirConverter.AirCompilerFilter(); http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4933ddf8/mavenizer/core/pom.xml ---------------------------------------------------------------------- diff --git a/mavenizer/core/pom.xml b/mavenizer/core/pom.xml index 3a3f4c8..d0eae20 100644 --- a/mavenizer/core/pom.xml +++ b/mavenizer/core/pom.xml @@ -40,7 +40,7 @@ <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> <addClasspath>true</addClasspath> - <mainClass>org.apache.flex.utilities.converter.core.SdkConverter</mainClass> + <mainClass>org.apache.flex.utilities.converter.core.SdkConverterCLI</mainClass> </manifest> <manifestEntries> <Implementation-Build>${project.version}</Implementation-Build> @@ -67,14 +67,30 @@ <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>download-retriever</artifactId> + <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/4933ddf8/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/AirDownloader.java ---------------------------------------------------------------------- diff --git a/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/AirDownloader.java b/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/AirDownloader.java deleted file mode 100644 index 6e2b9ce..0000000 --- a/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/AirDownloader.java +++ /dev/null @@ -1,55 +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.flex.utilities.converter.core; - -import org.apache.flex.utilities.converter.air.AirConverter; -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; - -/** - * Created by cdutz on 24.05.2014. - */ -public class AirDownloader { - - public void downloadAndConvert(File targetDirectory, String version, PlatformType platformType) throws Exception { - final DownloadRetriever downloadRetriever = new DownloadRetriever(); - final File airSDKSourceDirectory = downloadRetriever.retrieve(SdkType.AIR, version, platformType); - - final AirConverter airConverter = new AirConverter(airSDKSourceDirectory, targetDirectory); - airConverter.convert(); - } - - public static void main(String[] args) throws Exception { - if(args.length != 3) { - System.out.println("Usage: AirDownloader {air-version} {target-directory} {platform-type}"); - return; - } - - final String version = args[0]; - final File targetDirectory = new File(args[1]); - final PlatformType platformType = PlatformType.valueOf(args[2]); - if(platformType == null) { - throw new Exception("Unknown platform type: " + args[2]); - } - - new AirDownloader().downloadAndConvert(targetDirectory, version, platformType); - } - -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4933ddf8/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/BatchConverter.java ---------------------------------------------------------------------- diff --git a/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/BatchConverter.java b/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/BatchConverter.java deleted file mode 100644 index caf14cf..0000000 --- a/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/BatchConverter.java +++ /dev/null @@ -1,87 +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.flex.utilities.converter.core; - -import org.apache.flex.utilities.converter.air.AirConverter; -import org.apache.flex.utilities.converter.flash.FlashConverter; -import org.apache.flex.utilities.converter.flex.FlexConverter; - -import java.io.File; -import java.io.FileFilter; - -/** - * Created by cdutz on 30.05.2014. - */ -public class BatchConverter { - - public static void main(String[] args) throws Exception { - if(args.length != 2) { - System.out.println("Usage: SDKConverter {source-directory} {target-directory}"); - return; - } - - final File sourceDirectory = new File(args[0]); - final File targetDirectory = new File(args[1]); - - if(!sourceDirectory.exists()) { - throw new Exception("'source-directory' does not exist: " + sourceDirectory.getAbsolutePath()); - } - - if(!targetDirectory.exists()) { - if(!targetDirectory.mkdirs()) { - throw new Exception("Could not create 'target-directory': " + targetDirectory.getAbsolutePath()); - } - } - - for(final File batchDirectory : sourceDirectory.listFiles(new FileFilter() { - @Override - public boolean accept(File pathname) { - return pathname.isDirectory(); - } - })) { - System.out.println("-------------------------------------------------------------------------------------"); - System.out.println("Processing directory: " + batchDirectory.getAbsolutePath()); - - try { - System.out.println("Generating FLEX SDK"); - final FlexConverter flexConverter = new FlexConverter(batchDirectory, targetDirectory); - flexConverter.convert(); - } catch(Exception e) { - System.out.println("Skipping generation of FLEX SDK"); - } - - try { - System.out.println("Generating AIR SDK"); - final AirConverter airConverter = new AirConverter(batchDirectory, targetDirectory); - airConverter.convert(); - } catch(Exception e) { - System.out.println("Skipping generation of AIR SDK"); - } - - try { - System.out.println("Generating Flash SDK"); - final FlashConverter flashConverter = new FlashConverter(batchDirectory, targetDirectory); - flashConverter.convert(); - } catch(Exception e) { - System.out.println("Skipping generation of Flash SDK"); - } - - System.out.println("Finished."); - } - } - -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4933ddf8/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/FlashDownloader.java ---------------------------------------------------------------------- diff --git a/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/FlashDownloader.java b/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/FlashDownloader.java deleted file mode 100644 index b90a223..0000000 --- a/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/FlashDownloader.java +++ /dev/null @@ -1,65 +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.flex.utilities.converter.core; - -import org.apache.flex.utilities.converter.flash.FlashConverter; -import org.apache.flex.utilities.converter.retrievers.download.DownloadRetriever; -import org.apache.flex.utilities.converter.retrievers.types.SdkType; - -import java.io.File; - -/** - * Created by cdutz on 24.05.2014. - */ -public class FlashDownloader { - - public void downloadAndConvert(File targetDirectory, String version) throws Exception { - final DownloadRetriever downloadRetriever = new DownloadRetriever(); - final File playerglobalSourceFile = downloadRetriever.retrieve(SdkType.FLASH, version); - - final File tempSdkRoot = new File(playerglobalSourceFile.getParent(), - playerglobalSourceFile.getName().substring(0, playerglobalSourceFile.getName().length() - 4) + - "-temp-dir"); - final File playerGlobalTargetDir = new File(tempSdkRoot, - ("frameworks.libs.player.").replace(".", File.separator) + version); - if(!playerGlobalTargetDir.mkdirs()) { - throw new Exception("Couldn't create playerglobal target dir " + tempSdkRoot.getAbsolutePath()); - } - final File playerGlobalTargetFile = new File(playerGlobalTargetDir, "playerglobal.swc"); - - if(!playerglobalSourceFile.renameTo(playerGlobalTargetFile)) { - throw new Exception("Couldn't move playerglobal file from " + playerglobalSourceFile.getAbsolutePath() + - " to " + playerGlobalTargetFile.getAbsolutePath()); - } - - final FlashConverter flashConverter = new FlashConverter(tempSdkRoot, targetDirectory); - flashConverter.convert(); - } - - public static void main(String[] args) throws Exception { - if(args.length != 2) { - System.out.println("Usage: FlashDownloader {player-version} {target-directory}"); - return; - } - - final String version = args[0]; - final File targetDirectory = new File(args[1]); - - new FlashDownloader().downloadAndConvert(targetDirectory, version); - } - -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4933ddf8/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkConverter.java ---------------------------------------------------------------------- diff --git a/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkConverter.java b/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkConverter.java deleted file mode 100644 index ca8e0df..0000000 --- a/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkConverter.java +++ /dev/null @@ -1,77 +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.flex.utilities.converter.core; - -import org.apache.flex.utilities.converter.air.AirConverter; -import org.apache.flex.utilities.converter.exceptions.ConverterException; -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 java.io.File; - -/** - * Created by cdutz on 24.05.2014. - */ -public class SdkConverter { - - public static void main(String[] args) throws Exception { - if(args.length != 2) { - System.out.println("Usage: SDKConverter {source-directory} {target-directory}"); - return; - } - - final File sourceDirectory = new File(args[0]); - final File targetDirectory = new File(args[1]); - - if(!sourceDirectory.exists()) { - throw new Exception("'source-directory' does not exist: " + sourceDirectory.getAbsolutePath()); - } - - if(!targetDirectory.exists()) { - if(!targetDirectory.mkdirs()) { - throw new Exception("Could not create 'target-directory': " + targetDirectory.getAbsolutePath()); - } - } - - try { - final FlexConverter flexConverter = new FlexConverter(sourceDirectory, targetDirectory); - flexConverter.convert(); - } catch(ConverterException e) { - System.out.println("Error during FLEX SDK generation: " + e.getMessage()); - } - try { - final AirConverter airConverter = new AirConverter(sourceDirectory, targetDirectory); - airConverter.convert(); - } catch(ConverterException e) { - System.out.println("Error during AIR SDK generation: " + e.getMessage()); - } - try { - final FlashConverter flashConverter = new FlashConverter(sourceDirectory, targetDirectory); - flashConverter.convert(); - } catch(ConverterException e) { - System.out.println("Error during Flash SDK generation: " + e.getMessage()); - } - try { - final FontkitConverter fontkitConverter = new FontkitConverter(sourceDirectory, targetDirectory); - fontkitConverter.convert(); - } catch(ConverterException e) { - System.out.println("Error during Fontkit artifacts generation: " + e.getMessage()); - } - } - -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4933ddf8/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 new file mode 100644 index 0000000..f5263c0 --- /dev/null +++ b/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java @@ -0,0 +1,244 @@ +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/4933ddf8/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkDownloader.java ---------------------------------------------------------------------- diff --git a/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkDownloader.java b/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkDownloader.java deleted file mode 100644 index 12beb18..0000000 --- a/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkDownloader.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.apache.flex.utilities.converter.core; - -import org.apache.flex.utilities.converter.air.AirConverter; -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; - -/** - * Created by christoferdutz on 07.04.15. - */ -public class SdkDownloader { - - public static void main(String[] args) throws Exception { - File mavenTarget = new File("temp/maven"); - mavenTarget.mkdirs(); - - DownloadRetriever downloadRetriever = new DownloadRetriever(); - - // Download and convert Flex - File flexDir = downloadRetriever.retrieve(SdkType.FLEX, "4.14.1"); - FlexConverter flexConverter = new FlexConverter(flexDir, mavenTarget); - flexConverter.convert(); - - // Download and convert Air - File airDir = downloadRetriever.retrieve(SdkType.AIR, "17.0", PlatformType.MAC); - AirConverter airConverter = new AirConverter(airDir, mavenTarget); - airConverter.convert(); - - // Download and convert Flash - File flashDir = downloadRetriever.retrieve(SdkType.FLASH, "17.0"); - FlashConverter flashConverter = new FlashConverter(flashDir, mavenTarget); - flashConverter.convert(); - - // Download and convert Fontkit - File fontkitDir = downloadRetriever.retrieve(SdkType.FONTKIT); - FontkitConverter fontkitConverter = new FontkitConverter(fontkitDir, mavenTarget); - fontkitConverter.convert(); - } - -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4933ddf8/mavenizer/deployers/aether/src/main/java/org/apache/flex/utilities/converter/deployer/aether/AetherDeployer.java ---------------------------------------------------------------------- diff --git a/mavenizer/deployers/aether/src/main/java/org/apache/flex/utilities/converter/deployer/aether/AetherDeployer.java b/mavenizer/deployers/aether/src/main/java/org/apache/flex/utilities/converter/deployer/aether/AetherDeployer.java index c9168e3..89b991b 100644 --- a/mavenizer/deployers/aether/src/main/java/org/apache/flex/utilities/converter/deployer/aether/AetherDeployer.java +++ b/mavenizer/deployers/aether/src/main/java/org/apache/flex/utilities/converter/deployer/aether/AetherDeployer.java @@ -62,14 +62,20 @@ import java.io.Reader; */ public class AetherDeployer { - private String directory; + private File directory; private String url; private String username; private String password; + public AetherDeployer(File directory, String url, String username, String password) { + this.directory = directory; + this.url = url; + this.username = username; + this.password = password; + } public AetherDeployer(String[] parameters) { - this.directory = parameters[0]; + this.directory = new File(parameters[0]); this.url = parameters[1]; if (parameters.length > 2) { this.username = parameters[2]; @@ -84,7 +90,7 @@ public class AetherDeployer { } final AetherDeployer deployer = new AetherDeployer(args); - deployer.start(); + deployer.deploy(); } private static void printUsage() { @@ -97,7 +103,7 @@ public class AetherDeployer { System.out.println("\t4- password: The password used to authenticate on the target repository."); } - private void start() { + public void deploy() { try { final DefaultServiceLocator locator = new DefaultServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); @@ -131,7 +137,7 @@ public class AetherDeployer { session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(session, localRepo)); // Process all content of the mavenizer target directory. - final File rootDir = new File(directory); + final File rootDir = directory; processDir(rootDir, repositorySystem, session, remoteRepository); } } catch (Throwable e) { @@ -222,21 +228,18 @@ public class AetherDeployer { } private class PomFilter implements java.io.FileFilter { - @Override public boolean accept(File pathname) { return pathname.getName().endsWith(".pom"); } } private class DirFilter implements java.io.FileFilter { - @Override public boolean accept(File pathname) { return pathname.isDirectory(); } } private class ArtifactFilter implements java.io.FileFilter { - @Override public boolean accept(File pathname) { return !pathname.getName().endsWith(".pom") && !pathname.isDirectory(); }
