You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2014/09/05 15:15:23 UTC
[07/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Put the pieces together. - Created an
AirDownloader and FlashDownloader to automatically dow
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Put the pieces together.
- Created an AirDownloader and FlashDownloader to automatically download and mavenize a given playerglobal or air sdk
- Created a SDKConverter to allow classic mavenization of local Flex SDKs
- Cleaned up the visual output
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/0c4151f5
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/0c4151f5
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/0c4151f5
Branch: refs/heads/develop
Commit: 0c4151f588ba635913ca9cfd91cca987a8e2b5d6
Parents: f8468ba
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sat May 24 20:25:38 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sat May 24 20:25:38 2014 +0200
----------------------------------------------------------------------
.../converter/flash/FlashConverter.java | 3 +-
mavenizer/core/pom.xml | 13 +++
.../utilities/converter/core/AirDownloader.java | 52 +++++++++++
.../converter/core/FlashDownloader.java | 61 +++++++++++++
.../utilities/converter/core/SdkConverter.java | 57 ++++++++++++
mavenizer/pom.xml | 5 --
mavenizer/retrievers/base/pom.xml | 8 ++
.../converter/retrievers/BaseRetriever.java | 93 ++++++++++++++++++++
.../converter/retrievers/utils/ProgressBar.java | 47 ++++++++++
.../retrievers/download/DownloadRetriever.java | 57 ++++++++----
10 files changed, 372 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0c4151f5/mavenizer/converters/flash/src/main/java/org/apache/flex/utilities/converter/flash/FlashConverter.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/flash/src/main/java/org/apache/flex/utilities/converter/flash/FlashConverter.java b/mavenizer/converters/flash/src/main/java/org/apache/flex/utilities/converter/flash/FlashConverter.java
index 2981109..b24e446 100644
--- a/mavenizer/converters/flash/src/main/java/org/apache/flex/utilities/converter/flash/FlashConverter.java
+++ b/mavenizer/converters/flash/src/main/java/org/apache/flex/utilities/converter/flash/FlashConverter.java
@@ -69,7 +69,8 @@ public class FlashConverter extends BaseConverter implements Converter {
// Create a list of all libs that should belong to the Flash SDK runtime.
final File directory = new File(rootSourceDirectory, "runtimes" + File.separator + "player");
if(!directory.exists() || !directory.isDirectory()) {
- throw new ConverterException("Runtime directory does not exist.");
+ System.out.println("Skipping runtime generation.");
+ return;
}
final List<File> playerVersions = new ArrayList<File>();
playerVersions.addAll(Arrays.asList(directory.listFiles(new FlashRuntimeFilter())));
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0c4151f5/mavenizer/core/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/core/pom.xml b/mavenizer/core/pom.xml
index d3cc9bf..21dd31c 100644
--- a/mavenizer/core/pom.xml
+++ b/mavenizer/core/pom.xml
@@ -32,4 +32,17 @@
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.flex.utilities.converter</groupId>
+ <artifactId>flex-converter</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.flex.utilities.converter</groupId>
+ <artifactId>download-retriever</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0c4151f5/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
new file mode 100644
index 0000000..cac8244
--- /dev/null
+++ b/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/AirDownloader.java
@@ -0,0 +1,52 @@
+/*
+ * 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.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 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]);
+ }
+
+ final DownloadRetriever downloadRetriever = new DownloadRetriever();
+ final File airSDKSourceDirectory = downloadRetriever.retrieve(SDKType.AIR, version, platformType);
+
+ final AirConverter airConverter = new AirConverter(airSDKSourceDirectory, targetDirectory);
+ airConverter.convert();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0c4151f5/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
new file mode 100644
index 0000000..c75e250
--- /dev/null
+++ b/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/FlashDownloader.java
@@ -0,0 +1,61 @@
+/*
+ * 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 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]);
+
+ 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();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0c4151f5/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
new file mode 100644
index 0000000..44115cc
--- /dev/null
+++ b/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/SdkConverter.java
@@ -0,0 +1,57 @@
+/*
+ * 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;
+
+/**
+ * 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());
+ }
+ }
+
+ final FlexConverter flexConverter = new FlexConverter(sourceDirectory, targetDirectory);
+ flexConverter.convert();
+ final AirConverter airConverter = new AirConverter(sourceDirectory, targetDirectory);
+ airConverter.convert();
+ final FlashConverter flashConverter = new FlashConverter(sourceDirectory, targetDirectory);
+ flashConverter.convert();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0c4151f5/mavenizer/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/pom.xml b/mavenizer/pom.xml
index 83015db..3be7f8f 100644
--- a/mavenizer/pom.xml
+++ b/mavenizer/pom.xml
@@ -51,11 +51,6 @@
<artifactId>jettison</artifactId>
<version>1.3.1</version>
</dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-compress</artifactId>
- <version>1.4</version>
- </dependency>
<!-- Needed for Aether Repository Client -->
<dependency>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0c4151f5/mavenizer/retrievers/base/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/pom.xml b/mavenizer/retrievers/base/pom.xml
index 4a8c74d..5663955 100644
--- a/mavenizer/retrievers/base/pom.xml
+++ b/mavenizer/retrievers/base/pom.xml
@@ -32,4 +32,12 @@
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-compress</artifactId>
+ <version>1.8.1</version>
+ </dependency>
+ </dependencies>
+
</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0c4151f5/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/BaseRetriever.java
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/BaseRetriever.java b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/BaseRetriever.java
index 8477a0f..4f04363 100644
--- a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/BaseRetriever.java
+++ b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/BaseRetriever.java
@@ -16,8 +16,101 @@
*/
package org.apache.flex.utilities.converter.retrievers;
+import com.google.common.io.CountingInputStream;
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.ArchiveException;
+import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.archivers.ArchiveStreamFactory;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
+import org.apache.flex.utilities.converter.retrievers.exceptions.RetrieverException;
+import org.apache.flex.utilities.converter.retrievers.utils.ProgressBar;
+
+import java.io.*;
+
/**
* Created by cdutz on 18.05.2014.
*/
public abstract class BaseRetriever implements Retriever {
+
+ public static final int KILOBYTE = 1024;
+ public static final int MEGABYTE = KILOBYTE * 1024;
+ public static final int BUFFER_MAX = MEGABYTE;
+
+ protected void unpack(File inputArchive, File targetDirectory) throws RetrieverException {
+ if (!targetDirectory.mkdirs()) {
+ throw new RetrieverException(
+ "Unable to create extraction directory " + targetDirectory.getAbsolutePath());
+ }
+
+ ArchiveInputStream archiveInputStream = null;
+ ArchiveEntry entry;
+ try {
+
+ final CountingInputStream inputStream = new CountingInputStream(new FileInputStream(inputArchive));
+
+ final long inputFileSize = inputArchive.length();
+
+ if(inputArchive.getName().endsWith(".tbz2")) {
+ archiveInputStream = new TarArchiveInputStream(
+ new BZip2CompressorInputStream(inputStream));
+ } else {
+ archiveInputStream = new ArchiveStreamFactory().createArchiveInputStream(
+ new BufferedInputStream(inputStream));
+ }
+
+ final ProgressBar progressBar = new ProgressBar(inputFileSize);
+ while ((entry = archiveInputStream.getNextEntry()) != null) {
+ final File outputFile = new File(targetDirectory, entry.getName());
+
+ // Entry is a directory.
+ if (entry.isDirectory()) {
+ if (!outputFile.exists()) {
+ if(!outputFile.mkdirs()) {
+ throw new RetrieverException(
+ "Could not create output directory " + outputFile.getAbsolutePath());
+ }
+ }
+ }
+
+ // Entry is a file.
+ else {
+ final byte[] data = new byte[BUFFER_MAX];
+ final FileOutputStream fos = new FileOutputStream(outputFile);
+ BufferedOutputStream dest = null;
+ try {
+ dest = new BufferedOutputStream(fos, BUFFER_MAX);
+
+ int count;
+ while ((count = archiveInputStream.read(data, 0, BUFFER_MAX)) != -1) {
+ dest.write(data, 0, count);
+ progressBar.updateProgress(inputStream.getCount());
+ }
+ } finally {
+ if(dest != null) {
+ dest.flush();
+ dest.close();
+ }
+ }
+ }
+
+ progressBar.updateProgress(inputStream.getCount());
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (ArchiveException e) {
+ e.printStackTrace();
+ } finally {
+ if(archiveInputStream != null) {
+ try {
+ archiveInputStream.close();
+ } catch(Exception e) {
+ // Ignore...
+ }
+ }
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0c4151f5/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/utils/ProgressBar.java
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/utils/ProgressBar.java b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/utils/ProgressBar.java
new file mode 100644
index 0000000..8e91864
--- /dev/null
+++ b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/utils/ProgressBar.java
@@ -0,0 +1,47 @@
+/*
+ * 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.retrievers.utils;
+
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * Created by cdutz on 24.05.2014.
+ */
+public class ProgressBar {
+
+ protected long total;
+
+ public ProgressBar(long total) {
+ this.total = total;
+ drawOutput(0l);
+ }
+
+ public void updateProgress(long current) {
+ drawOutput(current);
+ }
+
+ protected void drawOutput(long current) {
+ final int transferredPercent = (int) Math.round(
+ ((double) current / (double) total) * (double) 100);
+ final int segmentsTransferred = transferredPercent / 2;
+ final int segmentsRest = 50 - segmentsTransferred;
+ System.out.print("\r" + String.format(" %3d", transferredPercent) + "% [" +
+ StringUtils.repeat("=", segmentsTransferred) +
+ ((segmentsRest > 0) ? ">" + StringUtils.repeat(" ", segmentsRest - 1) : "") + "] ");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0c4151f5/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 0bf26b2..6bea87c 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
@@ -20,7 +20,7 @@ import org.apache.flex.utilities.converter.retrievers.BaseRetriever;
import org.apache.flex.utilities.converter.retrievers.exceptions.RetrieverException;
import org.apache.flex.utilities.converter.retrievers.types.PlatformType;
import org.apache.flex.utilities.converter.retrievers.types.SDKType;
-import org.codehaus.plexus.util.StringUtils;
+import org.apache.flex.utilities.converter.retrievers.utils.ProgressBar;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -68,12 +68,17 @@ public class DownloadRetriever extends BaseRetriever {
// Create a temp target file.
final File targetFile = File.createTempFile(type.toString() + "-" + version +
- ((platformType != null) ? "-" + platformType : "") + "-", ".bin");
+ ((platformType != null) ? "-" + platformType : "") + "-",
+ sourceUrl.getFile().substring(sourceUrl.getFile().lastIndexOf(".")));
final FileOutputStream fos = new FileOutputStream(targetFile);
- // Do the copying.
+ ////////////////////////////////////////////////////////////////////////////////
+ // Do the downloading.
+ ////////////////////////////////////////////////////////////////////////////////
+
final long expectedSize = connection.getContentLength();
long transferedSize = 0L;
+ System.out.println("===========================================================");
System.out.println("Downloading " + type + " version " + version +
((platformType != null) ? " for platform " + platformType : ""));
if(expectedSize > 1014 * 1024) {
@@ -81,21 +86,33 @@ public class DownloadRetriever extends BaseRetriever {
} else {
System.out.println("Expected size: " + (expectedSize / 1024 ) + "KB");
}
+ final ProgressBar progressBar = new ProgressBar(expectedSize);
while (transferedSize < expectedSize) {
transferedSize += fos.getChannel().transferFrom(rbc, transferedSize, 1 << 20);
- final int transferedPercent = (int) Math.round(
- ((double) transferedSize / (double) expectedSize) * (double) 100);
- final int segmentsTransferred = transferedPercent / 2;
- final int segmentsRest = 50 - segmentsTransferred;
- System.out.print("\r" + String.format("%3d", transferedPercent) + "% [" +
- StringUtils.repeat("=", segmentsTransferred) +
- ((segmentsRest > 0) ? ">" + StringUtils.repeat(" ", segmentsRest - 1) : "") + "]");
+ progressBar.updateProgress(transferedSize);
}
- System.out.println();
- System.out.println("Finished");
fos.close();
+ System.out.println();
+ System.out.println("Finished downloading.");
+ System.out.println("===========================================================");
- return targetFile;
+ ////////////////////////////////////////////////////////////////////////////////
+ // Do the extracting.
+ ////////////////////////////////////////////////////////////////////////////////
+
+ if(type.equals(SDKType.FLASH)) {
+ return targetFile;
+ } else {
+ System.out.println("Extracting archive to temp directory.");
+ final File targetDirectory = new File(targetFile.getParent(),
+ targetFile.getName().substring(0, targetFile.getName().lastIndexOf(".") - 1));
+ unpack(targetFile, targetDirectory);
+ System.out.println();
+ System.out.println("Finished extracting.");
+ System.out.println("===========================================================");
+
+ return targetDirectory;
+ }
} catch (MalformedURLException e) {
throw new RetrieverException("Error downloading archive.", e);
} catch (FileNotFoundException e) {
@@ -117,6 +134,10 @@ public class DownloadRetriever extends BaseRetriever {
final XPath xPath = XPathFactory.newInstance().newXPath();
final Element artifactElement = (Element) xPath.evaluate(
expression, doc.getDocumentElement(), XPathConstants.NODE);
+ if(artifactElement == null) {
+ throw new RetrieverException("Could not find " + sdkType.toString() + " SDK with version " + version);
+ }
+
final StringBuilder stringBuilder = new StringBuilder();
if (sdkType == SDKType.FLEX) {
final String path = artifactElement.getAttribute("path");
@@ -260,13 +281,13 @@ public class DownloadRetriever extends BaseRetriever {
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, "13.0", PlatformType.MAC);*/
+ //retriever.retrieve(SDKType.AIR, "14.0", PlatformType.WINDOWS);
+ retriever.retrieve(SDKType.AIR, "14.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, "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");