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:17 UTC
[01/28] FLEX-34318 - [Mavenizer] Refactor the Mavenizer in
preparation of future mavenized releases of Flex - Split up the Mavenizer
Logic into 3 parts: AirConverter,
FlashConverter and FlexConverter - Each converter is located in a dedicated
Maven modul
Repository: flex-utilities
Updated Branches:
refs/heads/develop 62fb6a4d1 -> a1d4c6725
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/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
new file mode 100644
index 0000000..658f067
--- /dev/null
+++ b/mavenizer/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
@@ -0,0 +1,617 @@
+package org.apache.flex.utilities.converter.flex;
+
+import org.apache.flex.utilities.converter.BaseConverter;
+import org.apache.flex.utilities.converter.Converter;
+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.model.MavenArtifact;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.*;
+import java.util.*;
+import java.util.jar.JarOutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * Created by cdutz on 22.04.2014.
+ */
+public class FlexConverter extends BaseConverter implements Converter {
+
+ protected String flexSdkVersion;
+
+ /**
+ * @param rootSourceDirectory Path to the root of the original Flex SDK.
+ * @param rootTargetDirectory Path to the root of the directory where the Maven artifacts should be generated to.
+ * @throws org.apache.flex.utilities.converter.exceptions.ConverterException
+ */
+ public FlexConverter(File rootSourceDirectory, File rootTargetDirectory) throws ConverterException {
+ super(rootSourceDirectory, rootTargetDirectory);
+
+ // Get the version of the current Flex SDK.
+ this.flexSdkVersion = getFlexVersion(rootSourceDirectory);
+ }
+
+ /**
+ * Entry point for generating the Maven artifacts for an Flex SDK.
+ *
+ * @throws ConverterException
+ */
+ @Override
+ protected void processDirectory() throws ConverterException {
+ if(!rootSourceDirectory.exists() || !rootSourceDirectory.isDirectory()) {
+ throw new ConverterException("Flex SDK directory '" + rootSourceDirectory.getPath() + "' is invalid.");
+ }
+
+ generateCompilerArtifacts();
+ generateFrameworkArtifacts();
+ }
+
+ /**
+ * This method generates those artifacts that resemble the compiler part of the Flex SDK.
+ *
+ * @throws ConverterException
+ */
+ protected void generateCompilerArtifacts() throws ConverterException {
+ // Create the root artifact.
+ final MavenArtifact compiler = new MavenArtifact();
+ compiler.setGroupId("org.apache.flex");
+ compiler.setArtifactId("compiler");
+ compiler.setVersion(flexSdkVersion);
+ compiler.setPackaging("pom");
+
+ // Create a list of all libs that should belong to the Flex SDK compiler.
+ final File directory = new File(rootSourceDirectory, "lib");
+ if(!directory.exists() || !directory.isDirectory()) {
+ throw new ConverterException("Compiler directory does not exist.");
+ }
+ final List<File> files = new ArrayList<File>();
+ files.addAll(Arrays.asList(directory.listFiles(new FlexCompilerFilter())));
+
+ // Add all jars in the "external" directory.
+ final File externalDirectory = new File(directory, "external");
+ if(externalDirectory.exists() && externalDirectory.isDirectory()) {
+ files.addAll(Arrays.asList(externalDirectory.listFiles(new FlexCompilerFilter())));
+
+ // Add all jars in the "external/optional" directory.
+ final File optionalDirectory = new File(externalDirectory, "optional");
+ if(optionalDirectory.exists() && optionalDirectory.isDirectory()) {
+ files.addAll(Arrays.asList(optionalDirectory.listFiles(new FlexCompilerFilter())));
+ }
+ }
+
+ // Generate artifacts for every jar in the input directories.
+ for(final File sourceFile : files) {
+ final MavenArtifact artifact = resolveArtifact(sourceFile, "org.apache.flex.compiler", flexSdkVersion);
+ compiler.addDependency(artifact);
+ }
+
+ // Write this artifact to file.
+ writeArtifact(compiler);
+ }
+
+ /**
+ * This method generates those artifacts that resemble the framework part of the Flex SDK.
+ *
+ * @throws ConverterException
+ */
+ protected void generateFrameworkArtifacts() throws ConverterException {
+ final File directory = new File(rootSourceDirectory, "frameworks" + File.separator + "libs");
+ generateFrameworkArtifacts(directory, "org.apache.flex");
+ generateThemeArtifacts();
+ generateFrameworkConfigurationArtifact();
+ }
+
+ protected void generateFrameworkArtifacts(File directory, String curGroupId) throws ConverterException {
+ // Create the root artifact.
+ final MavenArtifact framework = new MavenArtifact();
+ framework.setGroupId(curGroupId);
+ framework.setArtifactId("libs".equals(directory.getName()) ? "framework" : directory.getName());
+ framework.setVersion(flexSdkVersion);
+ framework.setPackaging("pom");
+
+ final String artifactGroupId = framework.getGroupId() + "." + framework.getArtifactId();
+
+ // Create a list of all libs that should belong to the Flex SDK framework.
+ if(!directory.exists() || !directory.isDirectory()) {
+ throw new ConverterException("Framework directory does not exist.");
+ }
+ final List<File> files = new ArrayList<File>();
+ files.addAll(Arrays.asList(directory.listFiles(new FlexFrameworkFilter())));
+
+ // Generate artifacts for every jar in the input directories.
+ for(final File sourceFile : files) {
+ // I think the experimental_mobile.swc belongs in the "mobile" package.
+ if(!"libs".equals(directory.getName()) || !"experimental_mobile.swc".equals(sourceFile.getName())) {
+ final MavenArtifact artifact = resolveArtifact(sourceFile, artifactGroupId, flexSdkVersion);
+ framework.addDependency(artifact);
+ }
+ }
+ // If we are in the "mobile" directory and the paren contains an "experimental_mobile.swc" file,
+ // add this to the mobile package.
+ if("mobile".equals(directory.getName())) {
+ final File mobileExperimental = new File(directory.getParent(), "experimental_mobile.swc");
+ final MavenArtifact artifact = resolveArtifact(mobileExperimental, artifactGroupId, flexSdkVersion);
+ framework.addDependency(artifact);
+ }
+ // Write this artifact to file.
+ writeArtifact(framework);
+
+ // After processing the current directory, process any eventually existing child directories.
+ final List<File> children = new ArrayList<File>();
+ children.addAll(Arrays.asList(directory.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(File pathname) {
+ return pathname.isDirectory() && !"player".equals(pathname.getName());
+ }
+ })));
+ for(final File childDirectory : children) {
+ generateFrameworkArtifacts(childDirectory, artifactGroupId);
+ }
+ }
+
+ protected void generateThemeArtifacts() throws ConverterException {
+ final File frameworksDirectory = new File(rootSourceDirectory, "frameworks");
+
+ // Deploy all the swcs in the themes directory.
+ final File themesSrcDirectory = new File(frameworksDirectory, "themes");
+ if(themesSrcDirectory.exists()) {
+ generateDefaultThemeArtifacts(themesSrcDirectory);
+ }
+
+ // Deploy MXFTEText theme
+ final File mxfteThemeCss = new File(frameworksDirectory, "projects" + File.separator + "spark" +
+ File.separator + "MXFTEText.css");
+ if(mxfteThemeCss.exists()){
+ generateMxFteThemeArtifact(mxfteThemeCss);
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Utility methods
+ //
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+
+ @Override
+ protected void writeArtifact(MavenArtifact artifact) throws ConverterException {
+ if(!"pom".equals(artifact.getPackaging())) {
+ // Copy the rsls too.
+ final File rslSourceFile = getRsl(artifact.getArtifactId());
+ if(rslSourceFile != null) {
+ final File rslTargetFile = new File(
+ artifact.getBinaryTargetFile(rootTargetDirectory, MavenArtifact.DEFAULT_CLASSIFIER).getParent(),
+ artifact.getArtifactId() + "-" + artifact.getVersion() + ".swf");
+ copyFile(rslSourceFile, rslTargetFile);
+ }
+
+ // Copy the swzc too.
+ final File signedRslSourceFile = getSignedRsl(artifact.getArtifactId());
+ if(signedRslSourceFile != null) {
+ final File signedRslTargetFile = new File(
+ artifact.getBinaryTargetFile(rootTargetDirectory, MavenArtifact.DEFAULT_CLASSIFIER).getParent(),
+ artifact.getArtifactId() + "-" + artifact.getVersion() + ".swz");
+ copyFile(signedRslSourceFile, signedRslTargetFile);
+ }
+
+ // Copy the language resources too.
+ final Map<String, File> resourceBundles = getResourceBundles(artifact.getArtifactId());
+ if(!resourceBundles.isEmpty() &&
+ artifact.getBinaryTargetFile(rootTargetDirectory, MavenArtifact.DEFAULT_CLASSIFIER) != null) {
+ boolean foundResources = false;
+ for(final String resource : resourceBundles.keySet()) {
+ final File resourceSourceFile = resourceBundles.get(resource);
+ final File resourceTargetFile = new File(
+ artifact.getBinaryTargetFile(rootTargetDirectory, MavenArtifact.DEFAULT_CLASSIFIER).getParent(),
+ artifact.getArtifactId() + "-" + artifact.getVersion() + "-" + resource + ".rb.swc");
+ copyFile(resourceSourceFile, resourceTargetFile);
+ foundResources = true;
+ }
+
+ // If the library had at least one resource bundle, generate a dummy rb.swc and add that as dependency.
+ if(foundResources) {
+ final File resourceDummyTargetFile = new File(
+ artifact.getBinaryTargetFile(rootTargetDirectory, MavenArtifact.DEFAULT_CLASSIFIER).getParent(),
+ artifact.getArtifactId() + "-" + artifact.getVersion() + ".rb.swc");
+ writeDummy(resourceDummyTargetFile);
+
+ final MavenArtifact resourceBundleDependency = new MavenArtifact();
+ resourceBundleDependency.setGroupId(artifact.getGroupId());
+ resourceBundleDependency.setArtifactId(artifact.getArtifactId());
+ resourceBundleDependency.setVersion(artifact.getVersion());
+ resourceBundleDependency.setPackaging("rb.swc");
+ artifact.addDependency(resourceBundleDependency);
+ }
+ }
+
+ // Add source zips ...
+ final File sourceArtifactSourceFile = generateSourceArtifact(artifact.getArtifactId());
+ if(sourceArtifactSourceFile != null) {
+ final File sourceArtifactTargetFile = new File(
+ artifact.getBinaryTargetFile(rootTargetDirectory, MavenArtifact.DEFAULT_CLASSIFIER).getParent(),
+ artifact.getArtifactId() + "-" + artifact.getVersion() + "-sources.jar");
+ copyFile(sourceArtifactSourceFile, sourceArtifactTargetFile);
+ }
+ }
+
+ super.writeArtifact(artifact);
+ }
+
+ protected File generateSourceArtifact(String artifactId) throws ConverterException {
+ final File frameworksDirectory = new File(rootSourceDirectory, "frameworks");
+ final File librarySrcRootPath = new File(frameworksDirectory, "projects/" + artifactId);
+ final File librarySourcePath = new File(librarySrcRootPath, "src");
+
+ if (librarySourcePath.listFiles() != null) {
+ final File sourceFiles[] = librarySourcePath.listFiles();
+ if (sourceFiles != null) {
+ final File zipInputFiles[] = new File[sourceFiles.length + 1];
+ System.arraycopy(sourceFiles, 0, zipInputFiles, 0, sourceFiles.length);
+
+ try {
+ // Create a temp file.
+ final File targetFile = File.createTempFile("temp-" + artifactId, "zip");
+
+ JarOutputStream jar = new JarOutputStream(new FileOutputStream(targetFile));
+ for (final File file : zipInputFiles) {
+ addFileToZip(jar, file, librarySourcePath);
+ }
+ jar.close();
+
+ return targetFile;
+ } catch(IOException e) {
+ throw new ConverterException("Error creating source archive.", e);
+ }
+ }
+ }
+ return null;
+ }
+
+ protected void generateFrameworkConfigurationArtifact() throws ConverterException {
+ // ZIP up every file (not directory) in the framework directory and the entire themes directory.
+ final File frameworksDirectory = new File(rootSourceDirectory, "frameworks");
+ final File sourceFiles[] = frameworksDirectory.listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ return pathname.isFile();
+ }
+ });
+ final File zipInputFiles[] = new File[sourceFiles.length];
+ System.arraycopy(sourceFiles, 0, zipInputFiles, 0, sourceFiles.length);
+
+ try {
+ final File targetFile = new File(rootTargetDirectory,
+ "org.apache.flex.framework.framework.".replace(".", File.separator) + flexSdkVersion +
+ File.separator + "framework-" + flexSdkVersion + "-configs.zip");
+
+ // Add all the content to a zip-file.
+ final ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(targetFile));
+ for (final File file : zipInputFiles) {
+ addFileToZip(zipOutputStream, file, frameworksDirectory);
+ }
+ zipOutputStream.close();
+ } catch(IOException e) {
+ throw new ConverterException("Error generating configuration zip.", e);
+ }
+ }
+
+ protected void generateDefaultThemeArtifacts(File themesDirectory) throws ConverterException {
+ final File[] themes = themesDirectory.listFiles();
+ if(themes != null) {
+ for(final File themeDirectory : themes) {
+ if(themeDirectory.isDirectory()) {
+ final String themeName = themeDirectory.getName().toLowerCase();
+ final File themeFile = new File(themeDirectory, themeName + ".swc");
+
+ File targetSwcFile = null;
+ if(themeFile.exists()) {
+ targetSwcFile = themeFile;
+ } else {
+ targetSwcFile = generateThemeSwc(themeDirectory);
+ }
+
+ if(targetSwcFile != null) {
+ // Generate the pom file.
+ final MavenArtifact themeArtifact = new MavenArtifact();
+ themeArtifact.setGroupId("org.apache.flex.framework.themes");
+ themeArtifact.setArtifactId(themeName);
+ themeArtifact.setVersion(flexSdkVersion);
+ themeArtifact.setPackaging("swc");
+ themeArtifact.addDefaultBinaryArtifact(targetSwcFile);
+
+ // In this case we don't want the resources to be copied.
+ super.writeArtifact(themeArtifact);
+ }
+ }
+ }
+ }
+ }
+
+ protected void generateMxFteThemeArtifact(File themeCssFile) throws ConverterException {
+ final String themeName = "mxfte";
+
+ // Generate and Copy the SWC.
+ final File targetSwcFile = generateThemeSwc(themeCssFile);
+
+ if(targetSwcFile != null) {
+ // Generate the pom file.
+ final MavenArtifact themeArtifact = new MavenArtifact();
+ themeArtifact.setGroupId("org.apache.flex.framework.themes");
+ themeArtifact.setArtifactId(themeName);
+ themeArtifact.setVersion(flexSdkVersion);
+ themeArtifact.setPackaging("swc");
+ themeArtifact.addDefaultBinaryArtifact(targetSwcFile);
+
+ // In this case we don't want the resources to be copied.
+ super.writeArtifact(themeArtifact);
+ }
+ }
+
+ protected File generateThemeSwc(File themeDirectory) throws ConverterException {
+ final File fdkLibDir = new File(rootSourceDirectory, "lib");
+
+ List<String> processCmd = new ArrayList<String>(10);
+
+ if(fdkLibDir.exists() && fdkLibDir.isDirectory()) {
+ try {
+ final File compcLibrary = new File(fdkLibDir, "compc.jar");
+ final File frameworkDir = new File(rootSourceDirectory, "frameworks");
+
+ processCmd.add("java");
+ processCmd.add("-Xmx384m");
+ processCmd.add("-Dsun.io.useCanonCaches=false");
+ processCmd.add("-jar");
+ processCmd.add(compcLibrary.getCanonicalPath());
+ processCmd.add("+flexlib=" + frameworkDir.getCanonicalPath());
+
+ if (themeDirectory.isDirectory()) {
+ // Add all the content files.
+ final File contents[] = themeDirectory.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(File pathname) {
+ return !(pathname.isDirectory() && "src".equals(pathname.getName())) &&
+ !"preview.jpg".equals(pathname.getName()) && !pathname.getName().endsWith(".fla");
+ }
+ });
+ if (contents.length == 0) {
+ return null;
+ }
+
+ for (final File resource : contents) {
+ processCmd.add("-include-file");
+ processCmd.add(resource.getName());
+ processCmd.add(resource.getCanonicalPath());
+ }
+ } else {
+ processCmd.add("-include-file");
+ processCmd.add(themeDirectory.getName());
+ processCmd.add(themeDirectory.getCanonicalPath());
+ }
+
+ // Create a temp file.
+ final File targetFile = File.createTempFile(themeDirectory.getName(), "swc");
+
+ // Define the output file.
+ processCmd.add("-o");
+ processCmd.add(targetFile.getCanonicalPath());
+
+ final File targetDirectory = targetFile.getParentFile();
+ if (!targetDirectory.exists()) {
+ if (!targetDirectory.mkdirs()) {
+ throw new RuntimeException("Could not create directory: " + targetDirectory.getCanonicalPath());
+ }
+ }
+
+ // Execute the command.
+ try {
+ System.out.println("Generating theme '" + themeDirectory.getName() + "'");
+
+ //final Process child = Runtime.getRuntime().exec(cmd.toString(), envps);
+ ProcessBuilder processBuilder = new ProcessBuilder(processCmd);
+ processBuilder.environment().put("PLAYERGLOBAL_HOME",
+ new File(new File(frameworkDir, "libs"), "player").getCanonicalPath());
+ int exitValue = exec(processBuilder.start());
+ if (exitValue != 0) {
+ System.out.println("Couldn't create theme swc");
+ System.out.println("----------------------------------------------------------------");
+ System.out.println("Env: '" + processBuilder.environment().get("PLAYERGLOBAL_HOME") + "'");
+ System.out.println(processBuilder.command());
+ System.out.println("----------------------------------------------------------------");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Return a reference on the theme swc.
+ return targetFile;
+ } catch(IOException e) {
+ throw new ConverterException("Error generating theme swc.", e);
+ }
+ }
+ return null;
+ }
+
+ protected int exec(Process p) throws InterruptedException, IOException {
+ String line;
+ BufferedReader bri = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ BufferedReader bre = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ while ((line = bri.readLine()) != null) {
+ System.out.println(line);
+ }
+ while ((line = bre.readLine()) != null) {
+ System.out.println(line);
+ }
+ int result = p.waitFor();
+ bri.close();
+ bre.close();
+ System.out.println("Done.");
+ return result;
+ }
+
+ private void addFileToZip(ZipOutputStream zipOutputStream, File inputFile, File rootDirectory)
+ throws ConverterException {
+ if (inputFile == null) {
+ return;
+ }
+
+ // If this is a directory, add all it's children.
+ if (inputFile.isDirectory()) {
+ final File directoryContent[] = inputFile.listFiles();
+ if (directoryContent != null) {
+ for (final File file : directoryContent) {
+ addFileToZip(zipOutputStream, file, rootDirectory);
+ }
+ }
+ }
+ // If this is a file, add it to the zips output.
+ else {
+ byte[] buf = new byte[1024];
+ try {
+ final FileInputStream in = new FileInputStream(inputFile);
+ final String zipPath = inputFile.getAbsolutePath().substring(
+ rootDirectory.getAbsolutePath().length() + 1).replace("\\", "/");
+ zipOutputStream.putNextEntry(new ZipEntry(zipPath));
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ zipOutputStream.write(buf, 0, len);
+ }
+ zipOutputStream.closeEntry();
+ in.close();
+ } catch(IOException e) {
+ throw new ConverterException("Error adding files to zip.", e);
+ }
+ }
+ }
+
+ /**
+ * Get the version of an Flex SDK from the content of the SDK directory.
+ *
+ * @return version string for the current Flex SDK
+ */
+ protected String getFlexVersion(File rootDirectory) throws ConverterException {
+ final File sdkDescriptor = new File(rootDirectory, "flex-sdk-description.xml");
+
+ final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ try {
+ // Parse the document
+ final DocumentBuilder db = dbf.newDocumentBuilder();
+ final Document dom = db.parse(sdkDescriptor);
+
+ // Get name, version and build nodes
+ final Element root = dom.getDocumentElement();
+ final String version = root.getElementsByTagName("version").item(0).getTextContent();
+ final String build = root.getElementsByTagName("build").item(0).getTextContent();
+
+ // In general the version consists of the content of the version element with an appended build-number.
+ return (build.equals("0")) ? version + "-SNAPSHOT" : version + "." + build;
+ } catch (ParserConfigurationException pce) {
+ throw new RuntimeException(pce);
+ } catch (SAXException se) {
+ throw new RuntimeException(se);
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe);
+ }
+ }
+
+ protected File getRsl(String artifactId) {
+ final FlexRslFilter filter = new FlexRslFilter(artifactId, flexSdkVersion);
+ final File rslDirectory = new File(rootSourceDirectory, "frameworks" + File.separator + "rsls");
+ final File[] rsls = rslDirectory.listFiles(filter);
+ if ((rsls != null) && (rsls.length == 1)) {
+ return rsls[0];
+ }
+ return null;
+ }
+
+ protected File getSignedRsl(String artifactId) {
+ final FlexSignedRslFilter filter = new FlexSignedRslFilter(artifactId, flexSdkVersion);
+ final File rslDirectory = new File(rootSourceDirectory, "frameworks" + File.separator + "rsls");
+ final File[] swzs = rslDirectory.listFiles(filter);
+ if ((swzs != null) && (swzs.length == 1)) {
+ return swzs[0];
+ }
+ return null;
+ }
+
+ protected Map<String, File> getResourceBundles(String artifactId) {
+ final Map<String, File> bundles = new HashMap<String, File>();
+ final FlexResourceBundleFilter filter = new FlexResourceBundleFilter(artifactId);
+ final File[] languages = new File(rootSourceDirectory, "frameworks" + File.separator + "locale").listFiles();
+ if(languages != null) {
+ for (final File language : languages) {
+ final File[] resources = language.listFiles(filter);
+ if ((resources != null) && (resources.length == 1)) {
+ bundles.put(language.getName(), resources[0]);
+ }
+ }
+ }
+ return bundles;
+ }
+
+ public static class FlexCompilerFilter implements FilenameFilter {
+ private AirConverter.AirCompilerFilter airFilter = new AirConverter.AirCompilerFilter();
+
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jar") && !airFilter.accept(dir, name) &&
+ // Some old AIR SDKs contained two android libs in the main lib directory,
+ // we have to manually exclude them.
+ !name.equals("smali.jar") && !name.equals("baksmali.jar");
+ }
+ }
+
+ public static class FlexFrameworkFilter implements FilenameFilter {
+ private AirConverter.AirFrameworkFilter airFilter = new AirConverter.AirFrameworkFilter();
+ private FlashConverter.FlashFrameworkFilter flashFilter = new FlashConverter.FlashFrameworkFilter();
+
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".swc") && !airFilter.accept(dir, name) && !flashFilter.accept(dir, name);
+ }
+ }
+
+ public static class FlexRslFilter implements FilenameFilter {
+ private String fileName;
+
+ public FlexRslFilter(String artifactName, String artifactVersion) {
+ this.fileName = artifactName + "_" + artifactVersion + ".swf";
+ }
+
+ public boolean accept(File dir, String name) {
+ return name.equals(fileName);
+ }
+ }
+
+ public static class FlexSignedRslFilter implements FilenameFilter {
+ private String fileName;
+
+ public FlexSignedRslFilter(String artifactName, String artifactVersion) {
+ this.fileName = artifactName + "_" + artifactVersion + ".swz";
+ }
+
+ public boolean accept(File dir, String name) {
+ return name.equals(fileName);
+ }
+ }
+
+ public static class FlexResourceBundleFilter implements FilenameFilter {
+ private String fileName;
+
+ public FlexResourceBundleFilter(String artifactName) {
+ this.fileName = artifactName + "_rb.swc";
+ }
+
+ public boolean accept(File dir, String name) {
+ return name.equals(fileName);
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ FlexConverter converter = new FlexConverter(new File(args[0]), new File(args[1]));
+ converter.convert();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/converters/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/converters/pom.xml b/mavenizer/converters/pom.xml
new file mode 100644
index 0000000..41847d8
--- /dev/null
+++ b/mavenizer/converters/pom.xml
@@ -0,0 +1,45 @@
+<?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.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>converters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <modules>
+ <!-- Module defining all the base functionality shared among the other converters -->
+ <module>base</module>
+
+ <!-- The individual converter implementations -->
+ <module>air</module>
+ <module>flash</module>
+ <module>flex</module>
+ </modules>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/deployers/aether/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/deployers/aether/pom.xml b/mavenizer/deployers/aether/pom.xml
new file mode 100644
index 0000000..3f0d3db
--- /dev/null
+++ b/mavenizer/deployers/aether/pom.xml
@@ -0,0 +1,35 @@
+<?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>deployers</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>aether-deployer</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/deployers/maven/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/deployers/maven/pom.xml b/mavenizer/deployers/maven/pom.xml
new file mode 100644
index 0000000..ae85598
--- /dev/null
+++ b/mavenizer/deployers/maven/pom.xml
@@ -0,0 +1,35 @@
+<?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>deployers</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>maven-deployer</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/deployers/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/deployers/pom.xml b/mavenizer/deployers/pom.xml
new file mode 100644
index 0000000..3c821dc
--- /dev/null
+++ b/mavenizer/deployers/pom.xml
@@ -0,0 +1,40 @@
+<?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.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>deployers</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>maven</module>
+ <module>aether</module>
+ </modules>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/pom.xml b/mavenizer/pom.xml
index 77f19e9..e70008c 100644
--- a/mavenizer/pom.xml
+++ b/mavenizer/pom.xml
@@ -25,6 +25,7 @@
<groupId>org.apache.flex.utilities.converter</groupId>
<artifactId>flex-sdk-converter</artifactId>
<version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
<properties>
<mavenVersion>3.1.0</mavenVersion>
@@ -47,6 +48,11 @@
</developer>
</developers>
+ <modules>
+ <module>converters</module>
+ <module>deployers</module>
+ </modules>
+
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
[02/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Split up the Mavenizer Logic into 3 parts:
AirConverter, FlashConverter and FlexConverter -
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Split up the Mavenizer Logic into 3 parts: AirConverter, FlashConverter and FlexConverter
- Each converter is located in a dedicated Maven module while shared logic is located in a base-converter module.
- Code generation code has been dramatically cleaned up.
- The Flex modules no longer reference runtime artifacts
- The Flash converter generates an Apache dummy module for each Flashplayer version.
- Removed the Dependency-Version poms and included the dependencyManagement into the pom artifacts.
- Attached the resource-bundle dependencies to the swc artifacts directly instead of referencing both from a pom-artifact.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/5fc9d25c
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/5fc9d25c
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/5fc9d25c
Branch: refs/heads/develop
Commit: 5fc9d25cbf8b315c574710919f8f23493d1362ce
Parents: c11e18a
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sun May 11 20:10:37 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sun May 11 20:10:37 2014 +0200
----------------------------------------------------------------------
mavenizer/converters/air/pom.xml | 43 ++
.../utilities/converter/air/AirConverter.java | 210 +++++++
mavenizer/converters/base/pom.xml | 35 ++
.../flex/utilities/converter/BaseConverter.java | 486 +++++++++++++++
.../flex/utilities/converter/Converter.java | 14 +
.../exceptions/ConverterException.java | 16 +
.../converter/model/MavenArtifact.java | 152 +++++
mavenizer/converters/flash/pom.xml | 43 ++
.../converter/flash/FlashConverter.java | 262 ++++++++
mavenizer/converters/flex/pom.xml | 56 ++
.../utilities/converter/flex/FlexConverter.java | 617 +++++++++++++++++++
mavenizer/converters/pom.xml | 45 ++
mavenizer/deployers/aether/pom.xml | 35 ++
mavenizer/deployers/maven/pom.xml | 35 ++
mavenizer/deployers/pom.xml | 40 ++
mavenizer/pom.xml | 6 +
16 files changed, 2095 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/converters/air/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/converters/air/pom.xml b/mavenizer/converters/air/pom.xml
new file mode 100644
index 0000000..c3021c5
--- /dev/null
+++ b/mavenizer/converters/air/pom.xml
@@ -0,0 +1,43 @@
+<?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>converters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>air-converter</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.flex.utilities.converter</groupId>
+ <artifactId>base-converter</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java b/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
new file mode 100644
index 0000000..6212b8b
--- /dev/null
+++ b/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
@@ -0,0 +1,210 @@
+package org.apache.flex.utilities.converter.air;
+
+import org.apache.flex.utilities.converter.BaseConverter;
+import org.apache.flex.utilities.converter.Converter;
+import org.apache.flex.utilities.converter.exceptions.ConverterException;
+import org.apache.flex.utilities.converter.model.MavenArtifact;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Created by cdutz on 22.04.2014.
+ */
+public class AirConverter extends BaseConverter implements Converter {
+
+ protected String airSdkVersion;
+
+ /**
+ * @param rootSourceDirectory Path to the root of the original AIR SDK.
+ * @param rootTargetDirectory Path to the root of the directory where the Maven artifacts should be generated to.
+ * @throws ConverterException
+ */
+ public AirConverter(File rootSourceDirectory, File rootTargetDirectory) throws ConverterException {
+ super(rootSourceDirectory, rootTargetDirectory);
+
+ // Get the version of the current air sdk.
+ this.airSdkVersion = getAirVersion(rootSourceDirectory);
+ }
+
+ /**
+ * Entry point for generating the Maven artifacts for an AIR SDK.
+ *
+ * @throws ConverterException
+ */
+ @Override
+ protected void processDirectory() throws ConverterException {
+ if(!rootSourceDirectory.exists() || !rootSourceDirectory.isDirectory()) {
+ throw new ConverterException("Air SDK directory '" + rootSourceDirectory.getPath() + "' is invalid.");
+ }
+
+ generateCompilerArtifacts();
+ generateRuntimeArtifacts();
+ generateFrameworkArtifacts();
+ }
+
+ /**
+ * This method generates those artifacts that resemble the compiler part of the AIR SDK.
+ *
+ * @throws ConverterException
+ */
+ protected void generateCompilerArtifacts() throws ConverterException {
+ // Create the root artifact.
+ final MavenArtifact compiler = new MavenArtifact();
+ compiler.setGroupId("com.adobe.air");
+ compiler.setArtifactId("compiler");
+ compiler.setVersion(airSdkVersion);
+ compiler.setPackaging("pom");
+
+ // Create a list of all libs that should belong to the AIR SDK compiler.
+ final File directory = new File(rootSourceDirectory, "lib");
+ if(!directory.exists() || !directory.isDirectory()) {
+ throw new ConverterException("Compiler directory does not exist.");
+ }
+ final List<File> files = new ArrayList<File>();
+ files.addAll(Arrays.asList(directory.listFiles(new AirCompilerFilter())));
+
+ // Generate artifacts for every jar in the input directories.
+ for(final File sourceFile : files) {
+ final MavenArtifact artifact = resolveArtifact(sourceFile, "com.adobe.air.compiler", airSdkVersion);
+ compiler.addDependency(artifact);
+ }
+
+ // Write this artifact to file.
+ writeArtifact(compiler);
+ }
+
+ /**
+ * This method generates those artifacts that resemble the runtime part of the AIR SDK.
+ *
+ * @throws ConverterException
+ */
+ protected void generateRuntimeArtifacts() throws ConverterException {
+ // Create the root artifact.
+ final MavenArtifact runtime = new MavenArtifact();
+ runtime.setGroupId("com.adobe.air");
+ runtime.setArtifactId("runtime");
+ runtime.setVersion(airSdkVersion);
+ runtime.setPackaging("pom");
+
+ // Create a list of all libs that should belong to the AIR SDK runtime.
+ final File directory = new File(rootSourceDirectory, "bin");
+ if(!directory.exists() || !directory.isDirectory()) {
+ throw new ConverterException("Runtime directory does not exist.");
+ }
+ final List<File> files = new ArrayList<File>();
+ files.addAll(Arrays.asList(directory.listFiles(new AirRuntimeFilter())));
+
+ // Generate artifacts for every jar in the input directories.
+ for(final File sourceFile : files) {
+ final MavenArtifact artifact = resolveArtifact(sourceFile, "com.adobe.air.runtime", airSdkVersion);
+ runtime.addDependency(artifact);
+ }
+
+ // Write this artifact to file.
+ writeArtifact(runtime);
+ }
+
+ /**
+ * This method generates those artifacts that resemble the framework part of the AIR SDK.
+ *
+ * @throws ConverterException
+ */
+ protected void generateFrameworkArtifacts() throws ConverterException {
+ // Create the root artifact.
+ final MavenArtifact framework = new MavenArtifact();
+ framework.setGroupId("com.adobe.air");
+ framework.setArtifactId("framework");
+ framework.setVersion(airSdkVersion);
+ framework.setPackaging("pom");
+
+ // Create a list of all libs that should belong to the AIR SDK framework.
+ final File directory =
+ new File(rootSourceDirectory, "frameworks" + File.separator + "libs" + File.separator + "air");
+ if(!directory.exists() || !directory.isDirectory()) {
+ throw new ConverterException("Framework directory does not exist.");
+ }
+ final List<File> files = new ArrayList<File>();
+ files.addAll(Arrays.asList(directory.listFiles(new AirFrameworkFilter())));
+
+ // Generate artifacts for every jar in the input directories.
+ for(final File sourceFile : files) {
+ final MavenArtifact artifact = resolveArtifact(sourceFile, "com.adobe.air.framework", airSdkVersion);
+ framework.addDependency(artifact);
+ }
+
+ // Write this artifact to file.
+ writeArtifact(framework);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Utility methods
+ //
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Get the version of an AIR SDK from the content of the SDK directory.
+ *
+ * @return version string for the current AIR SDK
+ */
+ protected String getAirVersion(File rootDirectory) throws ConverterException {
+ // All AIR SDKs contain a text file "AIR SDK Readme.txt" which contains a
+ // Version string in the first line. Newer SDKs contain an additional "airsdk.xml"
+ // which would be easier to parse, but as all SDKs contain the text-file, we'll
+ // stick to that for now.
+
+ final File sdkDescriptor = new File(rootDirectory, "AIR SDK Readme.txt");
+ if(!sdkDescriptor.exists() || !sdkDescriptor.isFile()) {
+ throw new ConverterException("Air SDK directory '" + rootDirectory.getPath() +
+ "' is missing a the version text-file 'AIR SDK Readme.txt'.");
+ }
+
+ DataInputStream in = null;
+ try {
+ final FileInputStream descriptorInputStream = new FileInputStream(sdkDescriptor);
+ in = new DataInputStream(descriptorInputStream);
+ final BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ final String strLine = br.readLine();
+ return strLine.substring("Adobe AIR ".length(), strLine.indexOf(" ", "Adobe AIR ".length()));
+ } catch (Exception e) {
+ throw new ConverterException("Error getting AIR version.", e);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException ioe) {
+ // Ignore.
+ }
+ }
+ }
+ }
+
+ public static class AirCompilerFilter implements FilenameFilter {
+ public boolean accept(File dir, String name) {
+ return name.equals("adt.jar");
+ }
+ }
+
+ public static class AirRuntimeFilter implements FilenameFilter {
+ public boolean accept(File dir, String name) {
+ return name.equalsIgnoreCase("adl.exe");
+ }
+ }
+
+ public static class AirFrameworkFilter implements FilenameFilter {
+ public boolean accept(File dir, String name) {
+ return name.equals("aircore.swc") || name.equals("airglobal.swc") ||
+ name.equals("applicationupdater.swc") || name.equals("applicationupdater_ui.swc") ||
+ name.equals("servicemonitor.swc");
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ AirConverter converter = new AirConverter(new File(args[0]), new File(args[1]));
+ converter.convert();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/converters/base/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/pom.xml b/mavenizer/converters/base/pom.xml
new file mode 100644
index 0000000..e058961
--- /dev/null
+++ b/mavenizer/converters/base/pom.xml
@@ -0,0 +1,35 @@
+<?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>converters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>base-converter</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
new file mode 100644
index 0000000..8a62f25
--- /dev/null
+++ b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
@@ -0,0 +1,486 @@
+/*
+ * 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;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.WebResource;
+
+import org.apache.flex.utilities.converter.exceptions.ConverterException;
+import org.apache.flex.utilities.converter.model.MavenArtifact;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.codehaus.jettison.json.JSONTokener;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.*;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.*;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: cdutz
+ * Date: 11.05.12
+ * Time: 14:53
+ */
+public abstract class BaseConverter {
+
+ protected static final Map<String, MavenArtifact> checksums = new HashMap<String, MavenArtifact>();
+
+ protected static final String MAVEN_SCHEMA_URI = "http://maven.apache.org/POM/4.0.0";
+ protected static final String MAVEN_CENTRAL_SHA_1_QUERY_URL = "http://search.maven.org/solrsearch/select?rows=20&wt=json&q=1:";
+ // Artifactory: "http://server:port/artifactory/api/search/checksum?repos=libs-release-local&md5=04040c7c184620af0a0a8a3682a75eb7
+ // Nexus: "http://repository.sonatype.org/service/local/data_index?a=04040c7c184620af0a0a8a3682a75eb7"
+
+ protected File rootSourceDirectory;
+ protected File rootTargetDirectory;
+
+ protected BaseConverter(File rootSourceDirectory, File rootTargetDirectory) throws ConverterException {
+ if(rootSourceDirectory == null) {
+ throw new ConverterException("Air SDK directory is null.");
+ }
+ if(rootTargetDirectory == null) {
+ throw new ConverterException("Target directory is null.");
+ }
+
+ this.rootSourceDirectory = rootSourceDirectory;
+ this.rootTargetDirectory = rootTargetDirectory;
+ }
+
+ public void convert() throws ConverterException {
+ if(rootSourceDirectory.isFile()) {
+ processArchive();
+ } else {
+ processDirectory();
+ }
+ }
+
+ abstract protected void processDirectory() throws ConverterException;
+
+ protected void processArchive() throws ConverterException {
+
+ }
+
+ protected String calculateChecksum(File jarFile) throws ConverterException {
+ // Implement the calculation of checksums for a given jar.
+ final MessageDigest digest;
+ try {
+ digest = MessageDigest.getInstance("SHA-1");
+
+ final InputStream is = new FileInputStream(jarFile);
+ final byte[] buffer = new byte[8192];
+ int read;
+ try {
+ while( (read = is.read(buffer)) > 0) {
+ digest.update(buffer, 0, read);
+ }
+ final byte[] md5sum = digest.digest();
+ final BigInteger bigInt = new BigInteger(1, md5sum);
+ return bigInt.toString(16);
+ }
+ catch(IOException e) {
+ throw new RuntimeException("Unable to process file for MD5", e);
+ }
+ finally {
+ try {
+ is.close();
+ }
+ catch(IOException e) {
+ //noinspection ThrowFromFinallyBlock
+ throw new RuntimeException("Unable to close input stream for MD5 calculation", e);
+ }
+ }
+ } catch (NoSuchAlgorithmException e) {
+ throw new ConverterException("Error calculating checksum of file '" + jarFile.getPath() + "'", e);
+ } catch (FileNotFoundException e) {
+ throw new ConverterException("Error calculating checksum of file '" + jarFile.getPath() + "'", e);
+ }
+ }
+
+ protected MavenArtifact lookupMetadataForChecksum(String checksum) throws ConverterException {
+ final String queryUrl = MAVEN_CENTRAL_SHA_1_QUERY_URL + checksum;
+
+ final Client client = Client.create();
+ final WebResource webResource = client.resource(queryUrl);
+ final ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);
+
+ if (response.getStatus() != 200) {
+ throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
+ }
+
+ final String output = response.getEntity(String.class);
+
+ final BufferedReader reader = new BufferedReader(new StringReader(output));
+ final StringBuilder builder = new StringBuilder();
+ try {
+ for (String line; (line = reader.readLine()) != null; ) {
+ builder.append(line).append("\n");
+ }
+ final JSONTokener tokener = new JSONTokener(builder.toString());
+ final JSONObject rootObject = new JSONObject(tokener);
+
+ final JSONObject responseObject = (JSONObject) rootObject.get("response");
+ final int numFound = (Integer) responseObject.get("numFound");
+ if(numFound == 0) {
+ return null;
+ }
+ else if(numFound == 1) {
+ final JSONArray docs = (JSONArray) responseObject.get("docs");
+ final JSONObject firstHit = (JSONObject) docs.get(0);
+
+ final MavenArtifact artifactMetadata = new MavenArtifact();
+ artifactMetadata.setGroupId((String) firstHit.get("g"));
+ artifactMetadata.setArtifactId((String) firstHit.get("a"));
+ artifactMetadata.setVersion((String) firstHit.get("v"));
+ artifactMetadata.setPackaging((String) firstHit.get("p"));
+
+ return artifactMetadata;
+ } else {
+ long newestTimestamp = 0;
+ JSONObject newestVersion = null;
+
+ JSONArray options = (JSONArray) responseObject.get("docs");
+ // if the "groupId" is "batik" then use the newer version.
+ for(int i = 0; i < numFound; i++) {
+ final JSONObject option = (JSONObject) options.get(0);
+ if("batik".equals(option.get("g")) && "batik-dom".equals(option.get("a")) && "jar".equals(option.get("p"))) {
+ final long timestamp = (Long) option.get("timestamp");
+ if(timestamp > newestTimestamp) {
+ newestTimestamp = timestamp;
+ newestVersion = option;
+ }
+ }
+ }
+
+ if(newestVersion != null) {
+ final MavenArtifact artifactMetadata = new MavenArtifact();
+ artifactMetadata.setGroupId((String) newestVersion.get("g"));
+ artifactMetadata.setArtifactId((String) newestVersion.get("a"));
+ artifactMetadata.setVersion((String) newestVersion.get("v"));
+ artifactMetadata.setPackaging((String) newestVersion.get("p"));
+
+ return artifactMetadata;
+ } else {
+ System.out.println("For jar-file with checksum: " + checksum +
+ " more than one result was returned by query: " + queryUrl);
+ }
+ }
+ return null;
+ } catch(IOException e) {
+ throw new ConverterException("Error processing Metadata for checksum: '" + checksum + "'", e);
+ } catch (JSONException e) {
+ throw new ConverterException("Error processing Metadata for checksum: '" + checksum + "'", e);
+ }
+ }
+
+ protected void copyFile(File source, File target) throws ConverterException {
+ try {
+ final File outputDirectory = target.getParentFile();
+ if(!outputDirectory.exists()) {
+ if(!outputDirectory.mkdirs()) {
+ throw new RuntimeException("Could not create directory: " + outputDirectory.getAbsolutePath());
+ }
+ }
+
+ final InputStream in = new FileInputStream(source);
+ final OutputStream out = new FileOutputStream(target);
+
+ final byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0){
+ out.write(buf, 0, len);
+ }
+
+ in.close();
+ out.close();
+ } catch(IOException e) {
+ throw new ConverterException("Error copying file from '" + source.getPath() +
+ "' to '" + target.getPath() + "'", e);
+ }
+ }
+
+ /*protected void appendArtifact(MavenMetadata artifactMetadata, Element dependencies) {
+ final Document doc = dependencies.getOwnerDocument();
+ final Element dependency = doc.createElementNS(MAVEN_SCHEMA_URI, "dependency");
+ dependencies.appendChild(dependency);
+
+ final Element groupId = doc.createElementNS(MAVEN_SCHEMA_URI, "groupId");
+ groupId.setTextContent(artifactMetadata.getGroupId());
+ dependency.appendChild(groupId);
+ final Element artifactId = doc.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
+ artifactId.setTextContent(artifactMetadata.getArtifactId());
+ dependency.appendChild(artifactId);
+ final Element version = doc.createElementNS(MAVEN_SCHEMA_URI, "version");
+ version.setTextContent(artifactMetadata.getVersion());
+ dependency.appendChild(version);
+ if(!artifactMetadata.getPackaging().equals("jar")) {
+ final Element packaging = doc.createElementNS(MAVEN_SCHEMA_URI, "type");
+ packaging.setTextContent(artifactMetadata.getPackaging());
+ dependency.appendChild(packaging);
+ }
+ }*/
+
+ protected void writePomArtifact(MavenArtifact pomData) throws ConverterException {
+ final Document pomDoc = createPomDocument(pomData);
+ final File outputFile = pomData.getPomTargetFile(rootTargetDirectory);
+ writeDocument(pomDoc, outputFile);
+ }
+
+ protected void writeDocument(Document doc, File outputFile) throws ConverterException {
+ final Source source = new DOMSource(doc);
+ final File outputDirectory = outputFile.getParentFile();
+ if(!outputDirectory.exists()) {
+ if(!outputDirectory.mkdirs()) {
+ throw new RuntimeException("Could not create directory: " + outputDirectory.getAbsolutePath());
+ }
+ }
+
+ final Result result = new StreamResult(outputFile);
+
+ final Transformer transformer;
+ try {
+ transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
+ transformer.transform(source, result);
+ } catch (TransformerConfigurationException e) {
+ throw new ConverterException("Error writing xml document.", e);
+ } catch (TransformerException e) {
+ throw new ConverterException("Error writing xml document.", e);
+ }
+ }
+
+ protected Document createPomDocument(final MavenArtifact metadata) throws ConverterException {
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ final DocumentBuilder builder;
+ try {
+ builder = factory.newDocumentBuilder();
+ DOMImplementation domImpl = builder.getDOMImplementation();
+ final Document pom = domImpl.createDocument(MAVEN_SCHEMA_URI, "project", null);
+
+ final Element root = pom.getDocumentElement();
+ final Element modelVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "modelVersion");
+ modelVersion.setTextContent("4.0.0");
+ root.appendChild(modelVersion);
+ final Element groupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
+ groupId.setTextContent(metadata.getGroupId());
+ root.appendChild(groupId);
+ final Element artifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
+ artifactId.setTextContent(metadata.getArtifactId());
+ root.appendChild(artifactId);
+ final Element version = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
+ version.setTextContent(metadata.getVersion());
+ root.appendChild(version);
+ final Element packaging = pom.createElementNS(MAVEN_SCHEMA_URI, "packaging");
+ packaging.setTextContent(metadata.getPackaging());
+ root.appendChild(packaging);
+
+ // Output dependency data.
+ if((metadata.getDependencies() != null) && !metadata.getDependencies().isEmpty()) {
+ final Element dependencies = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencies");
+ root.appendChild(dependencies);
+ final Element dependencyManagement = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencyManagement");
+ final Element dependencyManagementDependencies = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencies");
+ dependencyManagement.appendChild(dependencyManagementDependencies);
+ root.appendChild(dependencyManagement);
+
+ final Map<String, MavenArtifact> dependencyIndex = new HashMap<String, MavenArtifact>();
+ for(final MavenArtifact dependencyMetadata : metadata.getDependencies()) {
+ Element dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
+ dependencies.appendChild(dependency);
+
+ // Generate the normal dependency.
+ Element dependencyGroupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
+ dependencyGroupId.setTextContent(dependencyMetadata.getGroupId());
+ dependency.appendChild(dependencyGroupId);
+ Element dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
+ dependencyArtifactId.setTextContent(dependencyMetadata.getArtifactId());
+ dependency.appendChild(dependencyArtifactId);
+ Element dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
+ dependencyPackaging.setTextContent(dependencyMetadata.getPackaging());
+ dependency.appendChild(dependencyPackaging);
+ if(dependencyMetadata.getClassifier() != null) {
+ final Element dependencyClassifier = pom.createElementNS(MAVEN_SCHEMA_URI, "classifier");
+ dependencyClassifier.setTextContent(dependencyMetadata.getClassifier());
+ dependency.appendChild(dependencyClassifier);
+ }
+
+ // Configure the dependency including version in the dependency management section of the pom.
+ dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
+ dependencyGroupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
+ dependencyGroupId.setTextContent(dependencyMetadata.getGroupId());
+ dependency.appendChild(dependencyGroupId);
+ dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
+ dependencyArtifactId.setTextContent(dependencyMetadata.getArtifactId());
+ dependency.appendChild(dependencyArtifactId);
+ Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
+ dependencyVersion.setTextContent(dependencyMetadata.getVersion());
+ dependency.appendChild(dependencyVersion);
+ dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
+ dependencyPackaging.setTextContent(dependencyMetadata.getPackaging());
+ dependency.appendChild(dependencyPackaging);
+ dependencyManagementDependencies.appendChild(dependency);
+
+ dependencyIndex.put(dependencyMetadata.getArtifactId(), dependencyMetadata);
+ }
+
+ // Output the rb.swc dependencies.
+ if(metadata.getLibrariesWithResourceBundles() != null) {
+ for(final String artifactWithResourceBundle : metadata.getLibrariesWithResourceBundles()) {
+ final MavenArtifact dependencyMetadata = dependencyIndex.get(artifactWithResourceBundle);
+ if(dependencyMetadata != null) {
+ final Element dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
+ dependencies.appendChild(dependency);
+
+ final Element dependencyGroupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
+ dependencyGroupId.setTextContent(dependencyMetadata.getGroupId());
+ dependency.appendChild(dependencyGroupId);
+ final Element dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
+ dependencyArtifactId.setTextContent(dependencyMetadata.getArtifactId());
+ dependency.appendChild(dependencyArtifactId);
+ final Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
+ dependencyVersion.setTextContent(dependencyMetadata.getVersion());
+ dependency.appendChild(dependencyVersion);
+ final Element dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
+ dependencyPackaging.setTextContent("rb.swc");
+ dependency.appendChild(dependencyPackaging);
+ }
+ }
+ }
+ }
+ return pom;
+ } catch (ParserConfigurationException e) {
+ throw new ConverterException("Error creating pom document.", e);
+ }
+ }
+
+ protected void writeDummy(final File targetFile) throws ConverterException {
+ try {
+ final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(targetFile));
+ out.putNextEntry(new ZipEntry("dummy"));
+ out.closeEntry();
+ out.close();
+ } catch (IOException e) {
+ throw new ConverterException("Error generating dummy resouce bundle.");
+ }
+ }
+
+ protected static File findDirectory(File directory, String directoryToFind) {
+ File[] entries = directory.listFiles();
+ File founded = null;
+
+ // Go over entries
+ if(entries != null) {
+ for (File entry : entries) {
+ if (entry.isDirectory() && directoryToFind.equalsIgnoreCase(entry.getName())) {
+ founded = entry;
+ break;
+ }
+ if (entry.isDirectory()) {
+ founded = findDirectory(entry, directoryToFind);
+ if (founded != null)
+ break;
+ }
+ }
+ }
+ return founded;
+ }
+
+ protected MavenArtifact resolveArtifact(File sourceFile, String defaultGroupId, String defaultVersion)
+ throws ConverterException {
+ // Calculate a checksum for the current file. We will use this checksum to query maven central
+ // in order to find out if this lib has already been published. If it has, there is no need to
+ // publish it again under a new name. In case a matching artifact is found the generated FDK
+ // will use the already deployed version. Additionally the checksum will be saved and if a
+ // fdk generated after this one uses the same version of a lib, the version of the older fdk is
+ // used also reducing the amount of jars that have to be re-deployed.
+ final String checksum = calculateChecksum(sourceFile);
+
+ // Try to get artifact metadata based upon the checksum by looking up the internal cache.
+ MavenArtifact artifact = checksums.get(checksum);
+
+ // Reusing artifact from other sdk version.
+ if(artifact != null) {
+ System.out.println("Reusing artifact (" + checksum + ") : " + artifact.getGroupId() + ":" +
+ artifact.getArtifactId() + ":" + artifact.getVersion());
+ return artifact;
+ }
+ // Id no artifact was found in the local cache, continue processing.
+ else {
+ // Do a lookup in maven central.
+ artifact = lookupMetadataForChecksum(checksum);
+
+ // The file was available on maven central, so use that version instead of the one coming with the sdk.
+ if(artifact != null) {
+ System.out.println("Using artifact from Maven Central (" + checksum + ") : " +
+ artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion());
+ }
+ // The file was not available on maven central, so we have to add it manually.
+ else {
+ // The artifact name is the name of the jar.
+ final String artifactFileName = sourceFile.getName();
+ final String dependencyArtifactId = artifactFileName.substring(0, artifactFileName.lastIndexOf("."));
+ final String dependencyArtifactPackaging =
+ artifactFileName.substring(artifactFileName.lastIndexOf(".") + 1);
+
+ // Generate a new metadata object
+ artifact = new MavenArtifact();
+ artifact.setGroupId(defaultGroupId);
+ artifact.setArtifactId(dependencyArtifactId);
+ artifact.setVersion(defaultVersion);
+ artifact.setPackaging(dependencyArtifactPackaging);
+ artifact.addDefaultBinaryArtifact(sourceFile);
+
+ // Create the pom document that will reside next to the artifact lib.
+ writeArtifact(artifact);
+ }
+
+ // Remember the checksum for later re-usage.
+ checksums.put(checksum, artifact);
+
+ return artifact;
+ }
+ }
+
+ protected void writeArtifact(MavenArtifact artifact) throws ConverterException {
+ // Write the pom itself.
+ writePomArtifact(artifact);
+ final List<String> binaryClassifiers = artifact.getBinaryFilesClassifiers();
+ for(final String classifier : binaryClassifiers) {
+ final File binarySourceFile = artifact.getBinarySourceFile(classifier);
+ final File binaryTargetFile = artifact.getBinaryTargetFile(rootTargetDirectory, classifier);
+ copyFile(binarySourceFile, binaryTargetFile);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/Converter.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/Converter.java b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/Converter.java
new file mode 100644
index 0000000..0f94155
--- /dev/null
+++ b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/Converter.java
@@ -0,0 +1,14 @@
+package org.apache.flex.utilities.converter;
+
+import org.apache.flex.utilities.converter.exceptions.ConverterException;
+
+import java.io.File;
+
+/**
+ * Created by cdutz on 18.04.2014.
+ */
+public interface Converter {
+
+ void convert() throws ConverterException;
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/exceptions/ConverterException.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/exceptions/ConverterException.java b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/exceptions/ConverterException.java
new file mode 100644
index 0000000..3a0b7c6
--- /dev/null
+++ b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/exceptions/ConverterException.java
@@ -0,0 +1,16 @@
+package org.apache.flex.utilities.converter.exceptions;
+
+/**
+ * Created by cdutz on 07.05.2014.
+ */
+public class ConverterException extends Exception {
+
+ public ConverterException(String message) {
+ super(message);
+ }
+
+ public ConverterException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java
new file mode 100644
index 0000000..0dca36c
--- /dev/null
+++ b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java
@@ -0,0 +1,152 @@
+/*
+ * 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.model;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: cdutz
+ * Date: 01.07.12
+ * Time: 12:31
+ */
+public class MavenArtifact {
+
+ public static final String DEFAULT_CLASSIFIER = "default";
+
+ protected String groupId;
+ protected String artifactId;
+ protected String version;
+ protected String packaging = "pom";
+ protected String classifier;
+ protected List<String> librariesWithResourceBundles;
+
+ protected List<MavenArtifact> dependencies;
+
+ protected Map<String, File> binaryArtifacts;
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ public void setArtifactId(String artifactId) {
+ this.artifactId = artifactId;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getPackaging() {
+ return packaging;
+ }
+
+ public void setPackaging(String packaging) {
+ this.packaging = packaging;
+ }
+
+ public String getClassifier() {
+ return classifier;
+ }
+
+ public void setClassifier(String classifier) {
+ this.classifier = classifier;
+ }
+
+ public List<String> getLibrariesWithResourceBundles() {
+ return librariesWithResourceBundles;
+ }
+
+ public void setLibrariesWithResourceBundles(List<String> librariesWithResourceBundles) {
+ this.librariesWithResourceBundles = librariesWithResourceBundles;
+ }
+
+ public List<MavenArtifact> getDependencies() {
+ return dependencies;
+ }
+
+ public void setDependencies(List<MavenArtifact> dependencies) {
+ this.dependencies = dependencies;
+ }
+
+ public void addDependency(MavenArtifact dependency) {
+ if(dependencies == null) {
+ dependencies = new ArrayList<MavenArtifact>();
+ }
+ dependencies.add(dependency);
+ }
+
+ public void addDefaultBinaryArtifact(File binaryArtifact) {
+ addBinaryArtifact(DEFAULT_CLASSIFIER, binaryArtifact);
+ }
+
+ public void addBinaryArtifact(String classifier, File binaryArtifact) {
+ if(binaryArtifacts == null) {
+ binaryArtifacts = new HashMap<String, File>();
+ }
+ binaryArtifacts.put(classifier, binaryArtifact);
+ }
+
+ public File getPomTargetFile(File targetRootDirectory) {
+ final String fileName = groupId.replace(".", File.separator) + File.separator + artifactId + File.separator +
+ version + File.separator + artifactId + "-" + version + ((classifier != null) ? "-" + classifier : "") +
+ ".pom";
+ return new File(targetRootDirectory, fileName);
+ }
+
+ public List<String> getBinaryFilesClassifiers() {
+ final List<String> classifiers = new ArrayList<String>();
+ if(binaryArtifacts != null) {
+ classifiers.addAll(binaryArtifacts.keySet());
+ }
+ return classifiers;
+ }
+
+ public File getBinarySourceFile(String classifier) {
+ if((binaryArtifacts != null) && (binaryArtifacts.containsKey(classifier))) {
+ return binaryArtifacts.get(classifier);
+ }
+ return null;
+ }
+
+ public File getBinaryTargetFile(File targetRootDirectory, String classifier) {
+ if((binaryArtifacts != null) && (binaryArtifacts.containsKey(classifier))) {
+ final String fileName = groupId.replace(".", File.separator) + File.separator + artifactId + File.separator +
+ version + File.separator + artifactId + "-" + version +
+ (DEFAULT_CLASSIFIER.equals(classifier) ? "" : "-" + classifier) + "." + packaging;
+ return new File(targetRootDirectory, fileName);
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/converters/flash/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/converters/flash/pom.xml b/mavenizer/converters/flash/pom.xml
new file mode 100644
index 0000000..d231261
--- /dev/null
+++ b/mavenizer/converters/flash/pom.xml
@@ -0,0 +1,43 @@
+<?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>converters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>flash-converter</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.flex.utilities.converter</groupId>
+ <artifactId>base-converter</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/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
new file mode 100644
index 0000000..6ff5462
--- /dev/null
+++ b/mavenizer/converters/flash/src/main/java/org/apache/flex/utilities/converter/flash/FlashConverter.java
@@ -0,0 +1,262 @@
+package org.apache.flex.utilities.converter.flash;
+
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
+import org.apache.flex.utilities.converter.BaseConverter;
+import org.apache.flex.utilities.converter.Converter;
+import org.apache.flex.utilities.converter.exceptions.ConverterException;
+import org.apache.flex.utilities.converter.model.MavenArtifact;
+
+import java.io.*;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * Created by cdutz on 22.04.2014.
+ */
+public class FlashConverter extends BaseConverter implements Converter {
+
+ /**
+ * @param rootSourceDirectory Path to the root of the original Flash SDK.
+ * @param rootTargetDirectory Path to the root of the directory where the Maven artifacts should be generated to.
+ * @throws org.apache.flex.utilities.converter.exceptions.ConverterException
+ */
+ public FlashConverter(File rootSourceDirectory, File rootTargetDirectory) throws ConverterException {
+ super(rootSourceDirectory, rootTargetDirectory);
+ }
+
+ /**
+ * Entry point for generating the Maven artifacts for an Flash SDK.
+ *
+ * @throws ConverterException
+ */
+ @Override
+ protected void processDirectory() throws ConverterException {
+ if(!rootSourceDirectory.exists() || !rootSourceDirectory.isDirectory()) {
+ throw new ConverterException("Flash SDK directory '" + rootSourceDirectory.getPath() + "' is invalid.");
+ }
+
+ generateRuntimeArtifacts();
+ generateFrameworkArtifacts();
+ }
+
+ /**
+ * This method generates those artifacts that resemble the runtime part of the Flash SDK.
+ *
+ * @throws ConverterException
+ */
+ protected void generateRuntimeArtifacts() throws ConverterException {
+ // 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.");
+ }
+ final List<File> playerVersions = new ArrayList<File>();
+ playerVersions.addAll(Arrays.asList(directory.listFiles(new FlashRuntimeFilter())));
+
+ // In really old SDKs the flash-player was installed in the players directory directly.
+ if(new File(directory, "win").exists()) {
+ playerVersions.add(directory);
+ }
+
+ // Generate artifacts for every jar in the input directories.
+ for(final File versionDir : playerVersions) {
+ // The flash-player 9 is installed directly in the player directory.
+ String playerVersionString;
+ if(versionDir == directory) {
+ playerVersionString = "9.0";
+ } else {
+ playerVersionString = versionDir.getName();
+ }
+
+ final double playerVersion = Double.valueOf(playerVersionString);
+ final NumberFormat doubleFormat = NumberFormat.getInstance(Locale.US);
+ doubleFormat.setMinimumFractionDigits(1);
+ doubleFormat.setMaximumFractionDigits(1);
+ final String version = doubleFormat.format(playerVersion);
+
+ final MavenArtifact playerArtifact = new MavenArtifact();
+ playerArtifact.setGroupId("com.adobe.flash");
+ playerArtifact.setArtifactId("runtime");
+ playerArtifact.setVersion(version);
+ playerArtifact.setPackaging("exe");
+
+ // Deploy Windows binaries.
+ final File windowsDirectory = new File(versionDir, "win");
+ if(windowsDirectory.exists()) {
+ // Find out if a flash-player binary exists.
+ File flashPlayerBinary = null;
+ if(new File(windowsDirectory, "FlashPlayerDebugger.exe").exists()) {
+ flashPlayerBinary = new File(windowsDirectory, "FlashPlayerDebugger.exe");
+ } else if(new File(windowsDirectory, "FlashPlayer.exe").exists()) {
+ flashPlayerBinary = new File(windowsDirectory, "FlashPlayer.exe");
+ }
+
+ // If a binary exists, copy it to the target and create a pom for it.
+ if (flashPlayerBinary != null) {
+ playerArtifact.addBinaryArtifact("win", flashPlayerBinary);
+ }
+ }
+
+ // Deploy Mac binaries.
+ final File macDirectory = new File(versionDir, "mac");
+ if(macDirectory.exists()) {
+ // Find out if a flash-player binary exists.
+ File flashPlayerBinary = null;
+ if(new File(macDirectory, "Flash Player.app.zip").exists()) {
+ flashPlayerBinary = new File(macDirectory, "Flash Player.app.zip");
+ } else if(new File(macDirectory, "Flash Player Debugger.app.zip").exists()) {
+ flashPlayerBinary = new File(macDirectory, "Flash Player Debugger.app.zip");
+ }
+
+ // If a binary exists, copy it to the target and create a pom for it.
+ if (flashPlayerBinary != null) {
+ playerArtifact.addBinaryArtifact("mac", flashPlayerBinary);
+ }
+ }
+
+ // Deploy Linux binaries.
+ final File lnxDirectory = new File(versionDir, "lnx");
+ if(lnxDirectory.exists()) {
+ // Find out if a flash-player binary exists.
+ File flashPlayerBinary;
+ if(new File(lnxDirectory, "flashplayer.tar.gz").exists()) {
+ flashPlayerBinary = new File(lnxDirectory, "flashplayer.tar.gz");
+ } else if(new File(lnxDirectory, "flashplayerdebugger.tar.gz").exists()) {
+ flashPlayerBinary = new File(lnxDirectory, "flashplayerdebugger.tar.gz");
+ } else {
+ throw new ConverterException("Couldn't find player archive.");
+ }
+
+ // Decompress the archive.
+ // First unzip it.
+ final FileInputStream fin;
+ try {
+ fin = new FileInputStream(flashPlayerBinary);
+ final BufferedInputStream in = new BufferedInputStream(fin);
+ final File tempTarFile = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".tar");
+ final FileOutputStream out = new FileOutputStream(tempTarFile);
+ final GzipCompressorInputStream gzIn = new GzipCompressorInputStream(in);
+ final byte[] buffer = new byte[1024];
+ int n;
+ while (-1 != (n = gzIn.read(buffer))) {
+ out.write(buffer, 0, n);
+ }
+ out.close();
+ gzIn.close();
+
+ // Then untar it.
+ File uncompressedBinary = null;
+ final FileInputStream tarFileInputStream = new FileInputStream(tempTarFile);
+ final TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(tarFileInputStream);
+ ArchiveEntry entry;
+ while((entry = tarArchiveInputStream.getNextEntry()) != null) {
+ if("flashplayer".equals(entry.getName())) {
+ uncompressedBinary = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".uexe");
+ final FileOutputStream uncompressedBinaryOutputStream = new FileOutputStream(uncompressedBinary);
+ while(-1 != (n = tarArchiveInputStream.read(buffer))) {
+ uncompressedBinaryOutputStream.write(buffer, 0, n);
+ }
+ uncompressedBinaryOutputStream.close();
+ } else if("flashplayerdebugger".equals(entry.getName())) {
+ uncompressedBinary = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".uexe");
+ final FileOutputStream uncompressedBinaryOutputStream = new FileOutputStream(uncompressedBinary);
+ while(-1 != (n = tarArchiveInputStream.read(buffer))) {
+ uncompressedBinaryOutputStream.write(buffer, 0, n);
+ }
+ uncompressedBinaryOutputStream.close();
+ }
+ }
+ tarFileInputStream.close();
+
+ // If a binary exists, copy it to the target and create a pom for it.
+ if (uncompressedBinary != null) {
+ playerArtifact.addBinaryArtifact("linux", flashPlayerBinary);
+ }
+ } catch (FileNotFoundException e) {
+ throw new ConverterException("Error processing the linux player tar file", e);
+ } catch (IOException e) {
+ throw new ConverterException("Error processing the linux player tar file", e);
+ }
+ }
+
+ // Write this artifact to file.
+ writeArtifact(playerArtifact);
+ }
+ }
+
+ /**
+ * This method generates those artifacts that resemble the framework part of the Flash SDK.
+ *
+ * @throws ConverterException
+ */
+ protected void generateFrameworkArtifacts() throws ConverterException {
+ // Create a list of all libs that should belong to the Flash SDK runtime.
+ final File directory = new File(rootSourceDirectory, "frameworks.libs.player".replace(".", File.separator));
+ if (!directory.exists() || !directory.isDirectory()) {
+ throw new ConverterException("Runtime directory does not exist.");
+ }
+ final List<File> playerVersions = new ArrayList<File>();
+ final File[] versions = directory.listFiles();
+ if((versions != null) && (versions.length > 0)) {
+ playerVersions.addAll(Arrays.asList(versions));
+
+ // Generate artifacts for every jar in the input directories.
+ for (final File versionDir : playerVersions) {
+ final File playerglobalSwc = new File(versionDir, "playerglobal.swc");
+
+ // Convert any version into a two-segment version number.
+ final double playerVersion = Double.valueOf(versionDir.getName());
+ final NumberFormat doubleFormat = NumberFormat.getInstance(Locale.US);
+ doubleFormat.setMinimumFractionDigits(1);
+ doubleFormat.setMaximumFractionDigits(1);
+ final String version = doubleFormat.format(playerVersion);
+
+ // Create an artifact for the player-global.
+ final MavenArtifact playerglobal = new MavenArtifact();
+ playerglobal.setGroupId("com.adobe.flash.framework");
+ playerglobal.setArtifactId("playerglobal");
+ playerglobal.setVersion(version);
+ playerglobal.setPackaging("swc");
+ playerglobal.addDefaultBinaryArtifact(playerglobalSwc);
+ writeArtifact(playerglobal);
+
+ // Generate dummy pom-artifact which we are allowed to deploy.
+ final MavenArtifact playerglobalDummy = new MavenArtifact();
+ playerglobalDummy.setGroupId("org.apache.flex.runtime");
+ playerglobalDummy.setArtifactId("flashplayer");
+ playerglobalDummy.setVersion(version);
+ writeArtifact(playerglobalDummy);
+ }
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Utility methods
+ //
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public static class FlashRuntimeFilter implements FileFilter {
+ public boolean accept(File pathname) {
+ return pathname.isDirectory() && !"win".equalsIgnoreCase(pathname.getName()) &&
+ !"lnx".equalsIgnoreCase(pathname.getName()) && !"mac".equalsIgnoreCase(pathname.getName());
+ }
+ }
+
+ public static class FlashFrameworkFilter implements FilenameFilter {
+ public boolean accept(File dir, String name) {
+ return name.equals("playerglobal.swc");
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ FlashConverter converter = new FlashConverter(new File(args[0]), new File(args[1]));
+ converter.convert();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5fc9d25c/mavenizer/converters/flex/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/converters/flex/pom.xml b/mavenizer/converters/flex/pom.xml
new file mode 100644
index 0000000..eca8505
--- /dev/null
+++ b/mavenizer/converters/flex/pom.xml
@@ -0,0 +1,56 @@
+<?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>converters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>flex-converter</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.flex.utilities.converter</groupId>
+ <artifactId>base-converter</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <!--
+ Flex usually contains Air and Flash artifacts, so we need to reference them.
+ -->
+ <dependency>
+ <groupId>org.apache.flex.utilities.converter</groupId>
+ <artifactId>air-converter</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.flex.utilities.converter</groupId>
+ <artifactId>flash-converter</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
[12/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Fixed a problem with mavenizing SDKs with mobile
components, but no experimental_mobile
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Fixed a problem with mavenizing SDKs with mobile components, but no experimental_mobile
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/ca5c0977
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/ca5c0977
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/ca5c0977
Branch: refs/heads/develop
Commit: ca5c0977cf4b55758d24a8b7370f39f8647fad28
Parents: 38514b5
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sat May 24 23:58:54 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sat May 24 23:58:54 2014 +0200
----------------------------------------------------------------------
.../apache/flex/utilities/converter/flex/FlexConverter.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ca5c0977/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 e0a2933..1d0709a 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
@@ -153,8 +153,10 @@ public class FlexConverter extends BaseConverter implements Converter {
// add this to the mobile package.
if("mobile".equals(directory.getName())) {
final File mobileExperimental = new File(directory.getParent(), "experimental_mobile.swc");
- final MavenArtifact artifact = resolveArtifact(mobileExperimental, artifactGroupId, flexSdkVersion);
- framework.addDependency(artifact);
+ if(mobileExperimental.exists()) {
+ final MavenArtifact artifact = resolveArtifact(mobileExperimental, artifactGroupId, flexSdkVersion);
+ framework.addDependency(artifact);
+ }
}
// Write this artifact to file.
writeArtifact(framework);
[04/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Started implementing a component for
automatically downloading artifacts - Created the cod
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Started implementing a component for automatically downloading artifacts
- Created the code for automatically extracting the url for an artifact from the "sdk-installer-config-4.0.xml"
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/16a64203
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/16a64203
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/16a64203
Branch: refs/heads/develop
Commit: 16a6420330e4742a5e802742a09fdc254a510002
Parents: 61d38e9
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sun May 18 21:39:57 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sun May 18 21:39:57 2014 +0200
----------------------------------------------------------------------
mavenizer/core/pom.xml | 35 ++++
mavenizer/pom.xml | 17 +-
mavenizer/retrievers/base/pom.xml | 35 ++++
.../converter/retrievers/BaseRetriever.java | 7 +
.../converter/retrievers/Retriever.java | 14 ++
.../exceptions/RetrieverException.java | 32 ++++
.../retrievers/types/PlatformType.java | 12 ++
.../converter/retrievers/types/SdkType.java | 12 ++
mavenizer/retrievers/download/pom.xml | 43 +++++
.../retrievers/download/DownloadRetriever.java | 166 +++++++++++++++++++
mavenizer/retrievers/pom.xml | 40 +++++
11 files changed, 398 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/16a64203/mavenizer/core/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/core/pom.xml b/mavenizer/core/pom.xml
new file mode 100644
index 0000000..d3cc9bf
--- /dev/null
+++ b/mavenizer/core/pom.xml
@@ -0,0 +1,35 @@
+<?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.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>core</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/16a64203/mavenizer/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/pom.xml b/mavenizer/pom.xml
index 21e5fd2..83015db 100644
--- a/mavenizer/pom.xml
+++ b/mavenizer/pom.xml
@@ -33,22 +33,9 @@
<wagonVersion>2.2</wagonVersion>
</properties>
- <developers>
- <developer>
- <id>cdutz</id>
- <name>Christofer Dutz</name>
- </developer>
- <developer>
- <id>fthomas</id>
- <name>Frederic Thomas</name>
- </developer>
- <developer>
- <id>josebarragan</id>
- <name>Jose Barragan</name>
- </developer>
- </developers>
-
<modules>
+ <module>core</module>
+ <module>retrievers</module>
<module>converters</module>
<module>deployers</module>
</modules>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/16a64203/mavenizer/retrievers/base/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/pom.xml b/mavenizer/retrievers/base/pom.xml
new file mode 100644
index 0000000..4a8c74d
--- /dev/null
+++ b/mavenizer/retrievers/base/pom.xml
@@ -0,0 +1,35 @@
+<?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>retrievers</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>base-retriever</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/16a64203/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
new file mode 100644
index 0000000..a0371b6
--- /dev/null
+++ b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/BaseRetriever.java
@@ -0,0 +1,7 @@
+package org.apache.flex.utilities.converter.retrievers;
+
+/**
+ * Created by cdutz on 18.05.2014.
+ */
+public abstract class BaseRetriever implements Retriever {
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/16a64203/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
new file mode 100644
index 0000000..1ce2207
--- /dev/null
+++ b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
@@ -0,0 +1,14 @@
+package org.apache.flex.utilities.converter.retrievers;
+
+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;
+
+/**
+ * Created by cdutz on 18.05.2014.
+ */
+public interface Retriever {
+
+ void retrieve(PlatformType platformType, SDKType sdkType, String version) throws RetrieverException;
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/16a64203/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/exceptions/RetrieverException.java
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/exceptions/RetrieverException.java b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/exceptions/RetrieverException.java
new file mode 100644
index 0000000..bfb708b
--- /dev/null
+++ b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/exceptions/RetrieverException.java
@@ -0,0 +1,32 @@
+/*
+ * 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.exceptions;
+
+/**
+ * Created by cdutz on 07.05.2014.
+ */
+public class RetrieverException extends Exception {
+
+ public RetrieverException(String message) {
+ super(message);
+ }
+
+ public RetrieverException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/16a64203/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/PlatformType.java
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/PlatformType.java b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/PlatformType.java
new file mode 100644
index 0000000..c0694d8
--- /dev/null
+++ b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/PlatformType.java
@@ -0,0 +1,12 @@
+package org.apache.flex.utilities.converter.retrievers.types;
+
+/**
+ * Created by cdutz on 18.05.2014.
+ */
+public enum PlatformType {
+
+ WINDOWS,
+ LINUX,
+ MAC
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/16a64203/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
new file mode 100644
index 0000000..b2ba4df
--- /dev/null
+++ b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
@@ -0,0 +1,12 @@
+package org.apache.flex.utilities.converter.retrievers.types;
+
+/**
+ * Created by cdutz on 18.05.2014.
+ */
+public enum SDKType {
+
+ FLASH,
+ AIR,
+ FLEX
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/16a64203/mavenizer/retrievers/download/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/download/pom.xml b/mavenizer/retrievers/download/pom.xml
new file mode 100644
index 0000000..a566673
--- /dev/null
+++ b/mavenizer/retrievers/download/pom.xml
@@ -0,0 +1,43 @@
+<?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>retrievers</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>download-retriever</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.flex.utilities.converter</groupId>
+ <artifactId>base-retriever</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/16a64203/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
new file mode 100644
index 0000000..bec47d1
--- /dev/null
+++ b/mavenizer/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
@@ -0,0 +1,166 @@
+package org.apache.flex.utilities.converter.retrievers.download;
+
+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.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+import java.io.IOException;
+
+/**
+ * Created by cdutz on 18.05.2014.
+ */
+public class DownloadRetriever extends BaseRetriever {
+
+ public static final String FLEX_INSTALLER_CONFIG_URL =
+ "http://flex.apache.org/installer/sdk-installer-config-4.0.xml";
+
+ @Override
+ public void retrieve(PlatformType platformType, SDKType type, String version) throws RetrieverException {
+ final String url = getBinaryUrl(platformType, type, version);
+ System.out.println(url);
+ }
+
+ protected String getBinaryUrl(PlatformType platformType, SDKType sdkType, String version) throws RetrieverException {
+ try {
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ final DocumentBuilder builder = factory.newDocumentBuilder();
+ final Document doc = builder.parse(FLEX_INSTALLER_CONFIG_URL);
+
+ //Evaluate XPath against Document itself
+ final String expression = getUrlXpath(platformType, sdkType, version);
+ final XPath xPath = XPathFactory.newInstance().newXPath();
+ final Element artifactElement = (Element) xPath.evaluate(
+ expression, doc.getDocumentElement(), XPathConstants.NODE);
+ final StringBuilder stringBuilder = new StringBuilder();
+ if(sdkType == SDKType.FLEX) {
+ final String path = artifactElement.getAttribute("path");
+ final String file = artifactElement.getAttribute("file");
+ if(!path.startsWith("http://")) {
+ stringBuilder.append("http://archive.apache.org/dist/");
+ }
+ stringBuilder.append(path).append(file);
+ } else {
+ final NodeList pathElements = artifactElement.getElementsByTagName("path");
+ final NodeList fileElements = artifactElement.getElementsByTagName("file");
+ if((pathElements.getLength() != 1) && (fileElements.getLength() != 1)) {
+ throw new RetrieverException("Invalid document structure.");
+ }
+ stringBuilder.append(pathElements.item(0).getTextContent());
+ stringBuilder.append(fileElements.item(0).getTextContent());
+ }
+
+ return stringBuilder.toString();
+ } catch(ParserConfigurationException e) {
+ throw new RetrieverException("Error parsing 'sdk-installer-config-4.0.xml'", e);
+ } catch (SAXException e) {
+ throw new RetrieverException("Error parsing 'sdk-installer-config-4.0.xml'", e);
+ } catch (XPathExpressionException e) {
+ throw new RetrieverException("Error parsing 'sdk-installer-config-4.0.xml'", e);
+ } catch (IOException e) {
+ throw new RetrieverException("Error parsing 'sdk-installer-config-4.0.xml'", e);
+ }
+ }
+
+ protected String getUrlXpath(PlatformType platformType, SDKType sdkType, String version) {
+ final StringBuilder stringBuilder = new StringBuilder();
+ switch (sdkType) {
+ case FLEX:
+ stringBuilder.append("//*[@id='").append(version).append("']");
+ break;
+ case AIR:
+ stringBuilder.append("//*[@id='air.sdk.version.");
+ switch (platformType) {
+ case WINDOWS:
+ stringBuilder.append("windows");
+ break;
+ case MAC:
+ stringBuilder.append("mac");
+ break;
+ case LINUX:
+ stringBuilder.append("linux");
+ break;
+
+ }
+ stringBuilder.append(".").append(version).append("']");
+ break;
+ case FLASH:
+ stringBuilder.append("//*[@id='flash.sdk.version.").append(version).append("']");
+ break;
+ }
+ return stringBuilder.toString();
+ }
+
+ public static void main(String[] args) throws Exception {
+ final DownloadRetriever retriever = new DownloadRetriever();
+
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLEX, "4.9.1");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLEX, "4.10.0");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLEX, "4.11.0");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLEX, "4.12.0");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLEX, "4.12.1");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLEX, "Nightly");
+
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "2.6");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "2.6");
+ retriever.retrieve(PlatformType.LINUX, SDKType.AIR, "2.6");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "2.7");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "2.7");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.0");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.0");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.1");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.1");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.2");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.2");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.3");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.3");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.4");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.4");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.5");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.5");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.6");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.6");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.7");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.7");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.8");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.8");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.9");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.9");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "4.0");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "4.0");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "13.0");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "13.0");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "14.0");
+ retriever.retrieve(PlatformType.MAC, SDKType.AIR, "14.0");
+
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "10.2");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "10.3");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.0");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.1");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.2");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.3");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.4");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.5");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.6");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.7");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.8");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.9");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "12.0");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "13.0");
+ retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "14.0");
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/16a64203/mavenizer/retrievers/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/pom.xml b/mavenizer/retrievers/pom.xml
new file mode 100644
index 0000000..30b38d3
--- /dev/null
+++ b/mavenizer/retrievers/pom.xml
@@ -0,0 +1,40 @@
+<?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.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>retrievers</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>base</module>
+ <module>download</module>
+ </modules>
+
+</project>
[05/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Finished the DownloadRetriever to actually be
able to retrieve any FLEX, AIR or FLASH sdk.
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Finished the DownloadRetriever to actually be able to retrieve any FLEX, AIR or FLASH sdk.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/b9ca520e
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/b9ca520e
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/b9ca520e
Branch: refs/heads/develop
Commit: b9ca520e43b2d9b1b28c175ec3c00a1958cc1cde
Parents: 16a6420
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Wed May 21 01:01:03 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Wed May 21 01:01:03 2014 +0200
----------------------------------------------------------------------
.../converter/retrievers/BaseRetriever.java | 16 ++
.../converter/retrievers/Retriever.java | 20 +-
.../retrievers/types/PlatformType.java | 16 ++
.../retrievers/download/DownloadRetriever.java | 219 +++++++++++++------
4 files changed, 202 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b9ca520e/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 a0371b6..8477a0f 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
@@ -1,3 +1,19 @@
+/*
+ * 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;
/**
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b9ca520e/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
index 1ce2207..f38af43 100644
--- a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
+++ b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
@@ -1,14 +1,32 @@
+/*
+ * 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;
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 java.io.File;
+
/**
* Created by cdutz on 18.05.2014.
*/
public interface Retriever {
- void retrieve(PlatformType platformType, SDKType sdkType, String version) throws RetrieverException;
+ File retrieve(SDKType sdkType, String version, PlatformType platformType) throws RetrieverException;
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b9ca520e/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/PlatformType.java
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/PlatformType.java b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/PlatformType.java
index c0694d8..b5cf83f 100644
--- a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/PlatformType.java
+++ b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/PlatformType.java
@@ -1,3 +1,19 @@
+/*
+ * 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.types;
/**
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b9ca520e/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 bec47d1..05a839d 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
@@ -1,12 +1,28 @@
+/*
+ * 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.download;
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.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
@@ -17,7 +33,13 @@ import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-import java.io.IOException;
+
+import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
/**
* Created by cdutz on 18.05.2014.
@@ -27,43 +49,97 @@ public class DownloadRetriever extends BaseRetriever {
public static final String FLEX_INSTALLER_CONFIG_URL =
"http://flex.apache.org/installer/sdk-installer-config-4.0.xml";
+ public File retrieve(SDKType type, String version) throws RetrieverException {
+ return retrieve(type, version, null);
+ }
+
@Override
- public void retrieve(PlatformType platformType, SDKType type, String version) throws RetrieverException {
- final String url = getBinaryUrl(platformType, type, version);
- System.out.println(url);
+ public File retrieve(SDKType type, String version, PlatformType platformType) throws RetrieverException {
+ try {
+ // Define the source.
+ final URL sourceUrl = new URL(getBinaryUrl(type, version, platformType));
+ final URLConnection connection = sourceUrl.openConnection();
+ final ReadableByteChannel rbc = Channels.newChannel(connection.getInputStream());
+
+ // Create a temp target file.
+ final File targetFile = File.createTempFile(type.toString() + "-" + version +
+ ((platformType != null) ? "-" + platformType : "") + "-", ".bin");
+ final FileOutputStream fos = new FileOutputStream(targetFile);
+
+ // Do the copying.
+ final long expectedSize = connection.getContentLength();
+ long transferedSize = 0L;
+ System.out.println("Downloading " + type + " version " + version +
+ ((platformType != null) ? " for platform " + platformType : ""));
+ if(expectedSize > 1014 * 1024) {
+ System.out.println("Expected size: " + (expectedSize / 1024 / 1024) + "MB");
+ } else {
+ System.out.println("Expected size: " + (expectedSize / 1024 ) + "KB");
+ }
+ 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) : "") + "]");
+ }
+ System.out.println();
+ System.out.println("Finished");
+ fos.close();
+
+ return targetFile;
+ } catch (MalformedURLException e) {
+ throw new RetrieverException("Error downloading archive.", e);
+ } catch (FileNotFoundException e) {
+ throw new RetrieverException("Error downloading archive.", e);
+ } catch (IOException e) {
+ throw new RetrieverException("Error downloading archive.", e);
+ }
}
- protected String getBinaryUrl(PlatformType platformType, SDKType sdkType, String version) throws RetrieverException {
+ protected String getBinaryUrl(SDKType sdkType, String version, PlatformType platformType)
+ throws RetrieverException {
try {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
final DocumentBuilder builder = factory.newDocumentBuilder();
final Document doc = builder.parse(FLEX_INSTALLER_CONFIG_URL);
//Evaluate XPath against Document itself
- final String expression = getUrlXpath(platformType, sdkType, version);
+ final String expression = getUrlXpath(sdkType, version, platformType);
final XPath xPath = XPathFactory.newInstance().newXPath();
final Element artifactElement = (Element) xPath.evaluate(
expression, doc.getDocumentElement(), XPathConstants.NODE);
final StringBuilder stringBuilder = new StringBuilder();
- if(sdkType == SDKType.FLEX) {
+ if (sdkType == SDKType.FLEX) {
final String path = artifactElement.getAttribute("path");
final String file = artifactElement.getAttribute("file");
- if(!path.startsWith("http://")) {
+ if (!path.startsWith("http://")) {
stringBuilder.append("http://archive.apache.org/dist/");
}
- stringBuilder.append(path).append(file);
+ stringBuilder.append(path);
+ if(!path.endsWith("/")) {
+ stringBuilder.append("/");
+ }
+ stringBuilder.append(file).append(".zip");
} else {
final NodeList pathElements = artifactElement.getElementsByTagName("path");
final NodeList fileElements = artifactElement.getElementsByTagName("file");
- if((pathElements.getLength() != 1) && (fileElements.getLength() != 1)) {
+ if ((pathElements.getLength() != 1) && (fileElements.getLength() != 1)) {
throw new RetrieverException("Invalid document structure.");
}
- stringBuilder.append(pathElements.item(0).getTextContent());
+ final String path = pathElements.item(0).getTextContent();
+ stringBuilder.append(path);
+ if(!path.endsWith("/")) {
+ stringBuilder.append("/");
+ }
stringBuilder.append(fileElements.item(0).getTextContent());
}
return stringBuilder.toString();
- } catch(ParserConfigurationException e) {
+ } catch (ParserConfigurationException e) {
throw new RetrieverException("Error parsing 'sdk-installer-config-4.0.xml'", e);
} catch (SAXException e) {
throw new RetrieverException("Error parsing 'sdk-installer-config-4.0.xml'", e);
@@ -74,7 +150,8 @@ public class DownloadRetriever extends BaseRetriever {
}
}
- protected String getUrlXpath(PlatformType platformType, SDKType sdkType, String version) {
+ protected String getUrlXpath(SDKType sdkType, String version, PlatformType platformType)
+ throws RetrieverException {
final StringBuilder stringBuilder = new StringBuilder();
switch (sdkType) {
case FLEX:
@@ -82,6 +159,9 @@ public class DownloadRetriever extends BaseRetriever {
break;
case AIR:
stringBuilder.append("//*[@id='air.sdk.version.");
+ if (platformType == null) {
+ throw new RetrieverException("You need to specify the platformType parameter for AIR SDKs.");
+ }
switch (platformType) {
case WINDOWS:
stringBuilder.append("windows");
@@ -106,60 +186,63 @@ public class DownloadRetriever extends BaseRetriever {
public static void main(String[] args) throws Exception {
final DownloadRetriever retriever = new DownloadRetriever();
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLEX, "4.9.1");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLEX, "4.10.0");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLEX, "4.11.0");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLEX, "4.12.0");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLEX, "4.12.1");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLEX, "Nightly");
-
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "2.6");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "2.6");
- retriever.retrieve(PlatformType.LINUX, SDKType.AIR, "2.6");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "2.7");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "2.7");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.0");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.0");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.1");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.1");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.2");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.2");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.3");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.3");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.4");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.4");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.5");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.5");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.6");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.6");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.7");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.7");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.8");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.8");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "3.9");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "3.9");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "4.0");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "4.0");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "13.0");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "13.0");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.AIR, "14.0");
- retriever.retrieve(PlatformType.MAC, SDKType.AIR, "14.0");
-
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "10.2");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "10.3");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.0");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.1");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.2");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.3");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.4");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.5");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.6");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.7");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.8");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "11.9");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "12.0");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "13.0");
- retriever.retrieve(PlatformType.WINDOWS, SDKType.FLASH, "14.0");
+ // 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, "Nightly");
+
+ // 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);
+
+ // 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");
}
[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
Posted by cd...@apache.org.
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");
[06/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Added the functionality to ask for accepting the
Adobe license before downloading AIR and Fl
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Added the functionality to ask for accepting the Adobe license before downloading AIR and Flash resources.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/f8468bad
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/f8468bad
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/f8468bad
Branch: refs/heads/develop
Commit: f8468bad7109f936ff3536ed65f949ed031c8f9a
Parents: b9ca520
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sat May 24 12:34:13 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sat May 24 12:34:13 2014 +0200
----------------------------------------------------------------------
.../converter/retrievers/types/SdkType.java | 16 +++++++
.../retrievers/download/DownloadRetriever.java | 49 +++++++++++++++++---
.../src/main/resources/message.properties | 21 +++++++++
3 files changed, 80 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f8468bad/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
index b2ba4df..f551ab1 100644
--- a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
+++ b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
@@ -1,3 +1,19 @@
+/*
+ * 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.types;
/**
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f8468bad/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 05a839d..0bf26b2 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
@@ -40,6 +40,7 @@ import java.net.URL;
import java.net.URLConnection;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
+import java.util.Properties;
/**
* Created by cdutz on 18.05.2014.
@@ -56,6 +57,10 @@ public class DownloadRetriever extends BaseRetriever {
@Override
public File retrieve(SDKType type, String version, PlatformType platformType) throws RetrieverException {
try {
+ if (type.equals(SDKType.FLASH) || type.equals(SDKType.AIR)) {
+ confirmLicenseAcceptance(type);
+ }
+
// Define the source.
final URL sourceUrl = new URL(getBinaryUrl(type, version, platformType));
final URLConnection connection = sourceUrl.openConnection();
@@ -183,19 +188,51 @@ public class DownloadRetriever extends BaseRetriever {
return stringBuilder.toString();
}
+ protected void confirmLicenseAcceptance(SDKType type) throws RetrieverException {
+ final Properties questionProps = new Properties();
+ try {
+ questionProps.load(DownloadRetriever.class.getClassLoader().getResourceAsStream("message.properties"));
+ } catch (IOException e) {
+ throw new RetrieverException("Error reading message.properties file", e);
+ }
+
+ final String question;
+ if(type.equals(SDKType.FLASH)) {
+ question = questionProps.getProperty("ASK_ADOBE_FLASH_PLAYER_GLOBAL_SWC");
+ } else if(type.equals(SDKType.AIR)) {
+ question = questionProps.getProperty("ASK_ADOBE_FLASH_PLAYER_GLOBAL_SWC");
+ } else {
+ throw new RetrieverException("Unknown SDKType");
+ }
+ System.out.println(question);
+ System.out.print(questionProps.getProperty("DO_YOU_ACCEPT_QUESTION") + " ");
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
+ try {
+ final String answer = reader.readLine();
+ if (!"YES".equalsIgnoreCase(answer)) {
+ System.out.println("You have to accept the license agreement in order to proceed.");
+ throw new RetrieverException("You have to accept the license agreement in order to proceed.");
+ }
+ } catch(IOException e) {
+ throw new RetrieverException("Couldn't read from Stdin.");
+ }
+ }
+
+
+
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.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, "Nightly");
+ retriever.retrieve(SDKType.FLEX, "Nightly");*/
// Test the retrieval of AIR SDKs
- retriever.retrieve(SDKType.AIR, "2.6", PlatformType.WINDOWS);
+ /*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);
@@ -225,11 +262,11 @@ public class DownloadRetriever extends BaseRetriever {
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, "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.3");
retriever.retrieve(SDKType.FLASH, "11.0");
retriever.retrieve(SDKType.FLASH, "11.1");
retriever.retrieve(SDKType.FLASH, "11.2");
@@ -242,7 +279,7 @@ public class DownloadRetriever extends BaseRetriever {
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, "14.0");*/
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f8468bad/mavenizer/retrievers/download/src/main/resources/message.properties
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/download/src/main/resources/message.properties b/mavenizer/retrievers/download/src/main/resources/message.properties
new file mode 100644
index 0000000..b799623
--- /dev/null
+++ b/mavenizer/retrievers/download/src/main/resources/message.properties
@@ -0,0 +1,21 @@
+################################################################################
+##
+## 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.
+##
+################################################################################
+ASK_ADOBE_AIR_SDK=The Adobe SDK license agreement applies to the Adobe AIR SDK. Do you want to install the Adobe AIR SDK? Adobe AIR SDK License: http://www.adobe.com/products/air/sdk-eula.html
+ASK_ADOBE_FLASH_PLAYER_GLOBAL_SWC=The Adobe SDK license agreement applies to the Adobe Flash Player playerglobal.swc. Do you want to install the Adobe Flash Player playerglobal.swc?
+DO_YOU_ACCEPT_QUESTION=Do you accept (Yes/No)?
\ No newline at end of file
[24/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Fixed a problem in the dependencyManagement
generation.
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Fixed a problem in the dependencyManagement generation.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/b3e70ac7
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/b3e70ac7
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/b3e70ac7
Branch: refs/heads/develop
Commit: b3e70ac74662ffc00b8781af7eb71a14c37ca237
Parents: 7583e96
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sat Jul 12 14:43:09 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sat Jul 12 14:43:09 2014 +0200
----------------------------------------------------------------------
.../converters/base/src/main/resources/templates/pom.vm | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b3e70ac7/mavenizer/converters/base/src/main/resources/templates/pom.vm
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/resources/templates/pom.vm b/mavenizer/converters/base/src/main/resources/templates/pom.vm
index 6287cbe..405ada1 100644
--- a/mavenizer/converters/base/src/main/resources/templates/pom.vm
+++ b/mavenizer/converters/base/src/main/resources/templates/pom.vm
@@ -22,13 +22,15 @@
</dependencies>
<dependencyManagement>
+ <dependencies>
#foreach( $dependency in $artifact.dependencies )
- <dependency>
- <groupId>${dependency.groupId}</groupId>
- <artifactId>${dependency.artifactId}</artifactId>
- <version>${dependency.version}</version>
- </dependency>
+ <dependency>
+ <groupId>${dependency.groupId}</groupId>
+ <artifactId>${dependency.artifactId}</artifactId>
+ <version>${dependency.version}</version>
+ </dependency>
#end
+ </dependencies>
</dependencyManagement>
#end
[20/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Added the maven assembly plugin to create the
fat jar that can be executed from the commandl
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Added the maven assembly plugin to create the fat jar that can be executed from the commandline.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/67ded729
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/67ded729
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/67ded729
Branch: refs/heads/develop
Commit: 67ded729250ea03ced03f45c530c7a646c2a46ed
Parents: 0ee60fc
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sat Jul 12 13:23:42 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sat Jul 12 13:23:42 2014 +0200
----------------------------------------------------------------------
mavenizer/core/pom.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/67ded729/mavenizer/core/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/core/pom.xml b/mavenizer/core/pom.xml
index a46530d..d8f06d0 100644
--- a/mavenizer/core/pom.xml
+++ b/mavenizer/core/pom.xml
@@ -42,6 +42,7 @@
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addClasspath>true</addClasspath>
+ <mainClass>org.apache.flex.utilities.converter.core.SdkConverter</mainClass>
</manifest>
<manifestEntries>
<Implementation-Build>${project.version}</Implementation-Build>
[26/28] git commit: [flex-utilities] [refs/heads/develop] - - Fixed a
problem occurring on Macs
Posted by cd...@apache.org.
- Fixed a problem occurring on Macs
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/4b5f3a77
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/4b5f3a77
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/4b5f3a77
Branch: refs/heads/develop
Commit: 4b5f3a77dd66baf694085f55f80dd673ae31b97e
Parents: 001ed0c
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Fri Aug 15 18:59:12 2014 +0200
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Fri Aug 15 18:59:12 2014 +0200
----------------------------------------------------------------------
.../utilities/converter/deployer/aether/AetherDeployer.java | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4b5f3a77/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 40ac8c2..74434f9 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
@@ -186,6 +186,12 @@ public class AetherDeployer {
final File artifactFiles[] = artifactDirectory.listFiles(new ArtifactFilter());
for (final File artifactFile : artifactFiles) {
final String fileName = artifactFile.getName();
+
+ // Handle the case that some file might not start with the base-name.
+ if(!fileName.startsWith(artifactBaseName)) {
+ continue;
+ }
+
final String classifier;
// This file has a classifier.
if (fileName.charAt(artifactBaseName.length()) == '-') {
[08/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Updated a problem outputting the Flash license
message when the Air one should be output.
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Updated a problem outputting the Flash license message when the Air one should be 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/83a57f64
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/83a57f64
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/83a57f64
Branch: refs/heads/develop
Commit: 83a57f64bb6486b410bebb8283fd76604d681f56
Parents: 0c4151f
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sat May 24 20:41:04 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sat May 24 20:41:04 2014 +0200
----------------------------------------------------------------------
.../utilities/converter/retrievers/download/DownloadRetriever.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/83a57f64/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 6bea87c..b8fa265 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
@@ -221,7 +221,7 @@ public class DownloadRetriever extends BaseRetriever {
if(type.equals(SDKType.FLASH)) {
question = questionProps.getProperty("ASK_ADOBE_FLASH_PLAYER_GLOBAL_SWC");
} else if(type.equals(SDKType.AIR)) {
- question = questionProps.getProperty("ASK_ADOBE_FLASH_PLAYER_GLOBAL_SWC");
+ question = questionProps.getProperty("ASK_ADOBE_AIR_SDK");
} else {
throw new RetrieverException("Unknown SDKType");
}
[14/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Removed the dependency management section and
added the version to the artifacts themselves
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Removed the dependency management section and added the version to the artifacts themselves
- Made the mavenizer generate the mx artifact to the main framework
- Added the generation of the asdoc template.zip
- Added a first version of a batch converter to convert a set of fdks
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/fac7e6fb
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/fac7e6fb
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/fac7e6fb
Branch: refs/heads/develop
Commit: fac7e6fb3cf937a3c69b91d2efc588e0eef936a5
Parents: 2e4279b
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Thu Jun 5 19:23:41 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Thu Jun 5 19:23:41 2014 +0200
----------------------------------------------------------------------
.../flex/utilities/converter/BaseConverter.java | 15 ++--
.../utilities/converter/flex/FlexConverter.java | 61 ++++++++++++--
.../converter/core/BatchConverter.java | 88 ++++++++++++++++++++
3 files changed, 152 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/fac7e6fb/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
index 6f67c6d..47466d1 100644
--- a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
+++ b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
@@ -51,7 +51,7 @@ import java.util.zip.ZipOutputStream;
*/
public abstract class BaseConverter {
- protected static final Map<String, MavenArtifact> checksums = new HashMap<String, MavenArtifact>();
+ protected final Map<String, MavenArtifact> checksums = new HashMap<String, MavenArtifact>();
protected static final String MAVEN_SCHEMA_URI = "http://maven.apache.org/POM/4.0.0";
protected static final String MAVEN_CENTRAL_SHA_1_QUERY_URL = "http://search.maven.org/solrsearch/select?rows=20&wt=json&q=1:";
@@ -306,10 +306,10 @@ public abstract class BaseConverter {
if((metadata.getDependencies() != null) && !metadata.getDependencies().isEmpty()) {
final Element dependencies = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencies");
root.appendChild(dependencies);
- final Element dependencyManagement = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencyManagement");
+ /*final Element dependencyManagement = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencyManagement");
final Element dependencyManagementDependencies = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencies");
dependencyManagement.appendChild(dependencyManagementDependencies);
- root.appendChild(dependencyManagement);
+ root.appendChild(dependencyManagement);*/
final Map<String, MavenArtifact> dependencyIndex = new HashMap<String, MavenArtifact>();
for(final MavenArtifact dependencyMetadata : metadata.getDependencies()) {
@@ -323,6 +323,9 @@ public abstract class BaseConverter {
Element dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
dependencyArtifactId.setTextContent(dependencyMetadata.getArtifactId());
dependency.appendChild(dependencyArtifactId);
+ Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
+ dependencyVersion.setTextContent(dependencyMetadata.getVersion());
+ dependency.appendChild(dependencyVersion);
Element dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
dependencyPackaging.setTextContent(dependencyMetadata.getPackaging());
dependency.appendChild(dependencyPackaging);
@@ -333,20 +336,20 @@ public abstract class BaseConverter {
}
// Configure the dependency including version in the dependency management section of the pom.
- dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
+ /*dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
dependencyGroupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
dependencyGroupId.setTextContent(dependencyMetadata.getGroupId());
dependency.appendChild(dependencyGroupId);
dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
dependencyArtifactId.setTextContent(dependencyMetadata.getArtifactId());
dependency.appendChild(dependencyArtifactId);
- Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
+ dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
dependencyVersion.setTextContent(dependencyMetadata.getVersion());
dependency.appendChild(dependencyVersion);
dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
dependencyPackaging.setTextContent(dependencyMetadata.getPackaging());
dependency.appendChild(dependencyPackaging);
- dependencyManagementDependencies.appendChild(dependency);
+ dependencyManagementDependencies.appendChild(dependency);*/
dependencyIndex.put(dependencyMetadata.getArtifactId(), dependencyMetadata);
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/fac7e6fb/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 1d0709a..7d1c671 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
@@ -149,6 +149,14 @@ public class FlexConverter extends BaseConverter implements Converter {
framework.addDependency(artifact);
}
}
+
+ // Forcefully add the mx library to the rest of the framework.
+ if("libs".equals(directory.getName())) {
+ final File mxSwc = new File(directory, "mx/mx.swc");
+ final MavenArtifact artifact = resolveArtifact(mxSwc, artifactGroupId, flexSdkVersion);
+ framework.addDependency(artifact);
+ }
+
// If we are in the "mobile" directory and the paren contains an "experimental_mobile.swc" file,
// add this to the mobile package.
if("mobile".equals(directory.getName())) {
@@ -166,7 +174,8 @@ public class FlexConverter extends BaseConverter implements Converter {
children.addAll(Arrays.asList(directory.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
- return pathname.isDirectory() && !"player".equals(pathname.getName());
+ return pathname.isDirectory() && !"player".equals(pathname.getName()) &&
+ !"mx".equals(pathname.getName());
}
})));
for(final File childDirectory : children) {
@@ -200,7 +209,7 @@ public class FlexConverter extends BaseConverter implements Converter {
@Override
protected void writeArtifact(MavenArtifact artifact) throws ConverterException {
if(!"pom".equals(artifact.getPackaging())) {
- // Copy the rsls too.
+ // Copy the rsls.
final File rslSourceFile = getRsl(artifact.getArtifactId());
if(rslSourceFile != null) {
final File rslTargetFile = new File(
@@ -209,7 +218,7 @@ public class FlexConverter extends BaseConverter implements Converter {
copyFile(rslSourceFile, rslTargetFile);
}
- // Copy the swzc too.
+ // Copy the swzc.
final File signedRslSourceFile = getSignedRsl(artifact.getArtifactId());
if(signedRslSourceFile != null) {
final File signedRslTargetFile = new File(
@@ -218,7 +227,7 @@ public class FlexConverter extends BaseConverter implements Converter {
copyFile(signedRslSourceFile, signedRslTargetFile);
}
- // Copy the language resources too.
+ // Copy the language resources.
final Map<String, File> resourceBundles = getResourceBundles(artifact.getArtifactId());
if(!resourceBundles.isEmpty() &&
artifact.getBinaryTargetFile(rootTargetDirectory, MavenArtifact.DEFAULT_CLASSIFIER) != null) {
@@ -248,7 +257,7 @@ public class FlexConverter extends BaseConverter implements Converter {
}
}
- // Add source zips ...
+ // Add source zips.
final File sourceArtifactSourceFile = generateSourceArtifact(artifact.getArtifactId());
if(sourceArtifactSourceFile != null) {
final File sourceArtifactTargetFile = new File(
@@ -256,6 +265,18 @@ public class FlexConverter extends BaseConverter implements Converter {
artifact.getArtifactId() + "-" + artifact.getVersion() + "-sources.jar");
copyFile(sourceArtifactSourceFile, sourceArtifactTargetFile);
}
+
+ // If this is the asdoc artifact, create the templates.zip for that.
+ if("asdoc".equals(artifact.getArtifactId())) {
+ final File asdocTemplatesZipSourceFile = generateAsdocTemplatesZip();
+ if (asdocTemplatesZipSourceFile != null) {
+ final File asdocTemplatesZipTargetFile = new File(
+ artifact.getBinaryTargetFile(
+ rootTargetDirectory, MavenArtifact.DEFAULT_CLASSIFIER).getParent(),
+ artifact.getArtifactId() + "-" + artifact.getVersion() + "-template.zip");
+ copyFile(asdocTemplatesZipSourceFile, asdocTemplatesZipTargetFile);
+ }
+ }
}
super.writeArtifact(artifact);
@@ -291,6 +312,34 @@ public class FlexConverter extends BaseConverter implements Converter {
return null;
}
+ protected File generateAsdocTemplatesZip() throws ConverterException {
+ final File templatesDirectory = new File(rootSourceDirectory, "asdoc/templates");
+
+ if (templatesDirectory.listFiles() != null) {
+ final File sourceFiles[] = templatesDirectory.listFiles();
+ if (sourceFiles != null) {
+ final File zipInputFiles[] = new File[sourceFiles.length + 1];
+ System.arraycopy(sourceFiles, 0, zipInputFiles, 0, sourceFiles.length);
+
+ try {
+ // Create a temp file.
+ final File targetFile = File.createTempFile("temp-asdoc-templates", "zip");
+
+ JarOutputStream jar = new JarOutputStream(new FileOutputStream(targetFile));
+ for (final File file : zipInputFiles) {
+ addFileToZip(jar, file, templatesDirectory);
+ }
+ jar.close();
+
+ return targetFile;
+ } catch(IOException e) {
+ throw new ConverterException("Error creating asdoc-templates archive.", e);
+ }
+ }
+ }
+ return null;
+ }
+
protected void generateFrameworkConfigurationArtifact() throws ConverterException {
// ZIP up every file (not directory) in the framework directory and the entire themes directory.
final File frameworksDirectory = new File(rootSourceDirectory, "frameworks");
@@ -326,7 +375,7 @@ public class FlexConverter extends BaseConverter implements Converter {
final String themeName = themeDirectory.getName().toLowerCase();
final File themeFile = new File(themeDirectory, themeName + ".swc");
- File targetSwcFile = null;
+ final File targetSwcFile;
if(themeFile.exists()) {
targetSwcFile = themeFile;
} else {
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/fac7e6fb/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
new file mode 100644
index 0000000..e1ed2b1
--- /dev/null
+++ b/mavenizer/core/src/main/java/org/apache/flex/utilities/converter/core/BatchConverter.java
@@ -0,0 +1,88 @@
+/*
+ * 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 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.");
+ }
+ }
+
+}
[18/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Updated the pom generation as the first attempt
produced poms that didn't seem to work.
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Updated the pom generation as the first attempt produced poms that didn't seem to work.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/07dc1193
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/07dc1193
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/07dc1193
Branch: refs/heads/develop
Commit: 07dc1193924edd780b6ea6d4ca901ace21413c01
Parents: 4eb49a5
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sat Jun 28 15:57:46 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sat Jun 28 15:57:46 2014 +0200
----------------------------------------------------------------------
.../base/src/main/resources/templates/pom.vm | 24 +++++---------------
.../converter/core/BatchConverter.java | 1 -
2 files changed, 6 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/07dc1193/mavenizer/converters/base/src/main/resources/templates/pom.vm
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/resources/templates/pom.vm b/mavenizer/converters/base/src/main/resources/templates/pom.vm
index 5ccb0d1..917dff0 100644
--- a/mavenizer/converters/base/src/main/resources/templates/pom.vm
+++ b/mavenizer/converters/base/src/main/resources/templates/pom.vm
@@ -8,18 +8,6 @@
<packaging>${artifact.packaging}</packaging>
#if ( $artifact.hasDependencies() )
- <dependencies>
-#foreach( $dependency in $artifact.dependencies )
- <dependency>
- <groupId>${dependency.groupId}</groupId>
- <artifactId>${dependency.artifactId}</artifactId>
-#if ($dependency.packaging != "jar")
- <type>${dependency.packaging}</type>
-#end
- </dependency>
-#end
- </dependencies>
-
#if ( $artifact.isAtLeastOneDependencyRsl() )
<profiles>
<profile>
@@ -29,7 +17,7 @@
<activeByDefault>true</activeByDefault>
</activation>
- <dependencyManagement>
+ <dependencies>
#foreach( $dependency in $artifact.dependencies )
<dependency>
<groupId>${dependency.groupId}</groupId>
@@ -40,7 +28,7 @@
#end
</dependency>
#end
- </dependencyManagement>
+ </dependencies>
</profile>
<profile>
@@ -53,7 +41,7 @@
</property>
</activation>
- <dependencyManagement>
+ <dependencies>
#foreach( $dependency in $artifact.dependencies )
<dependency>
<groupId>${dependency.groupId}</groupId>
@@ -67,11 +55,11 @@
#end
</dependency>
#end
- </dependencyManagement>
+ </dependencies>
</profile>
</profiles>
#else
- <dependencyManagement>
+ <dependencies>
#foreach( $dependency in $artifact.dependencies )
<dependency>
<groupId>${dependency.groupId}</groupId>
@@ -82,7 +70,7 @@
#end
</dependency>
#end
- </dependencyManagement>
+ </dependencies>
#end
#end
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/07dc1193/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
index e1ed2b1..caf14cf 100644
--- 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
@@ -17,7 +17,6 @@
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;
[13/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Fixed a problem causing the mavenizer to abort
if a Flex SDK didn't contain Air
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Fixed a problem causing the mavenizer to abort if a Flex SDK didn't contain Air
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/2e4279bb
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/2e4279bb
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/2e4279bb
Branch: refs/heads/develop
Commit: 2e4279bb6cd57d83fe8681e7be4d0ec2ee35e6db
Parents: ca5c097
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sun May 25 00:13:07 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sun May 25 00:13:07 2014 +0200
----------------------------------------------------------------------
.../utilities/converter/core/SdkConverter.java | 25 +++++++++++++++-----
1 file changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/2e4279bb/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
index 44115cc..f438dcd 100644
--- 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
@@ -17,6 +17,7 @@
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;
@@ -46,12 +47,24 @@ public class SDKConverter {
}
}
- 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();
+ try {
+ final FlexConverter flexConverter = new FlexConverter(sourceDirectory, targetDirectory);
+ flexConverter.convert();
+ } catch(ConverterException e) {
+ System.out.println("Skipping generation of FLEX SDK");
+ }
+ try {
+ final AirConverter airConverter = new AirConverter(sourceDirectory, targetDirectory);
+ airConverter.convert();
+ } catch(ConverterException e) {
+ System.out.println("Skipping generation of AIR SDK");
+ }
+ try {
+ final FlashConverter flashConverter = new FlashConverter(sourceDirectory, targetDirectory);
+ flashConverter.convert();
+ } catch(ConverterException e) {
+ System.out.println("Skipping generation of Flash SDK");
+ }
}
}
[25/28] git commit: [flex-utilities] [refs/heads/develop] - Added
repo info so the apache jenkins will know how to deploy the artifacts.
Posted by cd...@apache.org.
Added repo info so the apache jenkins will know how to deploy the artifacts.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/001ed0c3
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/001ed0c3
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/001ed0c3
Branch: refs/heads/develop
Commit: 001ed0c3fb6d050e1f59f71ce070bc43df5e09b2
Parents: b3e70ac
Author: cdutz <ch...@c-ware.de>
Authored: Thu Jul 31 10:13:38 2014 +0200
Committer: cdutz <ch...@c-ware.de>
Committed: Thu Jul 31 10:13:38 2014 +0200
----------------------------------------------------------------------
mavenizer/pom.xml | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/001ed0c3/mavenizer/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/pom.xml b/mavenizer/pom.xml
index 71748f0..f56c49b 100644
--- a/mavenizer/pom.xml
+++ b/mavenizer/pom.xml
@@ -33,6 +33,17 @@
<wagonVersion>2.2</wagonVersion>
</properties>
+ <distributionManagement>
+ <repository>
+ <id>apache.releases.https</id>
+ <url>https://repository.apache.org/service/local/staging/deploy/maven2</url>
+ </repository>
+ <snapshotRepository>
+ <id>apache.snapshots.https</id>
+ <url>https://repository.apache.org/content/repositories/snapshots</url>
+ </snapshotRepository>
+ </distributionManagement>
+
<modules>
<module>core</module>
<module>retrievers</module>
[15/28] git commit: [flex-utilities] [refs/heads/develop] -
Refactored the way the poms are generated: - Instead of hard-coded pom
construction now velocity templates can be used.
Posted by cd...@apache.org.
Refactored the way the poms are generated:
- Instead of hard-coded pom construction now velocity templates can be used.
Fixed some Case-Problems in the Class names.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/95be7411
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/95be7411
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/95be7411
Branch: refs/heads/develop
Commit: 95be74110c439a8178857aa3024fb03ba108cdab
Parents: fac7e6f
Author: cdutz <ch...@c-ware.de>
Authored: Thu Jun 26 13:57:24 2014 +0200
Committer: cdutz <ch...@c-ware.de>
Committed: Thu Jun 26 13:57:24 2014 +0200
----------------------------------------------------------------------
mavenizer/converters/base/pom.xml | 5 +
.../flex/utilities/converter/BaseConverter.java | 123 ++++++++++---------
.../converter/model/MavenArtifact.java | 21 +++-
.../src/main/resources/templates/default.vm | 21 ++++
.../base/src/main/resources/templates/pom.vm | 89 ++++++++++++++
.../base/src/main/resources/velocity.properties | 10 ++
.../utilities/converter/flex/FlexConverter.java | 2 +
.../utilities/converter/core/AirDownloader.java | 4 +-
.../converter/core/FlashDownloader.java | 4 +-
.../utilities/converter/core/SdkConverter.java | 2 +-
.../converter/retrievers/Retriever.java | 4 +-
.../converter/retrievers/types/SdkType.java | 2 +-
.../retrievers/download/DownloadRetriever.java | 24 ++--
13 files changed, 229 insertions(+), 82 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/95be7411/mavenizer/converters/base/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/pom.xml b/mavenizer/converters/base/pom.xml
index 25c5fc7..e919012 100644
--- a/mavenizer/converters/base/pom.xml
+++ b/mavenizer/converters/base/pom.xml
@@ -43,6 +43,11 @@
<artifactId>jettison</artifactId>
<version>1.3.1</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.7</version>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/95be7411/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
index 47466d1..499b8e9 100644
--- a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
+++ b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
@@ -22,20 +22,13 @@ import com.sun.jersey.api.client.WebResource;
import org.apache.flex.utilities.converter.exceptions.ConverterException;
import org.apache.flex.utilities.converter.model.MavenArtifact;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.codehaus.jettison.json.JSONTokener;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
+
import java.io.*;
import java.math.BigInteger;
import java.security.MessageDigest;
@@ -43,6 +36,7 @@ import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -53,7 +47,6 @@ public abstract class BaseConverter {
protected final Map<String, MavenArtifact> checksums = new HashMap<String, MavenArtifact>();
- protected static final String MAVEN_SCHEMA_URI = "http://maven.apache.org/POM/4.0.0";
protected static final String MAVEN_CENTRAL_SHA_1_QUERY_URL = "http://search.maven.org/solrsearch/select?rows=20&wt=json&q=1:";
// Artifactory: "http://server:port/artifactory/api/search/checksum?repos=libs-release-local&md5=04040c7c184620af0a0a8a3682a75eb7
// Nexus: "http://repository.sonatype.org/service/local/data_index?a=04040c7c184620af0a0a8a3682a75eb7"
@@ -61,6 +54,8 @@ public abstract class BaseConverter {
protected File rootSourceDirectory;
protected File rootTargetDirectory;
+ private VelocityEngine velocityEngine;
+
protected BaseConverter(File rootSourceDirectory, File rootTargetDirectory) throws ConverterException {
if(rootSourceDirectory == null) {
throw new ConverterException("Air SDK directory is null.");
@@ -71,6 +66,21 @@ public abstract class BaseConverter {
this.rootSourceDirectory = rootSourceDirectory;
this.rootTargetDirectory = rootTargetDirectory;
+
+ try {
+ // Load some initial properties from the classpath.
+ final Properties properties = new Properties();
+ final InputStream propertyInputStream =
+ getClass().getClassLoader().getResourceAsStream("velocity.properties");
+ if(propertyInputStream != null) {
+ properties.load(propertyInputStream);
+ }
+
+ // Instantiate the engine that will be used for every generation.
+ velocityEngine = new VelocityEngine(properties);
+ } catch (Exception e) {
+ throw new ConverterException("Error initializing the velocity template engine.", e);
+ }
}
public void convert() throws ConverterException {
@@ -225,59 +235,50 @@ public abstract class BaseConverter {
}
}
- /*protected void appendArtifact(MavenMetadata artifactMetadata, Element dependencies) {
- final Document doc = dependencies.getOwnerDocument();
- final Element dependency = doc.createElementNS(MAVEN_SCHEMA_URI, "dependency");
- dependencies.appendChild(dependency);
-
- final Element groupId = doc.createElementNS(MAVEN_SCHEMA_URI, "groupId");
- groupId.setTextContent(artifactMetadata.getGroupId());
- dependency.appendChild(groupId);
- final Element artifactId = doc.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
- artifactId.setTextContent(artifactMetadata.getArtifactId());
- dependency.appendChild(artifactId);
- final Element version = doc.createElementNS(MAVEN_SCHEMA_URI, "version");
- version.setTextContent(artifactMetadata.getVersion());
- dependency.appendChild(version);
- if(!artifactMetadata.getPackaging().equals("jar")) {
- final Element packaging = doc.createElementNS(MAVEN_SCHEMA_URI, "type");
- packaging.setTextContent(artifactMetadata.getPackaging());
- dependency.appendChild(packaging);
- }
- }*/
-
protected void writePomArtifact(MavenArtifact pomData) throws ConverterException {
- final Document pomDoc = createPomDocument(pomData);
final File outputFile = pomData.getPomTargetFile(rootTargetDirectory);
- writeDocument(pomDoc, outputFile);
+ createPomDocument(pomData, outputFile);
}
- protected void writeDocument(Document doc, File outputFile) throws ConverterException {
- final Source source = new DOMSource(doc);
- final File outputDirectory = outputFile.getParentFile();
- if(!outputDirectory.exists()) {
- if(!outputDirectory.mkdirs()) {
- throw new RuntimeException("Could not create directory: " + outputDirectory.getAbsolutePath());
+ protected void createPomDocument(final MavenArtifact metadata, File outputFile) throws ConverterException {
+ try {
+ // Build a context to hold the model
+ final VelocityContext velocityContext = new VelocityContext();
+ velocityContext.put("artifact", metadata);
+
+ // Try to get a template "templates/{type}.vm".
+ final String templateName;
+ if(velocityEngine.resourceExists("templates/" + metadata.getPackaging() + ".vm")) {
+ templateName = "templates/" + metadata.getPackaging() + ".vm";
+ } else if(velocityEngine.resourceExists("templates/default.vm")) {
+ templateName = "templates/default.vm";
+ } else {
+ throw new ConverterException("No template found for generating pom output.");
}
- }
- final Result result = new StreamResult(outputFile);
+ // Prepare an output stream to which the output can be generated.
+ FileWriter writer = null;
+ try {
+ if(!outputFile.getParentFile().exists()) {
+ if(!outputFile.getParentFile().mkdirs()) {
+ throw new ConverterException("Could not create template output directory.");
+ }
+ }
+
+ writer = new FileWriter(outputFile);
- final Transformer transformer;
- try {
- transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
- transformer.transform(source, result);
- } catch (TransformerConfigurationException e) {
- throw new ConverterException("Error writing xml document.", e);
- } catch (TransformerException e) {
- throw new ConverterException("Error writing xml document.", e);
+ // Have velocity generate the output for the template.
+ velocityEngine.mergeTemplate(templateName, "utf-8", velocityContext, writer);
+ } finally {
+ if(writer != null) {
+ writer.close();
+ }
+ }
+ } catch (Exception e) {
+ throw new ConverterException("Error generating template output.", e);
}
- }
- protected Document createPomDocument(final MavenArtifact metadata) throws ConverterException {
- final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ /*final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
final DocumentBuilder builder;
try {
@@ -306,10 +307,10 @@ public abstract class BaseConverter {
if((metadata.getDependencies() != null) && !metadata.getDependencies().isEmpty()) {
final Element dependencies = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencies");
root.appendChild(dependencies);
- /*final Element dependencyManagement = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencyManagement");
+ final Element dependencyManagement = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencyManagement");
final Element dependencyManagementDependencies = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencies");
dependencyManagement.appendChild(dependencyManagementDependencies);
- root.appendChild(dependencyManagement);*/
+ root.appendChild(dependencyManagement);
final Map<String, MavenArtifact> dependencyIndex = new HashMap<String, MavenArtifact>();
for(final MavenArtifact dependencyMetadata : metadata.getDependencies()) {
@@ -336,20 +337,20 @@ public abstract class BaseConverter {
}
// Configure the dependency including version in the dependency management section of the pom.
- /*dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
+ dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
dependencyGroupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
dependencyGroupId.setTextContent(dependencyMetadata.getGroupId());
dependency.appendChild(dependencyGroupId);
dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
dependencyArtifactId.setTextContent(dependencyMetadata.getArtifactId());
dependency.appendChild(dependencyArtifactId);
- dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
+ Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
dependencyVersion.setTextContent(dependencyMetadata.getVersion());
dependency.appendChild(dependencyVersion);
dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
dependencyPackaging.setTextContent(dependencyMetadata.getPackaging());
dependency.appendChild(dependencyPackaging);
- dependencyManagementDependencies.appendChild(dependency);*/
+ dependencyManagementDependencies.appendChild(dependency);
dependencyIndex.put(dependencyMetadata.getArtifactId(), dependencyMetadata);
}
@@ -381,7 +382,7 @@ public abstract class BaseConverter {
return pom;
} catch (ParserConfigurationException e) {
throw new ConverterException("Error creating pom document.", e);
- }
+ }*/
}
protected void writeDummy(final File targetFile) throws ConverterException {
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/95be7411/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java
index db5d4de..018542a 100644
--- a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java
+++ b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java
@@ -114,7 +114,11 @@ public class MavenArtifact {
binaryArtifacts.put(classifier, binaryArtifact);
}
- public File getPomTargetFile(File targetRootDirectory) {
+ public boolean hasBinaryArtifact(String classifier) {
+ return binaryArtifacts != null && binaryArtifacts.containsKey(classifier);
+ }
+
+ public File getPomTargetFile(File targetRootDirectory) {
final String fileName = groupId.replace(".", File.separator) + File.separator + artifactId + File.separator +
version + File.separator + artifactId + "-" + version + ((classifier != null) ? "-" + classifier : "") +
".pom";
@@ -146,4 +150,19 @@ public class MavenArtifact {
return null;
}
+ public boolean hasDependencies() {
+ return (dependencies != null) && (!dependencies.isEmpty());
+ }
+
+ public boolean isAtLeastOneDependencyRsl() {
+ if(dependencies != null) {
+ for(final MavenArtifact dependency : dependencies) {
+ if(dependency.hasBinaryArtifact("rsl")) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/95be7411/mavenizer/converters/base/src/main/resources/templates/default.vm
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/resources/templates/default.vm b/mavenizer/converters/base/src/main/resources/templates/default.vm
new file mode 100644
index 0000000..7af9619
--- /dev/null
+++ b/mavenizer/converters/base/src/main/resources/templates/default.vm
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>${artifact.groupId}</groupId>
+ <artifactId>${artifact.artifactId}</artifactId>
+ <version>${artifact.version}</version>
+ <packaging>${artifact.packaging}</packaging>
+
+ <dependencies>
+#foreach( $dependency in $artifact.dependencies )
+ <dependency>
+ <groupId>${dependency.groupId}</groupId>
+ <artifactId>${dependency.artifactId}</artifactId>
+ <version>${dependency.version}</version>
+ <type>${dependency.packaging}</type>
+ </dependency>
+#end
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/95be7411/mavenizer/converters/base/src/main/resources/templates/pom.vm
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/resources/templates/pom.vm b/mavenizer/converters/base/src/main/resources/templates/pom.vm
new file mode 100644
index 0000000..5ccb0d1
--- /dev/null
+++ b/mavenizer/converters/base/src/main/resources/templates/pom.vm
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>${artifact.groupId}</groupId>
+ <artifactId>${artifact.artifactId}</artifactId>
+ <version>${artifact.version}</version>
+ <packaging>${artifact.packaging}</packaging>
+
+#if ( $artifact.hasDependencies() )
+ <dependencies>
+#foreach( $dependency in $artifact.dependencies )
+ <dependency>
+ <groupId>${dependency.groupId}</groupId>
+ <artifactId>${dependency.artifactId}</artifactId>
+#if ($dependency.packaging != "jar")
+ <type>${dependency.packaging}</type>
+#end
+ </dependency>
+#end
+ </dependencies>
+
+#if ( $artifact.isAtLeastOneDependencyRsl() )
+ <profiles>
+ <profile>
+ <id>default</id>
+
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+
+ <dependencyManagement>
+#foreach( $dependency in $artifact.dependencies )
+ <dependency>
+ <groupId>${dependency.groupId}</groupId>
+ <artifactId>${dependency.artifactId}</artifactId>
+ <version>${dependency.version}</version>
+#if ($dependency.packaging != "jar")
+ <type>${dependency.packaging}</type>
+#end
+ </dependency>
+#end
+ </dependencyManagement>
+ </profile>
+
+ <profile>
+ <id>flex-rsl</id>
+
+ <activation>
+ <property>
+ <name>flex.framework.scope</name>
+ <value>rsl</value>
+ </property>
+ </activation>
+
+ <dependencyManagement>
+#foreach( $dependency in $artifact.dependencies )
+ <dependency>
+ <groupId>${dependency.groupId}</groupId>
+ <artifactId>${dependency.artifactId}</artifactId>
+ <version>${dependency.version}</version>
+#if ($dependency.packaging != "jar")
+ <type>${dependency.packaging}</type>
+#end
+#if ($dependency.packaging == "swc" && $dependency.hasBinaryArtifact('rsl'))
+ <scope>rsl</scope>
+#end
+ </dependency>
+#end
+ </dependencyManagement>
+ </profile>
+ </profiles>
+#else
+ <dependencyManagement>
+#foreach( $dependency in $artifact.dependencies )
+ <dependency>
+ <groupId>${dependency.groupId}</groupId>
+ <artifactId>${dependency.artifactId}</artifactId>
+ <version>${dependency.version}</version>
+#if ($dependency.packaging != "jar")
+ <type>${dependency.packaging}</type>
+#end
+ </dependency>
+#end
+ </dependencyManagement>
+#end
+#end
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/95be7411/mavenizer/converters/base/src/main/resources/velocity.properties
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/resources/velocity.properties b/mavenizer/converters/base/src/main/resources/velocity.properties
new file mode 100644
index 0000000..2beb502
--- /dev/null
+++ b/mavenizer/converters/base/src/main/resources/velocity.properties
@@ -0,0 +1,10 @@
+#
+# specify three resource loaders to use
+#
+resource.loader = class
+
+#
+# for the loader we call 'class', use the ClasspathResourceLoader
+#
+class.resource.loader.description = Velocity Classpath Resource Loader
+class.resource.loader.class = org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/95be7411/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 7d1c671..4aa9ba8 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
@@ -216,6 +216,7 @@ public class FlexConverter extends BaseConverter implements Converter {
artifact.getBinaryTargetFile(rootTargetDirectory, MavenArtifact.DEFAULT_CLASSIFIER).getParent(),
artifact.getArtifactId() + "-" + artifact.getVersion() + ".swf");
copyFile(rslSourceFile, rslTargetFile);
+ artifact.addBinaryArtifact("rsl", rslSourceFile);
}
// Copy the swzc.
@@ -225,6 +226,7 @@ public class FlexConverter extends BaseConverter implements Converter {
artifact.getBinaryTargetFile(rootTargetDirectory, MavenArtifact.DEFAULT_CLASSIFIER).getParent(),
artifact.getArtifactId() + "-" + artifact.getVersion() + ".swz");
copyFile(signedRslSourceFile, signedRslTargetFile);
+ artifact.addBinaryArtifact("caching", rslSourceFile);
}
// Copy the language resources.
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/95be7411/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
index f1df0f2..db1e7f4 100644
--- 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
@@ -19,7 +19,7 @@ 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 org.apache.flex.utilities.converter.retrievers.types.SdkType;
import java.io.File;
@@ -42,7 +42,7 @@ public class AirDownloader {
}
final DownloadRetriever downloadRetriever = new DownloadRetriever();
- final File airSDKSourceDirectory = downloadRetriever.retrieve(SDKType.AIR, version, platformType);
+ 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/95be7411/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
index c75e250..a0e7976 100644
--- 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
@@ -18,7 +18,7 @@ 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 org.apache.flex.utilities.converter.retrievers.types.SdkType;
import java.io.File;
@@ -37,7 +37,7 @@ public class FlashDownloader {
final File targetDirectory = new File(args[1]);
final DownloadRetriever downloadRetriever = new DownloadRetriever();
- final File playerglobalSourceFile = downloadRetriever.retrieve(SDKType.FLASH, version);
+ final File playerglobalSourceFile = downloadRetriever.retrieve(SdkType.FLASH, version);
final File tempSdkRoot = new File(playerglobalSourceFile.getParent(),
playerglobalSourceFile.getName().substring(0, playerglobalSourceFile.getName().length() - 4) +
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/95be7411/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
index f438dcd..e98cf5f 100644
--- 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
@@ -26,7 +26,7 @@ import java.io.File;
/**
* Created by cdutz on 24.05.2014.
*/
-public class SDKConverter {
+public class SdkConverter {
public static void main(String[] args) throws Exception {
if(args.length != 2) {
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/95be7411/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
index f38af43..ee863e3 100644
--- a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
+++ b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
@@ -18,7 +18,7 @@ package org.apache.flex.utilities.converter.retrievers;
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.apache.flex.utilities.converter.retrievers.types.SdkType;
import java.io.File;
@@ -27,6 +27,6 @@ import java.io.File;
*/
public interface Retriever {
- File retrieve(SDKType sdkType, String version, PlatformType platformType) throws RetrieverException;
+ File retrieve(SdkType sdkType, String version, PlatformType platformType) throws RetrieverException;
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/95be7411/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
index f551ab1..da0b527 100644
--- a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
+++ b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
@@ -19,7 +19,7 @@ package org.apache.flex.utilities.converter.retrievers.types;
/**
* Created by cdutz on 18.05.2014.
*/
-public enum SDKType {
+public enum SdkType {
FLASH,
AIR,
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/95be7411/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 b8fa265..e9c6c07 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
@@ -19,7 +19,7 @@ package org.apache.flex.utilities.converter.retrievers.download;
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.apache.flex.utilities.converter.retrievers.types.SdkType;
import org.apache.flex.utilities.converter.retrievers.utils.ProgressBar;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -50,14 +50,14 @@ public class DownloadRetriever extends BaseRetriever {
public static final String FLEX_INSTALLER_CONFIG_URL =
"http://flex.apache.org/installer/sdk-installer-config-4.0.xml";
- public File retrieve(SDKType type, String version) throws RetrieverException {
+ public File retrieve(SdkType type, String version) throws RetrieverException {
return retrieve(type, version, null);
}
@Override
- public File retrieve(SDKType type, String version, PlatformType platformType) throws RetrieverException {
+ public File retrieve(SdkType type, String version, PlatformType platformType) throws RetrieverException {
try {
- if (type.equals(SDKType.FLASH) || type.equals(SDKType.AIR)) {
+ if (type.equals(SdkType.FLASH) || type.equals(SdkType.AIR)) {
confirmLicenseAcceptance(type);
}
@@ -100,7 +100,7 @@ public class DownloadRetriever extends BaseRetriever {
// Do the extracting.
////////////////////////////////////////////////////////////////////////////////
- if(type.equals(SDKType.FLASH)) {
+ if(type.equals(SdkType.FLASH)) {
return targetFile;
} else {
System.out.println("Extracting archive to temp directory.");
@@ -122,7 +122,7 @@ public class DownloadRetriever extends BaseRetriever {
}
}
- protected String getBinaryUrl(SDKType sdkType, String version, PlatformType platformType)
+ protected String getBinaryUrl(SdkType sdkType, String version, PlatformType platformType)
throws RetrieverException {
try {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -139,7 +139,7 @@ public class DownloadRetriever extends BaseRetriever {
}
final StringBuilder stringBuilder = new StringBuilder();
- if (sdkType == SDKType.FLEX) {
+ if (sdkType == SdkType.FLEX) {
final String path = artifactElement.getAttribute("path");
final String file = artifactElement.getAttribute("file");
if (!path.startsWith("http://")) {
@@ -176,7 +176,7 @@ public class DownloadRetriever extends BaseRetriever {
}
}
- protected String getUrlXpath(SDKType sdkType, String version, PlatformType platformType)
+ protected String getUrlXpath(SdkType sdkType, String version, PlatformType platformType)
throws RetrieverException {
final StringBuilder stringBuilder = new StringBuilder();
switch (sdkType) {
@@ -209,7 +209,7 @@ public class DownloadRetriever extends BaseRetriever {
return stringBuilder.toString();
}
- protected void confirmLicenseAcceptance(SDKType type) throws RetrieverException {
+ protected void confirmLicenseAcceptance(SdkType type) throws RetrieverException {
final Properties questionProps = new Properties();
try {
questionProps.load(DownloadRetriever.class.getClassLoader().getResourceAsStream("message.properties"));
@@ -218,9 +218,9 @@ public class DownloadRetriever extends BaseRetriever {
}
final String question;
- if(type.equals(SDKType.FLASH)) {
+ if(type.equals(SdkType.FLASH)) {
question = questionProps.getProperty("ASK_ADOBE_FLASH_PLAYER_GLOBAL_SWC");
- } else if(type.equals(SDKType.AIR)) {
+ } else if(type.equals(SdkType.AIR)) {
question = questionProps.getProperty("ASK_ADOBE_AIR_SDK");
} else {
throw new RetrieverException("Unknown SDKType");
@@ -283,7 +283,7 @@ public class DownloadRetriever extends BaseRetriever {
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, "14.0", PlatformType.MAC);
// Test the retrieval of Flash SDKs
/*retriever.retrieve(SDKType.FLASH, "10.2");
[27/28] git commit: [flex-utilities] [refs/heads/develop] - Fine
tuned the main pom in preparation of releasing the mavenizer.
Posted by cd...@apache.org.
Fine tuned the main pom in preparation of releasing the mavenizer.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/1eefc9d4
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/1eefc9d4
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/1eefc9d4
Branch: refs/heads/develop
Commit: 1eefc9d444ffd3f0b3585d6c1e760f058e6b0d62
Parents: 4b5f3a7
Author: cdutz <ch...@c-ware.de>
Authored: Sat Aug 30 17:36:03 2014 +0200
Committer: cdutz <ch...@c-ware.de>
Committed: Sat Aug 30 17:36:03 2014 +0200
----------------------------------------------------------------------
mavenizer/pom.xml | 87 +++++++++++++++++++++-----------------------------
1 file changed, 36 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/1eefc9d4/mavenizer/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/pom.xml b/mavenizer/pom.xml
index f56c49b..a1be314 100644
--- a/mavenizer/pom.xml
+++ b/mavenizer/pom.xml
@@ -22,6 +22,12 @@
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</groupId>
+ <artifactId>apache</artifactId>
+ <version>14</version>
+ </parent>
+
<groupId>org.apache.flex.utilities.converter</groupId>
<artifactId>flex-sdk-converter</artifactId>
<version>1.0.0-SNAPSHOT</version>
@@ -33,16 +39,29 @@
<wagonVersion>2.2</wagonVersion>
</properties>
- <distributionManagement>
- <repository>
- <id>apache.releases.https</id>
- <url>https://repository.apache.org/service/local/staging/deploy/maven2</url>
- </repository>
- <snapshotRepository>
- <id>apache.snapshots.https</id>
- <url>https://repository.apache.org/content/repositories/snapshots</url>
- </snapshotRepository>
- </distributionManagement>
+ <mailingLists>
+ <mailingList>
+ <name>Apache Flex User List</name>
+ <subscribe>users-subscribe@flex.apache.org</subscribe>
+ <unsubscribe>users-unsubscribe@flex.apache.org</unsubscribe>
+ <post>users@flex.apache.org</post>
+ <archive>
+ http://mail-archives.apache.org/mod_mbox/flex-users/
+ </archive>
+ </mailingList>
+ </mailingLists>
+
+ <scm>
+ <connection>
+ scm:svn:https://git-wip-us.apache.org/repos/asf/flex-utilities.git
+ </connection>
+ <developerConnection>
+ scm:svn:https://git-wip-us.apache.org/repos/asf/flex-utilities.git
+ </developerConnection>
+ <url>
+ https://git-wip-us.apache.org/repos/asf/flex-utilities.git
+ </url>
+ </scm>
<modules>
<module>core</module>
@@ -53,49 +72,15 @@
<build>
<plugins>
- <!--plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2.2</version>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <archive>
- <manifest>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- <addClasspath>true</addClasspath>
- </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>
+ <source>1.5</source>
+ <target>1.5</target>
+ <encoding>${project.build.sourceEncoding}</encoding>
</configuration>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin-->
- <!-- Commented out because the plugin doesn't seem to work. -->
- <!--plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <version>0.10</version>
- <inherited>false</inherited>
- <executions>
- <execution>
- <phase>verify</phase>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
- </plugin-->
+ </plugin>
</plugins>
</build>
</project>
[09/28] FLEX-34318 - [Mavenizer] Refactor the Mavenizer in
preparation of future mavenized releases of Flex - Moved the SdkDeployer (Now
MavenDeployer) and SdkInVmDeployer (Now AetherDeployer). - Moved the maven
dependencies to the projects they belong t
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/src/main/java/flex/FlexRuntimeGenerator.java
----------------------------------------------------------------------
diff --git a/mavenizer/src/main/java/flex/FlexRuntimeGenerator.java b/mavenizer/src/main/java/flex/FlexRuntimeGenerator.java
deleted file mode 100644
index cdcb9b9..0000000
--- a/mavenizer/src/main/java/flex/FlexRuntimeGenerator.java
+++ /dev/null
@@ -1,205 +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 flex;
-
-import common.BaseGenerator;
-import common.MavenMetadata;
-import org.apache.commons.compress.archivers.ArchiveEntry;
-import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
-import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
-
-import java.io.*;
-import java.text.NumberFormat;
-import java.util.Locale;
-
-/**
- * Created with IntelliJ IDEA.
- * User: cdutz
- * Date: 14.05.12
- * Time: 22:42
- */
-public class FlexRuntimeGenerator extends BaseGenerator {
-
- @Override
- public void process(File sdkSourceDirectory, boolean isApache, File sdkTargetDirectory, String sdkVersion,
- boolean useApache)
- throws Exception
- {
- processFlashRuntime(sdkSourceDirectory, sdkTargetDirectory);
- }
-
- protected void processFlashRuntime(File sdkSourceDirectory, File sdkTargetDirectory)
- throws Exception
- {
- final File runtimeDirectory = new File(sdkSourceDirectory, "runtimes");
- final File flashPlayerDirectory = new File(runtimeDirectory, "player");
-
- File[] versions = flashPlayerDirectory.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.isDirectory() && !"win".equalsIgnoreCase(pathname.getName()) &&
- !"lnx".equalsIgnoreCase(pathname.getName()) && !"mac".equalsIgnoreCase(pathname.getName());
- }
- });
- // The flash-player 9 is installed directly in the player directory.
- if(new File(flashPlayerDirectory, "win").exists()) {
- final File[] extendedVersions = new File[versions.length + 1];
- System.arraycopy(versions, 0, extendedVersions, 0, versions.length);
- extendedVersions[versions.length] = flashPlayerDirectory;
- versions = extendedVersions;
- }
-
- if(versions != null) {
- for(final File versionDir : versions) {
- // If the versionDir is called "player", then this is the home of the flash-player version 9.
- final String playerVersionString = "player".equalsIgnoreCase(versionDir.getName()) ? "9.0" : versionDir.getName();
- final double playerVersion = Double.valueOf(playerVersionString);
- final NumberFormat doubleFormat = NumberFormat.getInstance(Locale.US);
- doubleFormat.setMinimumFractionDigits(1);
- doubleFormat.setMaximumFractionDigits(1);
- final String version = doubleFormat.format(playerVersion);
-
- final File targetDir = new File(sdkTargetDirectory, "com/adobe/flash/runtime/" + version);
-
- // Deploy Windows binaries.
- final File windowsDirectory = new File(versionDir, "win");
- if(windowsDirectory.exists()) {
- // Find out if a flash-player binary exists.
- File flashPlayerBinary = null;
- if(new File(windowsDirectory, "FlashPlayerDebugger.exe").exists()) {
- flashPlayerBinary = new File(windowsDirectory, "FlashPlayerDebugger.exe");
- } else if(new File(windowsDirectory, "FlashPlayer.exe").exists()) {
- flashPlayerBinary = new File(windowsDirectory, "FlashPlayer.exe");
- }
-
- // If a binary exists, copy it to the target and create a pom for it.
- if (flashPlayerBinary != null) {
- if(!targetDir.exists()) {
- if(!targetDir.mkdirs()) {
- throw new RuntimeException("Could not create directory: " + targetDir.getAbsolutePath());
- }
- }
- final File targetFile = new File(targetDir, "/runtime-" + version + "-win.exe");
- copyFile(flashPlayerBinary, targetFile);
- }
- }
-
- // Deploy Mac binaries.
- final File macDirectory = new File(versionDir, "mac");
- if(macDirectory.exists()) {
- // Find out if a flash-player binary exists.
- File flashPlayerBinary = null;
- if(new File(macDirectory, "Flash Player.app.zip").exists()) {
- flashPlayerBinary = new File(macDirectory, "Flash Player.app.zip");
- } else if(new File(macDirectory, "Flash Player Debugger.app.zip").exists()) {
- flashPlayerBinary = new File(macDirectory, "Flash Player Debugger.app.zip");
- }
-
- // If a binary exists, copy it to the target and create a pom for it.
- if (flashPlayerBinary != null) {
- if(!targetDir.exists()) {
- if(!targetDir.mkdirs()) {
- throw new RuntimeException("Could not create directory: " + targetDir.getAbsolutePath());
- }
- }
- final File targetFile = new File(targetDir, "/runtime-" + version + "-mac.zip");
- copyFile(flashPlayerBinary, targetFile);
- }
- }
-
- // Deploy Linux binaries.
- final File lnxDirectory = new File(versionDir, "lnx");
- if(lnxDirectory.exists()) {
- // Find out if a flash-player binary exists.
- File flashPlayerBinary = null;
- if(new File(lnxDirectory, "flashplayer.tar.gz").exists()) {
- flashPlayerBinary = new File(lnxDirectory, "flashplayer.tar.gz");
- } else if(new File(lnxDirectory, "flashplayerdebugger.tar.gz").exists()) {
- flashPlayerBinary = new File(lnxDirectory, "flashplayerdebugger.tar.gz");
- }
-
- // Decompress the archive.
- // First unzip it.
- final FileInputStream fin = new FileInputStream(flashPlayerBinary);
- final BufferedInputStream in = new BufferedInputStream(fin);
- final File tempTarFile = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".tar");
- final FileOutputStream out = new FileOutputStream(tempTarFile);
- final GzipCompressorInputStream gzIn = new GzipCompressorInputStream(in);
- final byte[] buffer = new byte[1024];
- int n;
- while (-1 != (n = gzIn.read(buffer))) {
- out.write(buffer, 0, n);
- }
- out.close();
- gzIn.close();
-
- // Then untar it.
- File uncompressedBinary = null;
- final FileInputStream tarFileInputStream = new FileInputStream(tempTarFile);
- final TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(tarFileInputStream);
- ArchiveEntry entry;
- while((entry = tarArchiveInputStream.getNextEntry()) != null) {
- if("flashplayer".equals(entry.getName())) {
- uncompressedBinary = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".uexe");
- final FileOutputStream uncompressedBinaryOutputStream = new FileOutputStream(uncompressedBinary);
- while(-1 != (n = tarArchiveInputStream.read(buffer))) {
- uncompressedBinaryOutputStream.write(buffer, 0, n);
- }
- uncompressedBinaryOutputStream.close();
- } else if("flashplayerdebugger".equals(entry.getName())) {
- uncompressedBinary = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".uexe");
- final FileOutputStream uncompressedBinaryOutputStream = new FileOutputStream(uncompressedBinary);
- while(-1 != (n = tarArchiveInputStream.read(buffer))) {
- uncompressedBinaryOutputStream.write(buffer, 0, n);
- }
- uncompressedBinaryOutputStream.close();
- }
- }
- tarFileInputStream.close();
-
- // If a binary exists, copy it to the target and create a pom for it.
- if (uncompressedBinary != null) {
- if(!targetDir.exists()) {
- if(!targetDir.mkdirs()) {
- throw new RuntimeException("Could not create directory: " + targetDir.getAbsolutePath());
- }
- }
- final File targetFile = new File(targetDir, "/runtime-" + version + "-linux.uexe");
- copyFile(uncompressedBinary, targetFile);
-
- // Clean up in the temp directory.
- if(!uncompressedBinary.delete()) {
- System.out.println("Could not delete: " + uncompressedBinary.getAbsolutePath());
- }
- }
-
- // Clean up in the temp directory.
- if(!tempTarFile.delete()) {
- System.out.println("Could not delete: " + tempTarFile.getAbsolutePath());
- }
- }
-
- final MavenMetadata playerArtifact = new MavenMetadata();
- playerArtifact.setGroupId("com.adobe.flash");
- playerArtifact.setArtifactId("runtime");
- playerArtifact.setVersion(version);
- playerArtifact.setPackaging("exe");
-
- writeDocument(createPomDocument(playerArtifact), new File(targetDir, "runtime-" + version + ".pom"));
- }
- }
- }
-}
[22/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Added the maven assembly plugin to create the
fat jar that can be executed from the commandl
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Added the maven assembly plugin to create the fat jar that can be executed from the commandline.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/d68f5fa3
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/d68f5fa3
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/d68f5fa3
Branch: refs/heads/develop
Commit: d68f5fa3cae7d9ff1810b2f0de4d6a845277701f
Parents: 908af51
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sat Jul 12 14:14:28 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sat Jul 12 14:14:28 2014 +0200
----------------------------------------------------------------------
mavenizer/deployers/aether/pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/d68f5fa3/mavenizer/deployers/aether/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/deployers/aether/pom.xml b/mavenizer/deployers/aether/pom.xml
index 5e1ffc8..ac7d2bb 100644
--- a/mavenizer/deployers/aether/pom.xml
+++ b/mavenizer/deployers/aether/pom.xml
@@ -42,7 +42,7 @@
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addClasspath>true</addClasspath>
- <mainClass>org.apache.flex.utilities.converter.core.SdkConverter</mainClass>
+ <mainClass>org.apache.flex.utilities.converter.deployer.aether.AetherDeployer</mainClass>
</manifest>
<manifestEntries>
<Implementation-Build>${project.version}</Implementation-Build>
@@ -51,7 +51,7 @@
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
- <finalName>flex-sdk-converter-${project.version}</finalName>
+ <finalName>aether-deployer-${project.version}-full</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
[21/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Added the maven assembly plugin to create the
fat jar that can be executed from the commandl
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Added the maven assembly plugin to create the fat jar that can be executed from the commandline.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/908af514
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/908af514
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/908af514
Branch: refs/heads/develop
Commit: 908af5143e350a5265701578d83274239dcdd811
Parents: 67ded72
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sat Jul 12 13:25:41 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sat Jul 12 13:25:41 2014 +0200
----------------------------------------------------------------------
mavenizer/deployers/aether/pom.xml | 34 +++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/908af514/mavenizer/deployers/aether/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/deployers/aether/pom.xml b/mavenizer/deployers/aether/pom.xml
index 3d68cea..5e1ffc8 100644
--- a/mavenizer/deployers/aether/pom.xml
+++ b/mavenizer/deployers/aether/pom.xml
@@ -32,6 +32,40 @@
<version>1.0.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.SdkConverter</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.eclipse.aether</groupId>
[03/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Added Apache License Headers.
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Added Apache License Headers.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/61d38e9e
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/61d38e9e
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/61d38e9e
Branch: refs/heads/develop
Commit: 61d38e9e3c4dbe3a0c0f6103a81d2d87ed4fcff6
Parents: 5fc9d25
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sun May 11 21:19:36 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sun May 11 21:19:36 2014 +0200
----------------------------------------------------------------------
.../flex/utilities/converter/air/AirConverter.java | 16 ++++++++++++++++
.../flex/utilities/converter/BaseConverter.java | 5 +----
.../apache/flex/utilities/converter/Converter.java | 16 ++++++++++++++++
.../converter/exceptions/ConverterException.java | 16 ++++++++++++++++
.../utilities/converter/model/MavenArtifact.java | 5 +----
.../utilities/converter/flash/FlashConverter.java | 16 ++++++++++++++++
.../utilities/converter/flex/FlexConverter.java | 16 ++++++++++++++++
mavenizer/pom.xml | 16 +++++++++++++++-
8 files changed, 97 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/61d38e9e/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java b/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
index 6212b8b..596ff5c 100644
--- a/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
+++ b/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
@@ -1,3 +1,19 @@
+/*
+ * 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.air;
import org.apache.flex.utilities.converter.BaseConverter;
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/61d38e9e/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
index 8a62f25..6f67c6d 100644
--- a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
+++ b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
@@ -47,10 +47,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
- * Created with IntelliJ IDEA.
- * User: cdutz
- * Date: 11.05.12
- * Time: 14:53
+ * Created by cdutz on 11.05.2012.
*/
public abstract class BaseConverter {
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/61d38e9e/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/Converter.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/Converter.java b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/Converter.java
index 0f94155..5883270 100644
--- a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/Converter.java
+++ b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/Converter.java
@@ -1,3 +1,19 @@
+/*
+ * 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;
import org.apache.flex.utilities.converter.exceptions.ConverterException;
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/61d38e9e/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/exceptions/ConverterException.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/exceptions/ConverterException.java b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/exceptions/ConverterException.java
index 3a0b7c6..384f2fe 100644
--- a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/exceptions/ConverterException.java
+++ b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/exceptions/ConverterException.java
@@ -1,3 +1,19 @@
+/*
+ * 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.exceptions;
/**
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/61d38e9e/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java
index 0dca36c..db5d4de 100644
--- a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java
+++ b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/model/MavenArtifact.java
@@ -23,10 +23,7 @@ import java.util.List;
import java.util.Map;
/**
- * Created with IntelliJ IDEA.
- * User: cdutz
- * Date: 01.07.12
- * Time: 12:31
+ * Created by cdutz on 01.07.2012.
*/
public class MavenArtifact {
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/61d38e9e/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 6ff5462..2981109 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
@@ -1,3 +1,19 @@
+/*
+ * 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.flash;
import org.apache.commons.compress.archivers.ArchiveEntry;
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/61d38e9e/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 658f067..e0a2933 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
@@ -1,3 +1,19 @@
+/*
+ * 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.flex;
import org.apache.flex.utilities.converter.BaseConverter;
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/61d38e9e/mavenizer/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/pom.xml b/mavenizer/pom.xml
index e70008c..21e5fd2 100644
--- a/mavenizer/pom.xml
+++ b/mavenizer/pom.xml
@@ -131,7 +131,7 @@
<build>
<plugins>
- <plugin>
+ <!--plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.2</version>
<configuration>
@@ -159,6 +159,20 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <version>0.10</version>
+ <inherited>false</inherited>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin-->
</plugins>
</build>
</project>
[16/28] git commit: [flex-utilities] [refs/heads/develop] -
Suppressed an empty dependencies element in generated poms
Posted by cd...@apache.org.
Suppressed an empty dependencies element in generated poms
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/7d6c9f6b
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/7d6c9f6b
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/7d6c9f6b
Branch: refs/heads/develop
Commit: 7d6c9f6be5a5179a21184e53e3f4a7911029277b
Parents: 95be741
Author: cdutz <ch...@c-ware.de>
Authored: Thu Jun 26 15:34:37 2014 +0200
Committer: cdutz <ch...@c-ware.de>
Committed: Thu Jun 26 15:34:37 2014 +0200
----------------------------------------------------------------------
mavenizer/converters/base/src/main/resources/templates/default.vm | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/7d6c9f6b/mavenizer/converters/base/src/main/resources/templates/default.vm
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/resources/templates/default.vm b/mavenizer/converters/base/src/main/resources/templates/default.vm
index 7af9619..4bfb60e 100644
--- a/mavenizer/converters/base/src/main/resources/templates/default.vm
+++ b/mavenizer/converters/base/src/main/resources/templates/default.vm
@@ -7,6 +7,7 @@
<version>${artifact.version}</version>
<packaging>${artifact.packaging}</packaging>
+#if ( $artifact.hasDependencies() )
<dependencies>
#foreach( $dependency in $artifact.dependencies )
<dependency>
@@ -17,5 +18,6 @@
</dependency>
#end
</dependencies>
+#end
</project>
[10/28] FLEX-34318 - [Mavenizer] Refactor the Mavenizer in
preparation of future mavenized releases of Flex - Moved the SdkDeployer (Now
MavenDeployer) and SdkInVmDeployer (Now AetherDeployer). - Moved the maven
dependencies to the projects they belong t
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/src/main/java/common/BaseGenerator.java
----------------------------------------------------------------------
diff --git a/mavenizer/src/main/java/common/BaseGenerator.java b/mavenizer/src/main/java/common/BaseGenerator.java
deleted file mode 100644
index 69e3faf..0000000
--- a/mavenizer/src/main/java/common/BaseGenerator.java
+++ /dev/null
@@ -1,389 +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 common;
-
-import java.io.*;
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.util.*;
-import javax.xml.parsers.*;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.*;
-import javax.xml.transform.stream.*;
-import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONObject;
-import org.codehaus.jettison.json.JSONTokener;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-
-/**
- * Created with IntelliJ IDEA.
- * User: cdutz
- * Date: 11.05.12
- * Time: 14:53
- */
-public abstract class BaseGenerator {
-
- protected static final Map<String, MavenMetadata> checksums = new HashMap<String, MavenMetadata>();
-
- protected static final String MAVEN_SCHEMA_URI = "http://maven.apache.org/POM/4.0.0";
- protected static final String MAVEN_CENTRAL_SHA_1_QUERY_URL = "http://search.maven.org/solrsearch/select?rows=20&wt=json&q=1:";
- // Artifactory: "http://server:port/artifactory/api/search/checksum?repos=libs-release-local&md5=04040c7c184620af0a0a8a3682a75eb7
- // Nexus: "http://repository.sonatype.org/service/local/data_index?a=04040c7c184620af0a0a8a3682a75eb7"
-
- abstract public void process(File sdkSourceDirectory, boolean isApache, File sdkTargetDirectory, String sdkVersion, boolean useApache)
- throws Exception;
-
- protected String calculateChecksum(File jarFile) throws Exception {
- // Implement the calculation of checksums for a given jar.
- final MessageDigest digest = MessageDigest.getInstance("SHA-1");
-
- final InputStream is = new FileInputStream(jarFile);
- final byte[] buffer = new byte[8192];
- int read;
- try {
- while( (read = is.read(buffer)) > 0) {
- digest.update(buffer, 0, read);
- }
- final byte[] md5sum = digest.digest();
- final BigInteger bigInt = new BigInteger(1, md5sum);
- return bigInt.toString(16);
- }
- catch(IOException e) {
- throw new RuntimeException("Unable to process file for MD5", e);
- }
- finally {
- try {
- is.close();
- }
- catch(IOException e) {
- //noinspection ThrowFromFinallyBlock
- throw new RuntimeException("Unable to close input stream for MD5 calculation", e);
- }
- }
- }
-
- protected MavenMetadata lookupMetadataForChecksum(String checksum) throws Exception {
- final String queryUrl = MAVEN_CENTRAL_SHA_1_QUERY_URL + checksum;
-
- final Client client = Client.create();
- final WebResource webResource = client.resource(queryUrl);
- final ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);
-
- if (response.getStatus() != 200) {
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- }
-
- final String output = response.getEntity(String.class);
-
- final BufferedReader reader = new BufferedReader(new StringReader(output));
- final StringBuilder builder = new StringBuilder();
- for (String line; (line = reader.readLine()) != null; ) {
- builder.append(line).append("\n");
- }
- final JSONTokener tokener = new JSONTokener(builder.toString());
- final JSONObject rootObject = new JSONObject(tokener);
-
- final JSONObject responseObject = (JSONObject) rootObject.get("response");
- final int numFound = (Integer) responseObject.get("numFound");
- if(numFound == 0) {
- return null;
- }
- else if(numFound == 1) {
- final JSONArray docs = (JSONArray) responseObject.get("docs");
- final JSONObject firstHit = (JSONObject) docs.get(0);
-
- final MavenMetadata artifactMetadata = new MavenMetadata();
- artifactMetadata.groupId = (String) firstHit.get("g");
- artifactMetadata.artifactId = (String) firstHit.get("a");
- artifactMetadata.version = (String) firstHit.get("v");
- artifactMetadata.packaging = (String) firstHit.get("p");
-
- return artifactMetadata;
- } else {
- long newestTimestamp = 0;
- JSONObject newestVersion = null;
-
- JSONArray options = (JSONArray) responseObject.get("docs");
- // if the "groupId" is "batik" then use the newer version.
- for(int i = 0; i < numFound; i++) {
- final JSONObject option = (JSONObject) options.get(0);
- if("batik".equals(option.get("g")) && "batik-dom".equals(option.get("a")) && "jar".equals(option.get("p"))) {
- final long timestamp = (Long) option.get("timestamp");
- if(timestamp > newestTimestamp) {
- newestTimestamp = timestamp;
- newestVersion = option;
- }
- }
- }
-
- if(newestVersion != null) {
- final MavenMetadata artifactMetadata = new MavenMetadata();
- artifactMetadata.groupId = (String) newestVersion.get("g");
- artifactMetadata.artifactId = (String) newestVersion.get("a");
- artifactMetadata.version = (String) newestVersion.get("v");
- artifactMetadata.packaging = (String) newestVersion.get("p");
-
- return artifactMetadata;
- } else {
- System.out.println("For jar-file with checksum: " + checksum +
- " more than one result was returned by query: " + queryUrl);
- }
- }
- return null;
- }
-
- protected void copyFile(File source, File target) throws Exception {
- InputStream in = new FileInputStream(source);
- OutputStream out = new FileOutputStream(target);
-
- byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) > 0){
- out.write(buf, 0, len);
- }
-
- in.close();
- out.close();
- }
-
- protected void appendArtifact(MavenMetadata artifactMetadata, Element dependencies) {
- final Document doc = dependencies.getOwnerDocument();
- final Element dependency = doc.createElementNS(MAVEN_SCHEMA_URI, "dependency");
- dependencies.appendChild(dependency);
-
- final Element groupId = doc.createElementNS(MAVEN_SCHEMA_URI, "groupId");
- groupId.setTextContent(artifactMetadata.groupId);
- dependency.appendChild(groupId);
- final Element artifactId = doc.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
- artifactId.setTextContent(artifactMetadata.artifactId);
- dependency.appendChild(artifactId);
- final Element version = doc.createElementNS(MAVEN_SCHEMA_URI, "version");
- version.setTextContent(artifactMetadata.version);
- dependency.appendChild(version);
- if(!artifactMetadata.getPackaging().equals("jar")) {
- final Element packaging = doc.createElementNS(MAVEN_SCHEMA_URI, "type");
- packaging.setTextContent(artifactMetadata.packaging);
- dependency.appendChild(packaging);
- }
- }
-
- protected void writeDocument(Document doc, File outputFile) throws Exception {
- final Source source = new DOMSource(doc);
- final File outputDirectory = outputFile.getParentFile();
- if(!outputDirectory.exists()) {
- if(!outputDirectory.mkdirs()) {
- throw new RuntimeException("Could not create directory: " + outputDirectory.getAbsolutePath());
- }
- }
-
- final Result result = new StreamResult(outputFile);
- final Transformer transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
- transformer.transform(source, result);
- }
-
- protected Document createPomDocument(final MavenMetadata metadata) throws Exception {
- final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- final DocumentBuilder builder = factory.newDocumentBuilder();
- DOMImplementation domImpl = builder.getDOMImplementation();
- final Document pom = domImpl.createDocument(MAVEN_SCHEMA_URI, "project", null);
-
- final Element root = pom.getDocumentElement();
- final Element modelVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "modelVersion");
- modelVersion.setTextContent("4.0.0");
- root.appendChild(modelVersion);
- final Element groupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
- groupId.setTextContent(metadata.groupId);
- root.appendChild(groupId);
- final Element artifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
- artifactId.setTextContent(metadata.artifactId);
- root.appendChild(artifactId);
- final Element version = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
- version.setTextContent(metadata.version);
- root.appendChild(version);
- final Element packaging = pom.createElementNS(MAVEN_SCHEMA_URI, "packaging");
- packaging.setTextContent(metadata.packaging);
- root.appendChild(packaging);
-
- // Output dependency data.
- if((metadata.dependencies != null) && !metadata.dependencies.isEmpty()) {
- final Element dependencies = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencies");
- root.appendChild(dependencies);
-
- final Map<String, MavenMetadata> dependencyIndex = new HashMap<String, MavenMetadata>();
- for(final MavenMetadata dependencyMetadata : metadata.dependencies) {
- final Element dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
- dependencies.appendChild(dependency);
-
- final Element dependencyGroupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
- dependencyGroupId.setTextContent(dependencyMetadata.groupId);
- dependency.appendChild(dependencyGroupId);
- final Element dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
- dependencyArtifactId.setTextContent(dependencyMetadata.artifactId);
- dependency.appendChild(dependencyArtifactId);
- final Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
- dependencyVersion.setTextContent(dependencyMetadata.version);
- dependency.appendChild(dependencyVersion);
- final Element dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
- dependencyPackaging.setTextContent(dependencyMetadata.packaging);
- dependency.appendChild(dependencyPackaging);
- if(dependencyMetadata.classifier != null) {
- final Element dependencyClassifier = pom.createElementNS(MAVEN_SCHEMA_URI, "classifier");
- dependencyClassifier.setTextContent(dependencyMetadata.classifier);
- dependency.appendChild(dependencyClassifier);
- }
-
- dependencyIndex.put(dependencyMetadata.artifactId, dependencyMetadata);
- }
-
- // Output the rb.swc dependencies.
- if(metadata.librariesWithResourceBundles != null) {
- for(final String artifactWithResourceBundle : metadata.librariesWithResourceBundles) {
- final MavenMetadata dependencyMetadata = dependencyIndex.get(artifactWithResourceBundle);
- if(dependencyMetadata != null) {
- final Element dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
- dependencies.appendChild(dependency);
-
- final Element dependencyGroupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
- dependencyGroupId.setTextContent(dependencyMetadata.groupId);
- dependency.appendChild(dependencyGroupId);
- final Element dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
- dependencyArtifactId.setTextContent(dependencyMetadata.artifactId);
- dependency.appendChild(dependencyArtifactId);
- final Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
- dependencyVersion.setTextContent(dependencyMetadata.version);
- dependency.appendChild(dependencyVersion);
- final Element dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
- dependencyPackaging.setTextContent("rb.swc");
- dependency.appendChild(dependencyPackaging);
- }
- }
- }
- }
-
- return pom;
- }
-
- protected Document createPomDocumentDependencyManagement(final MavenMetadata metadata) throws Exception {
- final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- final DocumentBuilder builder = factory.newDocumentBuilder();
- DOMImplementation domImpl = builder.getDOMImplementation();
- final Document pom = domImpl.createDocument(MAVEN_SCHEMA_URI, "project", null);
-
- final Element root = pom.getDocumentElement();
- final Element modelVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "modelVersion");
- modelVersion.setTextContent("4.0.0");
- root.appendChild(modelVersion);
- final Element groupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
- groupId.setTextContent(metadata.groupId);
- root.appendChild(groupId);
- final Element artifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
- artifactId.setTextContent(metadata.artifactId);
- root.appendChild(artifactId);
- final Element version = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
- version.setTextContent(metadata.version);
- root.appendChild(version);
- final Element packaging = pom.createElementNS(MAVEN_SCHEMA_URI, "packaging");
- packaging.setTextContent(metadata.packaging);
- root.appendChild(packaging);
-
- // Output dependency data.
- if((metadata.dependencies != null) && !metadata.dependencies.isEmpty()) {
- final Element dependencyManagement = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencyManagement");
- root.appendChild(dependencyManagement);
- final Element dependencies = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencies");
- dependencyManagement.appendChild(dependencies);
-
- final Map<String, MavenMetadata> dependencyIndex = new HashMap<String, MavenMetadata>();
- for(final MavenMetadata dependencyMetadata : metadata.dependencies) {
- final Element dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
- dependencies.appendChild(dependency);
-
- final Element dependencyGroupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
- dependencyGroupId.setTextContent(dependencyMetadata.groupId);
- dependency.appendChild(dependencyGroupId);
- final Element dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
- dependencyArtifactId.setTextContent(dependencyMetadata.artifactId);
- dependency.appendChild(dependencyArtifactId);
- final Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
- dependencyVersion.setTextContent(dependencyMetadata.version);
- dependency.appendChild(dependencyVersion);
- final Element dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
- dependencyPackaging.setTextContent(dependencyMetadata.packaging);
- dependency.appendChild(dependencyPackaging);
- if(dependencyMetadata.classifier != null) {
- final Element dependencyClassifier = pom.createElementNS(MAVEN_SCHEMA_URI, "classifier");
- dependencyClassifier.setTextContent(dependencyMetadata.classifier);
- dependency.appendChild(dependencyClassifier);
- }
-
- dependencyIndex.put(dependencyMetadata.artifactId, dependencyMetadata);
- }
-
- // Output the rb.swc dependencies.
- for(final String artifactWithResourceBundle : metadata.librariesWithResourceBundles) {
- final MavenMetadata dependencyMetadata = dependencyIndex.get(artifactWithResourceBundle);
- if(dependencyMetadata != null) {
- final Element dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
- dependencies.appendChild(dependency);
-
- final Element dependencyGroupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
- dependencyGroupId.setTextContent(dependencyMetadata.groupId);
- dependency.appendChild(dependencyGroupId);
- final Element dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
- dependencyArtifactId.setTextContent(dependencyMetadata.artifactId);
- dependency.appendChild(dependencyArtifactId);
- final Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
- dependencyVersion.setTextContent(dependencyMetadata.version);
- dependency.appendChild(dependencyVersion);
- final Element dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
- dependencyPackaging.setTextContent("rb.swc");
- dependency.appendChild(dependencyPackaging);
- }
- }
- }
-
- return pom;
- }
-
- protected static File findDirectory(File directory, String directoryToFind) {
- File[] entries = directory.listFiles();
- File founded = null;
-
- // Go over entries
- for (File entry : entries) {
- if (entry.isDirectory() && directoryToFind.equalsIgnoreCase(entry.getName())) {
- founded = entry;
- break;
- }
- if (entry.isDirectory()) {
- founded = findDirectory(entry, directoryToFind);
- if (founded != null)
- break;
- }
- }
- return founded;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/src/main/java/common/MavenMetadata.java
----------------------------------------------------------------------
diff --git a/mavenizer/src/main/java/common/MavenMetadata.java b/mavenizer/src/main/java/common/MavenMetadata.java
deleted file mode 100644
index b267444..0000000
--- a/mavenizer/src/main/java/common/MavenMetadata.java
+++ /dev/null
@@ -1,91 +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 common;
-
-import java.util.List;
-
-/**
- * Created with IntelliJ IDEA.
- * User: cdutz
- * Date: 01.07.12
- * Time: 12:31
- */
-public class MavenMetadata {
- protected String groupId;
- protected String artifactId;
- protected String version;
- protected String packaging;
- protected String classifier;
- protected List<String> librariesWithResourceBundles;
- protected List<MavenMetadata> dependencies;
-
- public String getGroupId() {
- return groupId;
- }
-
- public void setGroupId(String groupId) {
- this.groupId = groupId;
- }
-
- public String getArtifactId() {
- return artifactId;
- }
-
- public void setArtifactId(String artifactId) {
- this.artifactId = artifactId;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getPackaging() {
- return packaging;
- }
-
- public void setPackaging(String packaging) {
- this.packaging = packaging;
- }
-
- public String getClassifier() {
- return classifier;
- }
-
- public void setClassifier(String classifier) {
- this.classifier = classifier;
- }
-
- public List<String> getLibrariesWithResourceBundles() {
- return librariesWithResourceBundles;
- }
-
- public void setLibrariesWithResourceBundles(List<String> librariesWithResourceBundles) {
- this.librariesWithResourceBundles = librariesWithResourceBundles;
- }
-
- public List<MavenMetadata> getDependencies() {
- return dependencies;
- }
-
- public void setDependencies(List<MavenMetadata> dependencies) {
- this.dependencies = dependencies;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/src/main/java/flex/FlexCompilerGenerator.java
----------------------------------------------------------------------
diff --git a/mavenizer/src/main/java/flex/FlexCompilerGenerator.java b/mavenizer/src/main/java/flex/FlexCompilerGenerator.java
deleted file mode 100644
index 17be1ce..0000000
--- a/mavenizer/src/main/java/flex/FlexCompilerGenerator.java
+++ /dev/null
@@ -1,246 +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 flex;
-
-import java.io.*;
-import java.util.*;
-import java.util.zip.*;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import common.BaseGenerator;
-import common.MavenMetadata;
-
-/**
- * Created with IntelliJ IDEA.
- * User: cdutz
- * Date: 11.05.12
- * Time: 14:53
- */
-public class FlexCompilerGenerator extends BaseGenerator {
-
- public void process(final File sdkSourceDirectory, final boolean isApache, final File sdkTargetDirectory,
- final String sdkVersion, boolean useApache)
- throws Exception {
-
- final File sdkCompilerLibsDirectory = new File(sdkSourceDirectory, "lib");
- final List<File> jars = new ArrayList<File>();
- // In the Adobe Flex SDKs there can be 3 jars, that are actually part of the air sdk, so we manually
- // exclude these from the flex-compiler.
- jars.addAll(Arrays.asList(sdkCompilerLibsDirectory.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".jar") && !(name.equalsIgnoreCase("adt.jar") ||
- name.equalsIgnoreCase("baksmali.jar") || name.equalsIgnoreCase("smali.jar"));
- }
- })));
-
- // The Apache SDKs have an additional "external" directory
- // containing external libs. These have to be added too.
- final File externalLibsDirectory = new File(sdkCompilerLibsDirectory, "external");
- if(externalLibsDirectory.exists() && externalLibsDirectory.isDirectory()) {
- final File[] externalJars = externalLibsDirectory.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".jar");
- }
- });
- jars.addAll(Arrays.asList(externalJars));
- }
-
- // The Apache SDKs have an additional "optional" directory
- // containing external libs. These have to be added too.
- final File optionalLibsDirectory = new File(externalLibsDirectory, "optional");
- if (optionalLibsDirectory.exists() && optionalLibsDirectory.isDirectory()) {
- final File[] optionalJars = optionalLibsDirectory.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".jar");
- }
- });
- jars.addAll(Arrays.asList(optionalJars));
- }
-
- // A pom artifact will be generated that has all libs as a dependency.
- final MavenMetadata metadata = new MavenMetadata();
- metadata.setGroupId((isApache && useApache) ? "org.apache.flex" : "com.adobe.flex");
- metadata.setArtifactId("compiler");
- metadata.setVersion(sdkVersion);
- metadata.setPackaging("pom");
-
- // Create an empty pom document.
- final Document pom = createPomDocument(metadata);
-
- // Get the root element, as we will be adding the dependencies to that.
- final Element root = pom.getDocumentElement();
- // Add a "dependencies" element.
- final Element dependencies = pom.createElementNS(BaseGenerator.MAVEN_SCHEMA_URI, "dependencies");
- root.appendChild(dependencies);
-
- // Generate artifacts for every jar in the input directories.
- for(final File sourceJarFile : jars) {
- // Calculate a checksum for the current file. We will use this checksum to query maven central
- // in order to find out if this lib has already been published. If it has, there is no need to
- // publish it again under a new name. In case a matching artifact is found the generated FDK
- // will use the already deployed version. Additionally the checksum will be saved and if a
- // fdk generated after this one uses the same version of a lib, the version of the older fdk is
- // used also reducing the amount of jars that have to be re-deployed.
- final String checksum = calculateChecksum(sourceJarFile);
-
- // Try to get artifact metadata based upon the checksum by looking up the internal cache.
- MavenMetadata artifactMetadata = BaseGenerator.checksums.get(checksum);
- // Reusing artifact from other sdk version.
- if(artifactMetadata != null) {
- System.out.println("Reusing artifact (" + checksum + ") : " + artifactMetadata.getGroupId() + ":" +
- artifactMetadata.getArtifactId() + ":" + artifactMetadata.getVersion());
- appendArtifact(artifactMetadata, dependencies);
- }
- // Id no artifact was found in the local cache, continue processing.
- else {
- // Do a lookup in maven central.
- artifactMetadata = lookupMetadataForChecksum(checksum);
-
- // The file was available on maven central, so use that version instead of the one coming with the sdk.
- if(artifactMetadata != null) {
- appendArtifact(artifactMetadata, dependencies);
- }
- // The file was not available on maven central, so we have to add it manually.
- else {
- // The artifact name is the name of the jar.
- final String dependencyArtifactId =
- sourceJarFile.getName().substring(0, sourceJarFile.getName().lastIndexOf("."));
-
- // Generate a new metadata object
- artifactMetadata = new MavenMetadata();
- artifactMetadata.setGroupId((isApache && useApache) ? "org.apache.flex.compiler" :
- "com.adobe.flex.compiler");
- artifactMetadata.setArtifactId(dependencyArtifactId);
- artifactMetadata.setVersion(sdkVersion);
- artifactMetadata.setPackaging("jar");
-
- // Create the name of the directory that will contain the artifact.
- final File targetJarDirectory = new File(sdkTargetDirectory,
- ((isApache && useApache) ? "org/apache/flex/compiler/" : "com/adobe/flex/compiler/") +
- artifactMetadata.getArtifactId() + "/" + artifactMetadata.getVersion());
- // Create the directory.
- if(targetJarDirectory.mkdirs()) {
- // Create the filename of the artifact.
- final File targetJarFile = new File(targetJarDirectory, artifactMetadata.getArtifactId() + "-" +
- artifactMetadata.getVersion() + "." + artifactMetadata.getPackaging());
-
- // Copy the file to it's destination.
- copyFile(sourceJarFile, targetJarFile);
-
- // Add the dependency to the compiler-poms dependency section.
- appendArtifact(artifactMetadata, dependencies);
- } else {
- throw new RuntimeException("Could not create directory: " +
- targetJarDirectory.getAbsolutePath());
- }
-
- // Create the pom document that will reside next to the artifact lib.
- final Document artifactPom = createPomDocument(artifactMetadata);
- final File artifactPomFile =
- new File(targetJarDirectory, dependencyArtifactId + "-" + sdkVersion + ".pom");
- writeDocument(artifactPom, artifactPomFile);
-
- // The asdoc library needs us to zip up an additional directory and
- // deploy that as "asdoc-{version}-template.zip"
- if("asdoc".equals(dependencyArtifactId)) {
- final File asdocTemplatesDirectory = new File(sdkSourceDirectory, "asdoc/templates");
- if(asdocTemplatesDirectory.exists()) {
- createAsdocTemplatesZip(asdocTemplatesDirectory, targetJarDirectory, sdkVersion);
- }
- }
- }
-
- // Remember the checksum for later re-usage.
- BaseGenerator.checksums.put(checksum, artifactMetadata);
- }
- }
-
- // Add a reference to the versions pom of the framework. This is needed so the compiler can check which
- // versions of the framework libs belong to the current compiler version. This is especially needed to
- // perform the check if the correct version of framework.swc is included in the dependencies. This step
- // was needed due to the re-deployment of patched FDKs in 2011/2012 in which the framework.swc no longer
- // has the same version as the compiler.
- final MavenMetadata frameworkVersions = new MavenMetadata();
- frameworkVersions.setGroupId((isApache && useApache) ? "org.apache.flex" : "com.adobe.flex");
- frameworkVersions.setArtifactId("framework");
- frameworkVersions.setVersion(sdkVersion);
- frameworkVersions.setPackaging("pom");
- appendArtifact(frameworkVersions, dependencies);
-
- // Write the compiler-pom document to file.
- final File pomFile = new File(sdkTargetDirectory,
- ((isApache && useApache) ? "org/apache/flex/compiler/" : "com/adobe/flex/compiler/") +
- sdkVersion + "/compiler-" + sdkVersion + ".pom");
- writeDocument(pom, pomFile);
- }
-
- /**
- * Zips up the stuff in the asdoc templates directory.
- *
- * @param asdocTemplatesDirectory asdoc templates directory
- * @param asdocDestinationDir directory containing the asdoc lib
- * @param asdocVersion version of the asdoc lib
- * @throws Exception
- */
- private void createAsdocTemplatesZip(File asdocTemplatesDirectory, File asdocDestinationDir, String asdocVersion)
- throws Exception {
- // ZIP up every file (not directory) in the framework directory and the entire themes directory.
- final File sourceFiles[] = asdocTemplatesDirectory.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.isFile();
- }
- });
- final File zipInputFiles[] = new File[sourceFiles.length + 1];
- System.arraycopy(sourceFiles, 0, zipInputFiles, 0, sourceFiles.length);
- final File imagesDirectory = new File(asdocTemplatesDirectory, "images");
- zipInputFiles[sourceFiles.length] = imagesDirectory;
-
- // Add all the content to a zip-file.
- final File targetFile = new File(asdocDestinationDir,
- "asdoc-" + asdocVersion + "-template.zip");
- final ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(targetFile));
- for(final File file : zipInputFiles) {
- addFileToZip(zipOutputStream, file, asdocTemplatesDirectory);
- }
- zipOutputStream.close();
- }
-
- private void addFileToZip(ZipOutputStream zipOutputStream, File inputFile, File rootDirectory) throws Exception {
- // If this is a directory, add all it's children.
- if(inputFile.isDirectory()) {
- final File directoryContent[] = inputFile.listFiles();
- if(directoryContent != null) {
- for(final File file : directoryContent) {
- addFileToZip(zipOutputStream, file, rootDirectory);
- }
- }
- }
- // If this is a file, add it to the zips output.
- else {
- byte[] buf = new byte[1024];
- final FileInputStream in = new FileInputStream(inputFile);
- final String zipPath = inputFile.getAbsolutePath().substring(rootDirectory.getAbsolutePath().length() + 1);
- zipOutputStream.putNextEntry(new ZipEntry(zipPath));
- int len;
- while ((len = in.read(buf)) > 0) {
- zipOutputStream.write(buf, 0, len);
- }
- zipOutputStream.closeEntry();
- in.close();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/src/main/java/flex/FlexFrameworkGenerator.java
----------------------------------------------------------------------
diff --git a/mavenizer/src/main/java/flex/FlexFrameworkGenerator.java b/mavenizer/src/main/java/flex/FlexFrameworkGenerator.java
deleted file mode 100644
index cd8ed47..0000000
--- a/mavenizer/src/main/java/flex/FlexFrameworkGenerator.java
+++ /dev/null
@@ -1,844 +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 flex;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.jar.JarOutputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import common.BaseGenerator;
-import common.MavenMetadata;
-
-/**
- * Created with IntelliJ IDEA.
- * User: cdutz
- * Date: 11.05.12
- * Time: 14:55
- *
- * @author Christofer Dutz
- * @author Jose Barragan
- */
-public class FlexFrameworkGenerator extends BaseGenerator {
-
- protected Map<String, String> libraryVersions = new HashMap<String, String>();
- protected Map<String, String> libraryLocations = new HashMap<String, String>();
- protected List<String> librariesWithLocales = new ArrayList<String>();
-
- protected static final List<String> skipArtifacts;
-
- static {
- skipArtifacts = new ArrayList<String>();
- //skipArtifacts.add("playerglobal.swc");
- skipArtifacts.add("aircore.swc");
- skipArtifacts.add("airglobal.swc");
- skipArtifacts.add("applicationupdater.swc");
- skipArtifacts.add("applicationupdater_ui.swc");
- skipArtifacts.add("servicemonitor.swc");
- // The Flex 4.0.0.14159A contains a strange "flex3" directory in the air framework.
- // Simply skip this.
- skipArtifacts.add("flex3");
- }
-
- public void process(File sdkSourceDirectory, final boolean isApache, File sdkTargetDirectory, String sdkVersion,
- boolean useApache)
- throws Exception {
- final File frameworksDirectory = new File(sdkSourceDirectory, "frameworks");
- final File rslsDirectory = new File(frameworksDirectory, "rsls");
- final File targetBaseDirectory = new File(sdkTargetDirectory,
- (isApache && useApache) ? "org/apache/flex/framework" : "com/adobe/flex/framework");
-
- // Look at the RSLs first, as these have version numbers.
- // This makes it possible to deploy the swcs with the correct versions.
- // textLayout and osmf have different versions than the rest of the sdk.
- // Unfortunately we cannot deploy them yet, because the location of the
- // swz and swf will be determined by the location of the swc.
- final String[] rslNames = rslsDirectory.list(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".swf");
- }
- });
- if (rslNames != null) {
- for (final String rslName : rslNames) {
- final String libraryName = rslName.substring(0, rslName.lastIndexOf("_"));
- final String libraryVersion = rslName.substring(rslName.lastIndexOf("_") + 1, rslName.lastIndexOf("."));
- libraryVersions.put(libraryName, libraryVersion);
- }
- }
-
- // Find out which locales are generally available and which libraries have locale information.
- final File localeDirectory = new File(frameworksDirectory, "locale");
- final List<String> locales = new ArrayList<String>();
- final File[] localesDirectories = localeDirectory.listFiles();
- if (localesDirectories != null) {
- for (final File locale : localesDirectories) {
- if (locale.isDirectory()) {
- final String localeCode = locale.getName();
- locales.add(localeCode);
-
- for (final File library : locale.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.getName().endsWith("_rb.swc");
- }
- })) {
- final String libraryName = library.getName().substring(0, library.getName().lastIndexOf("_"));
- if (!librariesWithLocales.contains(libraryName)) {
- librariesWithLocales.add(libraryName);
- }
- }
- }
- }
- }
-
- // Generate the artifacts based upon the structure of the libraries in the lib-directory.
- final File swcsDirectory = new File(frameworksDirectory, "libs");
- generateArtifactsForDirectory(swcsDirectory, targetBaseDirectory, sdkVersion,
- (isApache && useApache) ? "org.apache.flex.framework" : "com.adobe.flex.framework",
- false, isApache && useApache);
-
- // Deploy the playerglobal in it's own groupId as this is not directly linked to flex.
- final File playerRootDirectory = new File(sdkTargetDirectory, "com/adobe/flash");
- generatePlayerglobalArtifacts(new File(swcsDirectory, "player"), new File(playerRootDirectory, "framework"));
- final String minimumFlashPlayerVersion = getMinimumPlayerVersion(frameworksDirectory);
- generateFlexFrameworkPom(targetBaseDirectory, sdkVersion, isApache && useApache, minimumFlashPlayerVersion);
-
- // After processing the swcs the locations for the libraries will be
- // available and the swfs and swzs can be deployed.
- if (rslNames != null) {
- for (final String rslName : rslNames) {
- final String libraryName = rslName.substring(0, rslName.lastIndexOf("_"));
- final String libraryVersion = libraryVersions.get(libraryName);
- final String libraryLocation = libraryLocations.get(libraryName);
- // Only if a lib has been deployed the corresponding swfs and swzs are deployed too.
- if (libraryLocation != null) {
- final String swzName = rslName.substring(0, rslName.lastIndexOf(".")) + ".swz";
- final File swzSourceFile = new File(rslsDirectory, swzName);
- // Apache SDKs don't come with swz files.
- if (swzSourceFile.exists()) {
- final File swzTargetFile = new File(libraryLocation + "/" + libraryName + "-" +
- libraryVersion + ".swz");
- copyFile(swzSourceFile, swzTargetFile);
- }
-
- final File rslSourceFile = new File(rslsDirectory, rslName);
- final File rslTargetFile = new File(libraryLocation + "/" + libraryName + "-" +
- libraryVersion + ".swf");
- copyFile(rslSourceFile, rslTargetFile);
- }
- }
- }
-
- // For every library available, try to copy existing resource bundles.
- for (final String libraryName : libraryLocations.keySet()) {
- final String libraryVersion = libraryVersions.get(libraryName);
- final File targetDirectory = new File(libraryLocations.get(libraryName));
- boolean atLeastOneResourceBundleCopied = false;
- for (final String localeCode : locales) {
- final File resourceBundle = new File(localeDirectory, localeCode + "/" + libraryName + "_rb.swc");
- if (resourceBundle.exists() && resourceBundle.isFile()) {
- if (libraryLocations.get(libraryName) != null) {
- final File targetFile = new File(targetDirectory, libraryName + "-" + libraryVersion + "-" +
- localeCode + ".rb.swc");
-
- copyFile(resourceBundle, targetFile);
-
- atLeastOneResourceBundleCopied = true;
- }
- }
- }
-
- if (atLeastOneResourceBundleCopied) {
- // Add the swc.rb dependency to the pom.
-
- // Generate the strange 1kb rb.swc
- final File dummyRbFile = new File(targetDirectory, libraryName + "-" + libraryVersion + ".rb.swc");
- writeDummyResourceBundleSwc(dummyRbFile);
- }
- }
-
- // Zip up the general framework config files to a single zip and deploy
- // it alongside with the framework jar.
- createConfigsZip(frameworksDirectory);
-
- // For every library available, to zip existing sources.
- for (final String libraryName : libraryLocations.keySet()) {
- final File librarySrcRootPath = new File(frameworksDirectory, "projects/" + libraryName);
- File librarySourcePath = new File(librarySrcRootPath, "src");
-
- if (!librarySourcePath.exists()) {
- librarySourcePath = librarySrcRootPath;
- }
-
- if (librarySourcePath != null && librarySourcePath.listFiles() != null) {
- final File sourceFiles[] = librarySourcePath.listFiles();
- if (sourceFiles != null) {
- final File zipInputFiles[] = new File[sourceFiles.length + 1];
- System.arraycopy(sourceFiles, 0, zipInputFiles, 0, sourceFiles.length);
-
- final File targetFinalDirectory = findDirectory(targetBaseDirectory, libraryName);
-
- if (targetFinalDirectory != null) {
- // Add all the content to a zip-file.
- final File targetFile = new File(targetFinalDirectory,
- libraryVersions.get(libraryName) + "/" + libraryName + "-" +
- libraryVersions.get(libraryName)
- + "-sources.jar");
- JarOutputStream jar = new JarOutputStream(new FileOutputStream(targetFile));
- for (final File file : zipInputFiles) {
- addFileToZip(jar, file, librarySourcePath);
- }
- jar.close();
- }
- }
- }
- }
-
- // Deploy all the swcs in the themes directory.
- final File themesSrcDirectory = new File(frameworksDirectory, "themes");
- if(themesSrcDirectory.exists()) {
- generateThemeArtifacts(themesSrcDirectory, targetBaseDirectory, sdkVersion, isApache && useApache);
- }
-
- // Deploy MXFTEText theme
- final File mxfteThemeCss = new File(frameworksDirectory, "projects" + File.separator + "spark" + File.separator + "MXFTEText.css");
- if(mxfteThemeCss.exists()){
- generateMxFteThemeArtifact(mxfteThemeCss, targetBaseDirectory, sdkVersion, isApache && useApache);
- }
- }
-
- protected void generateArtifactsForDirectory(final File sourceDirectory, final File targetDirectory,
- final String sdkVersion, final String groupId,
- boolean skipGroupPomGeneration, final boolean isApache)
- throws Exception {
- final MavenMetadata groupMetadata = new MavenMetadata();
- groupMetadata.setGroupId(groupId.substring(0, groupId.lastIndexOf(".")));
- groupMetadata.setArtifactId(groupId.substring(groupId.lastIndexOf(".") + 1, groupId.length()));
- groupMetadata.setVersion(sdkVersion);
- groupMetadata.setPackaging("pom");
- groupMetadata.setLibrariesWithResourceBundles(new ArrayList<String>());
- groupMetadata.setDependencies(new ArrayList<MavenMetadata>());
-
- // Don't deploy the player, as this has to be dealt with differently.
- final File[] directoryContent = sourceDirectory.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- if (pathname.isDirectory()) {
- // Skip the player directory as this contains the playerglobal
- // versions which we want to deploy at a different location.
- return !"player".equals(pathname.getName());
- } else {
- // In the flex 2 sdk the playerglobal is located
- // directly in the framework directory.
- return !("playerglobal.swc".equals(pathname.getName()) && "libs".equals(
- pathname.getParentFile().getName())) && pathname.getName()
- .endsWith(".swc");
- }
- }
- });
-
- if (directoryContent != null) {
- for (File file : directoryContent) {
- // The Adobe sdks contain some stuff that should not be deployed
- // with the rest as they belong to the flashplayer or the air-sdk.
- if (!skipArtifacts.contains(file.getName())) {
- final MavenMetadata metadata = new MavenMetadata();
- metadata.setGroupId(groupId);
- // If the current entry is a directory, generate artifacts for that
- // except for the mx directory. For this we output the one mx.swc in
- // the same level as the rest of the flex sdk.
- if (file.isDirectory() && !"mx".equals(file.getName())) {
- generateArtifactsForDirectory(file, new File(
- targetDirectory, file.getName()), sdkVersion, groupId + "." + file.getName(),
- skipGroupPomGeneration, isApache);
- }
- // If it's a file, generate the artifact for it.
- else {
- String libraryName;
- // If this is the mx directory, redirect to the mx.swc inside that directory.
- if ("mx".equals(file.getName()) && file.isDirectory()) {
- libraryName = "mx";
- file = new File(file, "mx.swc");
- } else {
- libraryName = file.getName().substring(0, file.getName().lastIndexOf("."));
- }
- // If an artifact contained a concrete version for the given library
- // (specified by the swz files), use that version. Else just use the
- // sdk version.
- String libraryVersion = libraryVersions.get(libraryName);
- if ((libraryVersion == null) || ("playerglobal".equals(libraryName))) {
- libraryVersion = sdkVersion;
- }
-
- // Create the target directory that will contain the swc, swf, swc, resource files and pom.
- final File targetSwcDirectory = new File(targetDirectory, libraryName + "/" + libraryVersion);
- if (!targetSwcDirectory.exists()) {
- if (!targetSwcDirectory.mkdirs()) {
- throw new RuntimeException("Could not create directory: " +
- targetSwcDirectory.getAbsolutePath());
- }
- }
-
- // Create the target file and copy the library there.
- final File targetSwcFile =
- new File(targetSwcDirectory, libraryName + "-" + libraryVersion + ".swc");
- copyFile(file, targetSwcFile);
-
- // Populate the metadata for the current artifact.
- metadata.setArtifactId(libraryName);
- metadata.setVersion(libraryVersion);
- metadata.setPackaging("swc");
-
- // Generate the pom for the current artifact.
- generateSwcPom(targetSwcFile, metadata);
-
- // Add the current artifact to the artifact-group it belongs to.
- // Usually there is one artifact-group for each directory level.
- // A group usually consists of one "commons" pom-artifact binding
- // all the artifact versions that were in the same sdk and one
- // dependency-management pom that can be used to automatically
- // handle the dependency versions.
- groupMetadata.getDependencies().add(metadata);
-
- // For the framework library an additional dependency has to be added.
- if ("framework".equals(libraryName)) {
- final MavenMetadata frameworkConfigMetadata = new MavenMetadata();
- frameworkConfigMetadata.setGroupId(metadata.getGroupId());
- frameworkConfigMetadata.setArtifactId(metadata.getArtifactId());
- frameworkConfigMetadata.setVersion(metadata.getVersion());
- frameworkConfigMetadata.setPackaging("zip");
- frameworkConfigMetadata.setClassifier("configs");
-
- groupMetadata.getDependencies().add(frameworkConfigMetadata);
- }
-
- libraryLocations.put(libraryName, targetSwcDirectory.getAbsolutePath());
- libraryVersions.put(libraryName, libraryVersion);
- }
- }
- }
- }
-
- if (!skipGroupPomGeneration) {
- // Add the names of libraries that have resource bundles to the list,
- // so the "rb.swc" dependencies can be generated.
- for (final MavenMetadata dependency : groupMetadata.getDependencies()) {
- if (!"pom".equals(dependency.getPackaging())) {
- if (librariesWithLocales.contains(dependency.getArtifactId())) {
- groupMetadata.getLibrariesWithResourceBundles().add(dependency.getArtifactId());
- }
- }
- }
-
- // Generate a "flex-framework" and "flex-common" artifact defining all
- // the dependencies the same way velos sdks did.
- if ("libs".equals(sourceDirectory.getName())) {
- final MavenMetadata commonFrameworkMetaData = new MavenMetadata();
- commonFrameworkMetaData.setGroupId(groupId);
- commonFrameworkMetaData.setArtifactId("common-framework");
- commonFrameworkMetaData.setVersion(groupMetadata.getVersion());
- commonFrameworkMetaData.setPackaging("pom");
- commonFrameworkMetaData.setDependencies(new ArrayList<MavenMetadata>());
- commonFrameworkMetaData.setLibrariesWithResourceBundles(new ArrayList<String>());
-
- for (final MavenMetadata dependency : groupMetadata.getDependencies()) {
- commonFrameworkMetaData.getDependencies().add(dependency);
- if (groupMetadata.getLibrariesWithResourceBundles().contains(dependency.getArtifactId())) {
- commonFrameworkMetaData.getLibrariesWithResourceBundles().add(dependency.getArtifactId());
- }
- }
- final File commonFrameworkPom = new File(targetDirectory, "common-framework/" +
- groupMetadata.getVersion() + "/common-framework-" +
- groupMetadata.getVersion() + ".pom");
- generateSwcPom(commonFrameworkPom, commonFrameworkMetaData);
-
- // Generate a dummy entry for the "flex-framework" pom,
- // which will be generated later in the process.
- final MavenMetadata flexFrameworkMetadata = new MavenMetadata();
- flexFrameworkMetadata.setGroupId(groupId);
- flexFrameworkMetadata.setArtifactId("flex-framework");
- flexFrameworkMetadata.setVersion(groupMetadata.getVersion());
- flexFrameworkMetadata.setPackaging("pom");
- groupMetadata.getDependencies().add(flexFrameworkMetadata);
- } else if ("air".equals(sourceDirectory.getName())) {
- final MavenMetadata airCommonFrameworkMetaData = new MavenMetadata();
- airCommonFrameworkMetaData.setGroupId(groupId);
- airCommonFrameworkMetaData.setArtifactId("common-framework");
- airCommonFrameworkMetaData.setVersion(groupMetadata.getVersion());
- airCommonFrameworkMetaData.setPackaging("pom");
- airCommonFrameworkMetaData.setDependencies(new ArrayList<MavenMetadata>());
- airCommonFrameworkMetaData.setLibrariesWithResourceBundles(new ArrayList<String>());
-
- for (final MavenMetadata dependency : groupMetadata.getDependencies()) {
- airCommonFrameworkMetaData.getDependencies().add(dependency);
- if (groupMetadata.getLibrariesWithResourceBundles().contains(dependency.getArtifactId())) {
- airCommonFrameworkMetaData.getLibrariesWithResourceBundles().add(dependency.getArtifactId());
- }
- }
- final File commonFrameworkPom = new File(targetDirectory, "common-framework/" +
- groupMetadata.getVersion() + "/common-framework-" +
- groupMetadata.getVersion() + ".pom");
- generateSwcPom(commonFrameworkPom, airCommonFrameworkMetaData);
-
- // Generate a dummy entry for the "flex-framework" pom,
- // which will be generated later in the process.
- final MavenMetadata flexFrameworkMetadata = new MavenMetadata();
- flexFrameworkMetadata.setGroupId(groupId);
- flexFrameworkMetadata.setArtifactId("air-framework");
- flexFrameworkMetadata.setVersion(groupMetadata.getVersion());
- flexFrameworkMetadata.setPackaging("pom");
- groupMetadata.getDependencies().add(flexFrameworkMetadata);
-
- // In the air-directory the checksum of the airglobal.swc will determin the
- // air-sdk version.
- final File airglobalSwc = new File(sourceDirectory, "airglobal.swc");
- if (airglobalSwc.exists()) {
- final String checksum = calculateChecksum(airglobalSwc);
- final MavenMetadata airGlobalMetaData = checksums.get(checksum);
- if (airGlobalMetaData != null) {
- generateAirFrameworkPom(targetDirectory, sdkVersion, isApache, airGlobalMetaData.getVersion());
- } else {
- System.out.println("Couldn't find matching airglobal for FDK " + sdkVersion);
- }
- }
- }
-
- // Generate the master pom for the current library (Pom that defines
- // all versions of the current sdk libraries.
- final File groupPomFile = new File(targetDirectory, groupMetadata.getVersion() +
- "/" + groupMetadata.getArtifactId() + "-" +
- groupMetadata.getVersion() + ".pom");
- generateDependencyManagementPom(groupPomFile, groupMetadata);
- }
- }
-
- protected void generatePlayerglobalArtifacts(final File playerDirectory, final File playersTargetDirectory)
- throws Exception {
- double highestPlayerVersion = 9.0;
-
- final File[] playerVersionDirectories = playerDirectory.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.isDirectory();
- }
- });
- if (playerVersionDirectories != null) {
- // If no child directories were found, this is probably an old sdk
- // which contains the playerglobal for a flash player 9.
- if (playerVersionDirectories.length > 0) {
- for (final File playerVersionDirectory : playerVersionDirectories) {
- if (playerVersionDirectory.isDirectory()) {
- // The flash-player 10 was deployed as 10.0.0, we need to
- // cut off the last ".0" to match the rest.
- String playerVersionString = playerVersionDirectory.getName();
- if (playerVersionString.lastIndexOf(".") != playerVersionString.indexOf(".")) {
- playerVersionString = playerVersionString.substring(
- 0, playerVersionString.lastIndexOf("."));
- }
- final double playerVersion = Double.valueOf(playerVersionString);
- final NumberFormat doubleFormat = NumberFormat.getInstance(Locale.US);
- doubleFormat.setMinimumFractionDigits(1);
- doubleFormat.setMaximumFractionDigits(1);
-
- if (highestPlayerVersion < playerVersion) {
- highestPlayerVersion = playerVersion;
- }
-
- if (!playersTargetDirectory.exists()) {
- if (!playersTargetDirectory.mkdirs()) {
- throw new RuntimeException("Could not create directory: " +
- playersTargetDirectory.getAbsolutePath());
- }
- }
-
- generateArtifactsForDirectory(
- playerVersionDirectory, playersTargetDirectory, doubleFormat.format(playerVersion),
- "com.adobe.flash.framework", true, false);
- }
- }
- } else {
- generateArtifactsForDirectory(
- playerDirectory, playersTargetDirectory, "9.0", "com.adobe.flash.framework", true, false);
- }
- }
- }
-
- protected void generateSwcPom(final File targetSwc, final MavenMetadata metadata) throws Exception {
- final String swcPath = targetSwc.getAbsolutePath();
- final String pomPath;
- if(metadata.getClassifier() == null) {
- pomPath = swcPath.substring(0, swcPath.lastIndexOf(".")) + ".pom";
- } else {
- pomPath = swcPath.substring(0, swcPath.lastIndexOf("-")) + ".pom";
- }
-
- final Document pom = createPomDocument(metadata);
-
- writeDocument(pom, new File(pomPath));
- }
-
- protected void generateDependencyManagementPom(final File targetSwc, final MavenMetadata metadata)
- throws Exception {
- final String swcPath = targetSwc.getAbsolutePath();
- final String pomPath = swcPath.substring(0, swcPath.lastIndexOf(".")) + ".pom";
-
- final Document pom = createPomDocumentDependencyManagement(metadata);
-
- writeDocument(pom, new File(pomPath));
- }
-
- protected void generateFlexFrameworkPom(
- File targetDirectory, String sdkVersion, boolean isApache, String playerVersion) throws Exception {
- final MavenMetadata flexFramework = new MavenMetadata();
- flexFramework.setGroupId((isApache) ? "org.apache.flex.framework" : "com.adobe.flex.framework");
- flexFramework.setArtifactId("flex-framework");
- flexFramework.setVersion(sdkVersion);
- flexFramework.setPackaging("pom");
- flexFramework.setDependencies(new ArrayList<MavenMetadata>());
- flexFramework.setLibrariesWithResourceBundles(new ArrayList<String>());
-
- final MavenMetadata commonFramework = new MavenMetadata();
- commonFramework.setGroupId((isApache) ? "org.apache.flex.framework" : "com.adobe.flex.framework");
- commonFramework.setArtifactId("common-framework");
- commonFramework.setVersion(sdkVersion);
- commonFramework.setPackaging("pom");
- flexFramework.getDependencies().add(commonFramework);
-
- final MavenMetadata playerglobal = new MavenMetadata();
- playerglobal.setGroupId("com.adobe.flash.framework");
- playerglobal.setArtifactId("playerglobal");
- playerglobal.setVersion(playerVersion);
- playerglobal.setPackaging("swc");
- flexFramework.getDependencies().add(playerglobal);
- if (!"9.0".equals(playerVersion)) {
- flexFramework.getLibrariesWithResourceBundles().add("playerglobal");
- }
-
- final File pomFile = new File(targetDirectory, "flex-framework/" + sdkVersion +
- "/flex-framework-" + sdkVersion + ".pom");
- generateSwcPom(pomFile, flexFramework);
- }
-
- protected void generateAirFrameworkPom(File targetDirectory, String sdkVersion, boolean isApache, String airVersion)
- throws Exception {
- final String flexFrameworkGroupId = (isApache) ? "org.apache.flex.framework" : "com.adobe.flex.framework";
-
- final MavenMetadata airFramework = new MavenMetadata();
- airFramework.setGroupId(flexFrameworkGroupId + ".air");
- airFramework.setArtifactId("air-framework");
- airFramework.setVersion(sdkVersion);
- airFramework.setPackaging("pom");
- airFramework.setDependencies(new ArrayList<MavenMetadata>());
- airFramework.setLibrariesWithResourceBundles(new ArrayList<String>());
-
- // Reference the core flex-sdks artifacts.
- final MavenMetadata flexCommonFramework = new MavenMetadata();
- flexCommonFramework.setGroupId(flexFrameworkGroupId);
- flexCommonFramework.setArtifactId("common-framework");
- flexCommonFramework.setVersion(sdkVersion);
- flexCommonFramework.setPackaging("pom");
- airFramework.getDependencies().add(flexCommonFramework);
-
- // Reference to the artifacts of the air components of the flex-sdk.
- final MavenMetadata flexAirCommonFramework = new MavenMetadata();
- flexAirCommonFramework.setGroupId(flexFrameworkGroupId + ".air");
- flexAirCommonFramework.setArtifactId("common-framework");
- flexAirCommonFramework.setVersion(sdkVersion);
- flexAirCommonFramework.setPackaging("pom");
- airFramework.getDependencies().add(flexAirCommonFramework);
-
- // Reference to the artifacts of the air-sdk.
- final MavenMetadata airCommonFramework = new MavenMetadata();
- airCommonFramework.setGroupId("com.adobe.air.framework");
- airCommonFramework.setArtifactId("common-framework");
- airCommonFramework.setVersion(airVersion);
- airCommonFramework.setPackaging("pom");
- airFramework.getDependencies().add(airCommonFramework);
-
- final File pomFile = new File(targetDirectory, "air-framework/" + sdkVersion +
- "/air-framework-" + sdkVersion + ".pom");
- generateSwcPom(pomFile, airFramework);
- }
-
- protected void writeDummyResourceBundleSwc(final File targetFile) throws Exception {
- final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(targetFile));
- out.putNextEntry(new ZipEntry("dummy"));
- out.closeEntry();
- out.close();
- }
-
- private void generateThemeArtifacts(File themesDirectory, File targetDirectory, String sdkVersion, boolean isApache)
- throws Exception {
- final File[] themes = themesDirectory.listFiles();
- if(themes != null) {
- for(final File themeDirectory : themes) {
- if(themeDirectory.isDirectory()) {
- final String themeName = themeDirectory.getName().toLowerCase();
- final String themeVersion;
- // If the theme name matches that of a normal artifact (such as spark),
- // make sure the same version is used.
- if(libraryVersions.containsKey(themeName)) {
- themeVersion = libraryVersions.get(themeName);
- } else {
- themeVersion = sdkVersion;
- }
- final File themeFile = new File(themeDirectory, themeName + ".swc");
-
- final File targetThemesDirectory = new File(targetDirectory, "themes");
- final File targetThemeDirectory = new File(targetThemesDirectory, themeName);
- final File targetThemeVersionDirectory = new File(targetThemeDirectory, themeVersion);
-
- // Copy the SWC.
- File targetSwcFile = new File(targetThemeVersionDirectory, themeName + "-" +
- themeVersion + ".swc");
-
- if(themeFile.exists()) {
- if(!targetThemeVersionDirectory.mkdirs()) {
- throw new RuntimeException("Could not create directory: " +
- targetThemeDirectory.getAbsolutePath());
- }
- copyFile(themeFile, targetSwcFile);
- } else {
- targetSwcFile = generateThemeSwc(themeDirectory, targetSwcFile);
- }
-
- if(targetSwcFile != null) {
- // Generate the pom file.
- final MavenMetadata themeMetadata = new MavenMetadata();
- themeMetadata.setGroupId((isApache) ? "org.apache.flex.framework.themes" : "com.adobe.flex.framework.themes");
- themeMetadata.setArtifactId(themeName);
- themeMetadata.setVersion(themeVersion);
- themeMetadata.setPackaging("swc");
- generateSwcPom(targetSwcFile, themeMetadata);
- }
- }
- }
- }
- }
-
- private void generateMxFteThemeArtifact(File themeCssFile, File targetDirectory, String themeVersion, boolean isApache) throws Exception {
- final String themeName = "mxfte";
-
- final File targetThemesDirectory = new File(targetDirectory, "themes");
- final File targetThemeDirectory = new File(targetThemesDirectory, themeName);
- final File targetThemeVersionDirectory = new File(targetThemeDirectory, themeVersion);
-
- // Generate and Copy the SWC.
- File targetSwcFile = new File(targetThemeVersionDirectory, themeName + "-" + themeVersion + ".swc");
- targetSwcFile = generateThemeSwc(themeCssFile, targetSwcFile);
-
- if(targetSwcFile != null) {
- // Generate the pom file.
- final MavenMetadata themeMetadata = new MavenMetadata();
- themeMetadata.setGroupId((isApache) ? "org.apache.flex.framework.themes" : "com.adobe.flex.framework.themes");
- themeMetadata.setArtifactId(themeName);
- themeMetadata.setVersion(themeVersion);
- themeMetadata.setPackaging("swc");
- generateSwcPom(targetSwcFile, themeMetadata);
- }
- }
-
- private File generateThemeSwc(File themeDirectory, File targetFile) throws Exception {
-
- final File fdkHomeDir = (themeDirectory.isDirectory()) ? themeDirectory.getParentFile().getParentFile().getParentFile() : themeDirectory.getParentFile().getParentFile().getParentFile().getParentFile();
- final File fdkLibDir = new File(fdkHomeDir, "lib");
-
- List<String> processCmd = new ArrayList<String>(10);
-
- if(fdkLibDir.exists() && fdkLibDir.isDirectory()) {
- final File compcLibrary = new File(fdkLibDir, "compc.jar");
- final File frameworkDir = new File(fdkHomeDir, "frameworks");
-
- processCmd.add("java");
- processCmd.add("-Xmx384m");
- processCmd.add("-Dsun.io.useCanonCaches=false");
- processCmd.add("-jar");
- processCmd.add(compcLibrary.getCanonicalPath());
- processCmd.add("+flexlib=" + frameworkDir.getCanonicalPath());
-
- if(themeDirectory.isDirectory()){
- // Add all the content files.
- final File contents[] = themeDirectory.listFiles(new FileFilter() {
- @Override
- public boolean accept(File pathname) {
- return !(pathname.isDirectory() && "src".equals(pathname.getName())) &&
- !"preview.jpg".equals(pathname.getName()) && !pathname.getName().endsWith(".fla");
- }
- });
- if(contents.length == 0) {
- return null;
- }
-
- for(final File resource : contents) {
- processCmd.add("-include-file");
- processCmd.add(resource.getName());
- processCmd.add(resource.getCanonicalPath());
- }
- } else {
- processCmd.add("-include-file");
- processCmd.add(themeDirectory.getName());
- processCmd.add(themeDirectory.getCanonicalPath());
- }
-
- // Define the output file.
- processCmd.add("-o");
- processCmd.add(targetFile.getCanonicalPath());
-
- final File targetDirectory = targetFile.getParentFile();
- if(targetDirectory.exists()) {
- if(!targetDirectory.mkdirs()) {
- throw new RuntimeException("Could not create directory: " + targetDirectory.getCanonicalPath());
- }
- }
-
- // Execute the command.
- try {
- System.out.println("Geneating theme '" + themeDirectory.getName() + "'");
-
- //final Process child = Runtime.getRuntime().exec(cmd.toString(), envps);
- ProcessBuilder processBuilder = new ProcessBuilder(processCmd);
- processBuilder.environment().put("PLAYERGLOBAL_HOME", new File(new File(frameworkDir, "libs"), "player").getCanonicalPath());
- int exitValue = exec(processBuilder.start());
- if(exitValue != 0) {
- System.out.println("Couldn't create theme swc");
- System.out.println("----------------------------------------------------------------");
- System.out.println("Env: '" + processBuilder.environment().get("PLAYERGLOBAL_HOME") + "'");
- System.out.println(processBuilder.command());
- System.out.println("----------------------------------------------------------------");
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- // Return a reference on the theme swc.
- return targetFile;
- }
- return null;
- }
-
- private int exec(Process p) throws InterruptedException, IOException {
- String line;
- BufferedReader bri = new BufferedReader(new InputStreamReader(p.getInputStream()));
- BufferedReader bre = new BufferedReader(new InputStreamReader(p.getErrorStream()));
- while ((line = bri.readLine()) != null) {
- System.out.println(line);
- }
- while ((line = bre.readLine()) != null) {
- System.out.println(line);
- }
- int result = p.waitFor();
- bri.close();
- bre.close();
- System.out.println("Done.");
- return result;
- }
-
- private void createConfigsZip(File sdkSourceDirectory) throws Exception {
- // ZIP up every file (not directory) in the framework directory and the entire themes directory.
- final File sourceFiles[] = sdkSourceDirectory.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.isFile();
- }
- });
- final File zipInputFiles[] = new File[sourceFiles.length];
- System.arraycopy(sourceFiles, 0, zipInputFiles, 0, sourceFiles.length);
-
- // Add all the content to a zip-file.
- final File targetFile = new File(libraryLocations.get("framework"), "framework-" +
- libraryVersions.get("framework") + "-configs.zip");
- final ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(targetFile));
- for (final File file : zipInputFiles) {
- addFileToZip(zipOutputStream, file, sdkSourceDirectory);
- }
- zipOutputStream.close();
- }
-
- protected String getMinimumPlayerVersion(File frameworksDirectory) {
- final File flexConfigFile = new File(frameworksDirectory, "flex-config.xml");
-
- final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- try {
- final DocumentBuilder db = dbf.newDocumentBuilder();
- final Document dom = db.parse(flexConfigFile);
-
- final Element root = dom.getDocumentElement();
- final NodeList targetPlayerElements = root.getElementsByTagName("target-player");
- if(targetPlayerElements.getLength() == 0) {
- return "9.0";
- } else {
- final String version = targetPlayerElements.item(0).getTextContent();
- final String[] versionFragments = version.split("\\.");
- return versionFragments[0] + "." + versionFragments[1];
- }
- } catch (ParserConfigurationException pce) {
- throw new RuntimeException(pce);
- } catch (SAXException se) {
- throw new RuntimeException(se);
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- }
- }
-
- private void addFileToZip(ZipOutputStream zipOutputStream, File inputFile, File rootDirectory) throws Exception {
- if (inputFile == null) {
- return;
- }
-
- // If this is a directory, add all it's children.
- if (inputFile.isDirectory()) {
- final File directoryContent[] = inputFile.listFiles();
- if (directoryContent != null) {
- for (final File file : directoryContent) {
- addFileToZip(zipOutputStream, file, rootDirectory);
- }
- }
- }
- // If this is a file, add it to the zips output.
- else {
- byte[] buf = new byte[1024];
- final FileInputStream in = new FileInputStream(inputFile);
- final String zipPath = inputFile.getAbsolutePath().substring(
- rootDirectory.getAbsolutePath().length() + 1).replace("\\", "/");
- zipOutputStream.putNextEntry(new ZipEntry(zipPath));
- int len;
- while ((len = in.read(buf)) > 0) {
- zipOutputStream.write(buf, 0, len);
- }
- zipOutputStream.closeEntry();
- in.close();
- }
- }
-}
[23/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Removed the rsl profile as this would probably
cause a lot of maven problems. - Adjusted the
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Removed the rsl profile as this would probably cause a lot of maven problems.
- Adjusted the pom that it can be used to manage dependency versions as well as import dependencies themselves.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/7583e96e
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/7583e96e
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/7583e96e
Branch: refs/heads/develop
Commit: 7583e96edba93f46da2dd35c257b3e3de74f76d6
Parents: d68f5fa
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sat Jul 12 14:21:02 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sat Jul 12 14:21:02 2014 +0200
----------------------------------------------------------------------
.../base/src/main/resources/templates/pom.vm | 60 +++-----------------
1 file changed, 9 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/7583e96e/mavenizer/converters/base/src/main/resources/templates/pom.vm
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/resources/templates/pom.vm b/mavenizer/converters/base/src/main/resources/templates/pom.vm
index 917dff0..6287cbe 100644
--- a/mavenizer/converters/base/src/main/resources/templates/pom.vm
+++ b/mavenizer/converters/base/src/main/resources/templates/pom.vm
@@ -8,57 +8,6 @@
<packaging>${artifact.packaging}</packaging>
#if ( $artifact.hasDependencies() )
-#if ( $artifact.isAtLeastOneDependencyRsl() )
- <profiles>
- <profile>
- <id>default</id>
-
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
-
- <dependencies>
-#foreach( $dependency in $artifact.dependencies )
- <dependency>
- <groupId>${dependency.groupId}</groupId>
- <artifactId>${dependency.artifactId}</artifactId>
- <version>${dependency.version}</version>
-#if ($dependency.packaging != "jar")
- <type>${dependency.packaging}</type>
-#end
- </dependency>
-#end
- </dependencies>
- </profile>
-
- <profile>
- <id>flex-rsl</id>
-
- <activation>
- <property>
- <name>flex.framework.scope</name>
- <value>rsl</value>
- </property>
- </activation>
-
- <dependencies>
-#foreach( $dependency in $artifact.dependencies )
- <dependency>
- <groupId>${dependency.groupId}</groupId>
- <artifactId>${dependency.artifactId}</artifactId>
- <version>${dependency.version}</version>
-#if ($dependency.packaging != "jar")
- <type>${dependency.packaging}</type>
-#end
-#if ($dependency.packaging == "swc" && $dependency.hasBinaryArtifact('rsl'))
- <scope>rsl</scope>
-#end
- </dependency>
-#end
- </dependencies>
- </profile>
- </profiles>
-#else
<dependencies>
#foreach( $dependency in $artifact.dependencies )
<dependency>
@@ -71,7 +20,16 @@
</dependency>
#end
</dependencies>
+
+ <dependencyManagement>
+#foreach( $dependency in $artifact.dependencies )
+ <dependency>
+ <groupId>${dependency.groupId}</groupId>
+ <artifactId>${dependency.artifactId}</artifactId>
+ <version>${dependency.version}</version>
+ </dependency>
#end
+ </dependencyManagement>
#end
</project>
[11/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Moved the SdkDeployer (Now MavenDeployer) and
SdkInVmDeployer (Now AetherDeployer). - Moved
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Moved the SdkDeployer (Now MavenDeployer) and SdkInVmDeployer (Now AetherDeployer).
- Moved the maven dependencies to the projects they belong to.
- Cleaned up old code.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/38514b56
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/38514b56
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/38514b56
Branch: refs/heads/develop
Commit: 38514b56b4d94a775e93d295410e4d01d3b04391
Parents: 83a57f6
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sat May 24 21:56:49 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sat May 24 21:56:49 2014 +0200
----------------------------------------------------------------------
mavenizer/README.txt | 9 +-
mavenizer/converters/base/pom.xml | 13 +
mavenizer/converters/flash/pom.xml | 5 +
.../utilities/converter/core/AirDownloader.java | 1 -
mavenizer/deployers/aether/pom.xml | 58 ++
.../deployer/aether/AetherDeployer.java | 242 ++++++
.../converter/deployer/maven/MavenDeployer.java | 189 +++++
mavenizer/pom.xml | 76 +-
mavenizer/retrievers/base/pom.xml | 10 +
.../converter/retrievers/BaseRetriever.java | 6 +-
mavenizer/src/main/java/SDKDeployer.java | 186 ----
mavenizer/src/main/java/SDKGenerator.java | 240 ------
.../src/main/java/air/AirCompilerGenerator.java | 156 ----
.../main/java/air/AirFrameworkGenerator.java | 155 ----
.../src/main/java/air/AirRuntimeGenerator.java | 205 -----
.../src/main/java/common/BaseGenerator.java | 389 ---------
.../src/main/java/common/MavenMetadata.java | 91 --
.../main/java/flex/FlexCompilerGenerator.java | 246 ------
.../main/java/flex/FlexFrameworkGenerator.java | 844 -------------------
.../main/java/flex/FlexRuntimeGenerator.java | 205 -----
20 files changed, 528 insertions(+), 2798 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/README.txt
----------------------------------------------------------------------
diff --git a/mavenizer/README.txt b/mavenizer/README.txt
index d962139..d22c539 100644
--- a/mavenizer/README.txt
+++ b/mavenizer/README.txt
@@ -114,15 +114,16 @@ Flex SDKs (From Adobe):
http://sourceforge.net/adobe/flexsdk/wiki/downloads/
/////////////////////////////////////////////////////////////////////////////////////////
-Some information (HOWTO) to go with the SDKDeployer
+Some information (HOWTO) to go with the MavenDeployer
/////////////////////////////////////////////////////////////////////////////////////////
-The SDKDeployer allows you to deploy any maven structured directory to a remote maven
+The MavenDeployer allows you to deploy any maven structured directory to a remote maven
repository as soon as you've got the remote rights.
-Usage: java -cp flex-sdk-converter-1.0.jar SDKDeployer "directory" "repositoryId" "url" "mvn"
+Usage:
+java -cp flex-sdk-converter-1.0.jar org.apache.flex.utilities.converter.deployer.maven.MavenDeployer "directory" "repositoryId" "url" "mvn"
-The SDKDeployer needs 4 ordered parameters separated by spaces:
+The MavenDeployer needs 4 ordered parameters separated by spaces:
1- directory: The path to the directory to deploy.
2- repositoryId: Server Id to map on the <id> under <server> section of settings.xml.
3- url: URL where the artifacts will be deployed.
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/converters/base/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/pom.xml b/mavenizer/converters/base/pom.xml
index e058961..25c5fc7 100644
--- a/mavenizer/converters/base/pom.xml
+++ b/mavenizer/converters/base/pom.xml
@@ -32,4 +32,17 @@
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>1.12</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ <version>1.3.1</version>
+ </dependency>
+ </dependencies>
+
</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/converters/flash/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/converters/flash/pom.xml b/mavenizer/converters/flash/pom.xml
index d231261..84d0ad3 100644
--- a/mavenizer/converters/flash/pom.xml
+++ b/mavenizer/converters/flash/pom.xml
@@ -38,6 +38,11 @@
<artifactId>base-converter</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-compress</artifactId>
+ <version>1.4</version>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/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
index cac8244..f1df0f2 100644
--- 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
@@ -17,7 +17,6 @@
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;
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/deployers/aether/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/deployers/aether/pom.xml b/mavenizer/deployers/aether/pom.xml
index 3f0d3db..3d68cea 100644
--- a/mavenizer/deployers/aether/pom.xml
+++ b/mavenizer/deployers/aether/pom.xml
@@ -32,4 +32,62 @@
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-api</artifactId>
+ <version>${aetherVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-util</artifactId>
+ <version>${aetherVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-impl</artifactId>
+ <version>${aetherVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-spi</artifactId>
+ <version>${aetherVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-connector-basic</artifactId>
+ <version>${aetherVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-transport-file</artifactId>
+ <version>${aetherVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-transport-http</artifactId>
+ <version>${aetherVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-transport-wagon</artifactId>
+ <version>${aetherVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-transport-classpath</artifactId>
+ <version>${aetherVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-aether-provider</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh</artifactId>
+ <version>${wagonVersion}</version>
+ </dependency>
+ </dependencies>
+
</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/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
new file mode 100644
index 0000000..40ac8c2
--- /dev/null
+++ b/mavenizer/deployers/aether/src/main/java/org/apache/flex/utilities/converter/deployer/aether/AetherDeployer.java
@@ -0,0 +1,242 @@
+/*
+ * 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.deployer.aether;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader;
+import org.apache.maven.repository.internal.DefaultVersionRangeResolver;
+import org.apache.maven.repository.internal.DefaultVersionResolver;
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
+import org.eclipse.aether.deployment.DeployRequest;
+import org.eclipse.aether.deployment.DeploymentException;
+import org.eclipse.aether.impl.*;
+import org.eclipse.aether.installation.InstallationException;
+import org.eclipse.aether.internal.impl.DefaultDependencyCollector;
+import org.eclipse.aether.internal.impl.DefaultTransporterProvider;
+import org.eclipse.aether.repository.Authentication;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
+import org.eclipse.aether.spi.connector.transport.TransporterFactory;
+import org.eclipse.aether.spi.connector.transport.TransporterProvider;
+import org.eclipse.aether.transport.file.FileTransporterFactory;
+import org.eclipse.aether.transport.http.HttpTransporterFactory;
+import org.eclipse.aether.transport.wagon.WagonTransporterFactory;
+import org.eclipse.aether.util.repository.AuthenticationBuilder;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+
+/**
+ * Updated Version of the SDKDeployer which no longer relies on an installed Maven
+ * system and which performs the deployment inside the VM without having to spawn new
+ * VMs for each artifact in order to deploy the files using a Maven commandline
+ * execution.
+ *
+ * Created with IntelliJ IDEA.
+ * User: cdutz
+ * Date: 03.11.13
+ *
+ * @author Christofer Dutz
+ */
+public class AetherDeployer {
+
+ private String directory;
+ private String url;
+ private String username;
+ private String password;
+
+
+ public AetherDeployer(String[] parameters) {
+ this.directory = parameters[0];
+ this.url = parameters[1];
+ if (parameters.length > 2) {
+ this.username = parameters[2];
+ this.password = parameters[3];
+ }
+ }
+
+ public static void main(String[] args) {
+ if ((args.length != 2) && (args.length != 4)) {
+ printUsage();
+ System.exit(0);
+ }
+
+ final AetherDeployer deployer = new AetherDeployer(args);
+ deployer.start();
+ }
+
+ private static void printUsage() {
+ System.out.println("\nUsage: java -cp flex-sdk-converter-1.0.jar SDKInVMDeployer \"directory\" \"url\" [\"username\", \"password\"]\n");
+ System.out.println("The SDKDeployer needs at least 2 ordered parameters separated by spaces:");
+ System.out.println("\t1- directory: The path to the directory containing the artifacts that should be deployed.");
+ System.out.println("\t2- url: URL where the artifacts will be deployed.");
+ System.out.println("If the targeted repository requires authentication two more parameters have to be provided:");
+ System.out.println("\t3- username: The username used to authenticate on the target repository.");
+ System.out.println("\t4- password: The password used to authenticate on the target repository.");
+ }
+
+ private void start() {
+ try {
+ final DefaultServiceLocator locator = new DefaultServiceLocator();
+ locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
+ locator.addService(VersionResolver.class, DefaultVersionResolver.class);
+ locator.addService(VersionRangeResolver.class, DefaultVersionRangeResolver.class);
+ locator.addService(ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class);
+ locator.addService(DependencyCollector.class, DefaultDependencyCollector.class);
+ locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
+ locator.addService(TransporterProvider.class, DefaultTransporterProvider.class);
+ locator.addService(TransporterFactory.class, FileTransporterFactory.class);
+ locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
+ locator.addService(TransporterFactory.class, WagonTransporterFactory.class);
+
+ final RepositorySystem repositorySystem = locator.getService(RepositorySystem.class);
+
+ if (repositorySystem == null) {
+ System.out.println("Couldn't initialize local maven repository system.");
+ System.exit(0);
+ } else {
+ // Setup the repository system session based upon the current maven settings.xml.
+ final DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
+ final LocalRepository localRepo = new LocalRepository(directory);
+ RemoteRepository.Builder repoBuilder = new RemoteRepository.Builder("repo", "default", url);
+ if ((username != null) && (password != null)) {
+ final Authentication authentication = new AuthenticationBuilder().addUsername(
+ username).addPassword(password).build();
+ repoBuilder.setAuthentication(authentication);
+ }
+ final RemoteRepository remoteRepository = repoBuilder.build();
+
+ session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(session, localRepo));
+
+ // Process all content of the mavenizer target directory.
+ final File rootDir = new File(directory);
+ processDir(rootDir, repositorySystem, session, remoteRepository);
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void processDir(File curDir, RepositorySystem repositorySystem, RepositorySystemSession session,
+ RemoteRepository remoteRepository)
+ throws IOException, XmlPullParserException, InstallationException, DeploymentException {
+ // If the current directory contained any poms,
+ // process them as artifacts.
+ final File[] poms = curDir.listFiles(new PomFilter());
+ if (poms != null) {
+ for (File pom : poms) {
+ processArtifact(pom, repositorySystem, session, remoteRepository);
+ }
+ }
+
+ // If the current directory contained any directories,
+ // continue processing their content.
+ final File[] dirs = curDir.listFiles(new DirFilter());
+ if (dirs != null) {
+ for (File dir : dirs) {
+ processDir(dir, repositorySystem, session, remoteRepository);
+ }
+ }
+ }
+
+ private void processArtifact(File pomFile, RepositorySystem repositorySystem, RepositorySystemSession session,
+ RemoteRepository remoteRepository)
+ throws IOException, XmlPullParserException, InstallationException, DeploymentException {
+ final Reader reader = new FileReader(pomFile);
+ try {
+ final File artifactDirectory = pomFile.getParentFile();
+ final MavenXpp3Reader xpp3Reader = new MavenXpp3Reader();
+ final Model model = xpp3Reader.read(reader);
+
+ // Make the deployer deploy the pom itself.
+ final DeployRequest artifactInstallRequest = new DeployRequest();
+ artifactInstallRequest.setRepository(remoteRepository);
+ Artifact pomArtifact = new DefaultArtifact(
+ model.getGroupId(), model.getArtifactId(), "pom", model.getVersion());
+ pomArtifact = pomArtifact.setFile(pomFile);
+ artifactInstallRequest.addArtifact(pomArtifact);
+
+ // Add any additional files to this installation.
+ final String artifactBaseName = model.getArtifactId() + "-" + model.getVersion();
+ final File artifactFiles[] = artifactDirectory.listFiles(new ArtifactFilter());
+ for (final File artifactFile : artifactFiles) {
+ final String fileName = artifactFile.getName();
+ final String classifier;
+ // This file has a classifier.
+ if (fileName.charAt(artifactBaseName.length()) == '-') {
+ classifier = fileName.substring(artifactBaseName.length() + 1,
+ fileName.indexOf(".", artifactBaseName.length()));
+ }
+ // This file doesn't have a classifier.
+ else {
+ classifier = "";
+ }
+ final String extension = fileName.substring(
+ artifactBaseName.length() + 1 + ((classifier.length() > 0) ? classifier.length() + 1 : 0));
+ Artifact fileArtifact = new DefaultArtifact(model.getGroupId(), model.getArtifactId(),
+ classifier, extension, model.getVersion());
+ fileArtifact = fileArtifact.setFile(artifactFile);
+ artifactInstallRequest.addArtifact(fileArtifact);
+ }
+
+ // Actually install the artifact.
+ System.out.println("Installing Artifact: " + pomArtifact.getGroupId() + ":" +
+ pomArtifact.getArtifactId() + ":" + pomArtifact.getVersion());
+ for (final Artifact artifact : artifactInstallRequest.getArtifacts()) {
+ System.out.println(" - File with extension " + artifact.getExtension() +
+ ((artifact.getClassifier().length() > 0) ? " and classifier " + artifact.getClassifier() : ""));
+ }
+
+ repositorySystem.deploy(session, artifactInstallRequest);
+ } finally {
+ reader.close();
+ }
+ }
+
+ 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();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/deployers/maven/src/main/java/org/apache/flex/utilities/converter/deployer/maven/MavenDeployer.java
----------------------------------------------------------------------
diff --git a/mavenizer/deployers/maven/src/main/java/org/apache/flex/utilities/converter/deployer/maven/MavenDeployer.java b/mavenizer/deployers/maven/src/main/java/org/apache/flex/utilities/converter/deployer/maven/MavenDeployer.java
new file mode 100644
index 0000000..88c28b8
--- /dev/null
+++ b/mavenizer/deployers/maven/src/main/java/org/apache/flex/utilities/converter/deployer/maven/MavenDeployer.java
@@ -0,0 +1,189 @@
+/*
+ * 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.deployer.maven;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: fthomas
+ * Date: 11.08.12
+ * Time: 18:17
+ *
+ * @author Frederic Thomas
+ * @author Jose Barragan
+ */
+public class MavenDeployer {
+
+ private String directory;
+ private String repositoryId;
+ private String url;
+ private String mvn;
+
+ /**
+ * @param parameters
+ */
+ public MavenDeployer(String[] parameters) {
+ super();
+ this.directory = parameters[0];
+ this.repositoryId = parameters[1];
+ this.url = parameters[2];
+ this.mvn = parameters[3];
+ }
+
+ public static void main(String[] args) {
+ if (args.length != 4) {
+ printUsage();
+ System.exit(0);
+ }
+
+ MavenDeployer deployer = new MavenDeployer(args);
+ deployer.start();
+ }
+
+ private static void printUsage() {
+ System.out.println("\nUsage: java -cp flex-sdk-converter-1.0.jar org.apache.flex.utilities.converter.deployer.maven.SDKDeployer \"directory\" \"repositoryId\" \"url\" \"mvn\"\n");
+ System.out.println("The org.apache.flex.utilities.converter.deployer.maven.SDKDeployer needs 4 ordered parameters separated by spaces:");
+ System.out.println("\t1- directory: The path to the directory to deploy.");
+ System.out.println("\t2- repositoryId: Server Id to map on the <id> under <server> section of settings.xml.");
+ System.out.println("\t3- url: URL where the artifacts will be deployed.");
+ System.out.println("\t4- mvn: The path to the mvn.bat / mvn.sh.");
+ }
+
+ private void start() {
+ try {
+ File dir = new File(directory);
+
+ doDir(dir);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void doDir(File dir) throws IOException, InterruptedException {
+ File[] listFiles = dir.listFiles(new PomFilter());
+ if (listFiles != null) {
+ for (File pom : listFiles) {
+ doPom(pom);
+ }
+ }
+
+ File[] listDirs = dir.listFiles(new DirFilter());
+ if (listDirs != null) {
+ for (File subdir : listDirs) {
+ doDir(subdir);
+ }
+ }
+ }
+
+ private void doPom(File pom) throws IOException, InterruptedException {
+ File base = pom.getParentFile();
+ final String fileName = pom.getName();
+ String artifactName = fileName.substring(0, fileName.lastIndexOf("-"));
+
+ if (artifactName != null) {
+ File artifacts[] = new File(pom.getParent()).listFiles(new ArtifactFilter());
+ List<String> processCmdBase = new ArrayList<String>(10);
+ processCmdBase.add(mvn);
+ processCmdBase.add("deploy:deploy-file");
+ processCmdBase.add("-DrepositoryId=" + repositoryId);
+ processCmdBase.add("-Durl=" + url);
+
+ ProcessBuilder processBuilder = null;
+
+
+ String packaging;
+ String classifier = null;
+
+ List<String> processCmd = null;
+ if (artifacts != null && artifacts.length > 0) {
+ for (File artifact : artifacts) {
+ processCmd = new ArrayList<String>(10);
+ processCmd.addAll(processCmdBase);
+ classifier = packaging = null;
+ artifactName = artifact.getName();
+
+ packaging = (artifactName.endsWith("rb.swc")) ? "rb.swc" : artifactName.substring(artifactName.lastIndexOf(".") + 1);
+
+ try {
+ classifier = artifactName
+ .substring(artifactName.indexOf(base.getName()) + base.getName().length() + 1, artifactName.length() - packaging.length() - 1);
+ } catch (StringIndexOutOfBoundsException ex) {/*has no classifier*/}
+
+ processCmd.add("-Dfile=" + artifact.getAbsolutePath());
+ processCmd.add("-DpomFile=" + pom.getAbsolutePath());
+ if (classifier != null && classifier.length() > 0) {
+ processCmd.add("-Dclassifier=" + classifier);
+ }
+ processCmd.add("-Dpackaging=" + packaging);
+ processBuilder = new ProcessBuilder(processCmd);
+ exec(processBuilder.start());
+ }
+ } else {
+ processCmd = new ArrayList<String>(10);
+ processCmd.addAll(processCmdBase);
+ processCmd.add("-Dfile=" + pom.getAbsolutePath());
+ processCmd.add("-DpomFile=" + pom.getAbsolutePath());
+ processBuilder = new ProcessBuilder(processCmd);
+ exec(processBuilder.start());
+ }
+
+ }
+ }
+
+ private void exec(Process p) throws InterruptedException, IOException {
+ String line;
+ BufferedReader bri = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ BufferedReader bre = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ while ((line = bri.readLine()) != null) {
+ System.out.println(line);
+ }
+ while ((line = bre.readLine()) != null) {
+ System.out.println(line);
+ }
+ p.waitFor();
+ bri.close();
+ bre.close();
+ System.out.println("Done.");
+ }
+
+ 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");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/pom.xml b/mavenizer/pom.xml
index 3be7f8f..71748f0 100644
--- a/mavenizer/pom.xml
+++ b/mavenizer/pom.xml
@@ -40,77 +40,6 @@
<module>deployers</module>
</modules>
- <dependencies>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-client</artifactId>
- <version>1.12</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jettison</groupId>
- <artifactId>jettison</artifactId>
- <version>1.3.1</version>
- </dependency>
-
- <!-- Needed for Aether Repository Client -->
- <dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-api</artifactId>
- <version>${aetherVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-util</artifactId>
- <version>${aetherVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-impl</artifactId>
- <version>${aetherVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-spi</artifactId>
- <version>${aetherVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-connector-basic</artifactId>
- <version>${aetherVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-transport-file</artifactId>
- <version>${aetherVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-transport-http</artifactId>
- <version>${aetherVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-transport-wagon</artifactId>
- <version>${aetherVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-transport-classpath</artifactId>
- <version>${aetherVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-aether-provider</artifactId>
- <version>${mavenVersion}</version>
- </dependency>
- <!-- Add support for scp and sftp protocols in the SDKInVMDeployer -->
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-ssh</artifactId>
- <version>${wagonVersion}</version>
- </dependency>
- </dependencies>
-
<build>
<plugins>
<!--plugin>
@@ -140,8 +69,9 @@
</goals>
</execution>
</executions>
- </plugin>
- <plugin>
+ </plugin-->
+ <!-- Commented out because the plugin doesn't seem to work. -->
+ <!--plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<version>0.10</version>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/retrievers/base/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/retrievers/base/pom.xml b/mavenizer/retrievers/base/pom.xml
index 5663955..3524dd8 100644
--- a/mavenizer/retrievers/base/pom.xml
+++ b/mavenizer/retrievers/base/pom.xml
@@ -34,10 +34,20 @@
<dependencies>
<dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.8.1</version>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>3.0.15</version>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/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 4f04363..514ed2e 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,13 +16,13 @@
*/
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.commons.compress.utils.CountingInputStream;
import org.apache.flex.utilities.converter.retrievers.exceptions.RetrieverException;
import org.apache.flex.utilities.converter.retrievers.utils.ProgressBar;
@@ -84,7 +84,7 @@ public abstract class BaseRetriever implements Retriever {
int count;
while ((count = archiveInputStream.read(data, 0, BUFFER_MAX)) != -1) {
dest.write(data, 0, count);
- progressBar.updateProgress(inputStream.getCount());
+ progressBar.updateProgress(inputStream.getBytesRead());
}
} finally {
if(dest != null) {
@@ -94,7 +94,7 @@ public abstract class BaseRetriever implements Retriever {
}
}
- progressBar.updateProgress(inputStream.getCount());
+ progressBar.updateProgress(inputStream.getBytesRead());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/src/main/java/SDKDeployer.java
----------------------------------------------------------------------
diff --git a/mavenizer/src/main/java/SDKDeployer.java b/mavenizer/src/main/java/SDKDeployer.java
deleted file mode 100644
index 44e4798..0000000
--- a/mavenizer/src/main/java/SDKDeployer.java
+++ /dev/null
@@ -1,186 +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.
- */
-import java.io.*;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created with IntelliJ IDEA.
- * User: fthomas
- * Date: 11.08.12
- * Time: 18:17
- *
- * @author Frederic Thomas
- * @author Jose Barragan
- */
-public class SDKDeployer {
- private String directory;
- private String repositoryId;
- private String url;
- private String mvn;
-
- /**
- * @param parameters
- */
- public SDKDeployer(String[] parameters) {
- super();
- this.directory = parameters[0];
- this.repositoryId = parameters[1];
- this.url = parameters[2];
- this.mvn = parameters[3];
- }
-
- public static void main(String[] args) {
- if (args.length != 4) {
- printUsage();
- System.exit(0);
- }
-
- SDKDeployer deployer = new SDKDeployer(args);
- deployer.start();
- }
-
- private static void printUsage() {
- System.out.println("\nUsage: java -cp flex-sdk-converter-1.0.jar SDKDeployer \"directory\" \"repositoryId\" \"url\" \"mvn\"\n");
- System.out.println("The SDKDeployer needs 4 ordered parameters separated by spaces:");
- System.out.println("\t1- directory: The path to the directory to deploy.");
- System.out.println("\t2- repositoryId: Server Id to map on the <id> under <server> section of settings.xml.");
- System.out.println("\t3- url: URL where the artifacts will be deployed.");
- System.out.println("\t4- mvn: The path to the mvn.bat / mvn.sh.");
- }
-
- private void start() {
- try {
- File dir = new File(directory);
-
- doDir(dir);
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
-
- private void doDir(File dir) throws IOException, InterruptedException {
- File[] listFiles = dir.listFiles(new PomFilter());
- if (listFiles != null) {
- for (File pom : listFiles) {
- doPom(pom);
- }
- }
-
- File[] listDirs = dir.listFiles(new DirFilter());
- if (listDirs != null) {
- for (File subdir : listDirs) {
- doDir(subdir);
- }
- }
- }
-
- private void doPom(File pom) throws IOException, InterruptedException {
- File base = pom.getParentFile();
- final String fileName = pom.getName();
- String artifactName = fileName.substring(0, fileName.lastIndexOf("-"));
-
- if (artifactName != null) {
- File artifacts[] = new File(pom.getParent()).listFiles(new ArtifactFilter());
- List<String> processCmdBase = new ArrayList<String>(10);
- processCmdBase.add(mvn);
- processCmdBase.add("deploy:deploy-file");
- processCmdBase.add("-DrepositoryId=" + repositoryId);
- processCmdBase.add("-Durl=" + url);
-
- ProcessBuilder processBuilder = null;
-
-
- String packaging;
- String classifier = null;
-
- List<String> processCmd = null;
- if (artifacts != null && artifacts.length > 0) {
- for (File artifact : artifacts) {
- processCmd = new ArrayList<String>(10);
- processCmd.addAll(processCmdBase);
- classifier = packaging = null;
- artifactName = artifact.getName();
-
- packaging = (artifactName.endsWith("rb.swc")) ? "rb.swc" : artifactName.substring(artifactName.lastIndexOf(".") + 1);
-
- try {
- classifier = artifactName
- .substring(artifactName.indexOf(base.getName()) + base.getName().length() + 1, artifactName.length() - packaging.length() - 1);
- } catch (StringIndexOutOfBoundsException ex) {/*has no classifier*/}
-
- processCmd.add("-Dfile=" + artifact.getAbsolutePath());
- processCmd.add("-DpomFile=" + pom.getAbsolutePath());
- if (classifier != null && classifier.length() > 0) {
- processCmd.add("-Dclassifier=" + classifier);
- }
- processCmd.add("-Dpackaging=" + packaging);
- processBuilder = new ProcessBuilder(processCmd);
- exec(processBuilder.start());
- }
- } else {
- processCmd = new ArrayList<String>(10);
- processCmd.addAll(processCmdBase);
- processCmd.add("-Dfile=" + pom.getAbsolutePath());
- processCmd.add("-DpomFile=" + pom.getAbsolutePath());
- processBuilder = new ProcessBuilder(processCmd);
- exec(processBuilder.start());
- }
-
- }
- }
-
- private void exec(Process p) throws InterruptedException, IOException {
- String line;
- BufferedReader bri = new BufferedReader(new InputStreamReader(p.getInputStream()));
- BufferedReader bre = new BufferedReader(new InputStreamReader(p.getErrorStream()));
- while ((line = bri.readLine()) != null) {
- System.out.println(line);
- }
- while ((line = bre.readLine()) != null) {
- System.out.println(line);
- }
- p.waitFor();
- bri.close();
- bre.close();
- System.out.println("Done.");
- }
-
- 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");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/src/main/java/SDKGenerator.java
----------------------------------------------------------------------
diff --git a/mavenizer/src/main/java/SDKGenerator.java b/mavenizer/src/main/java/SDKGenerator.java
deleted file mode 100644
index 401367c..0000000
--- a/mavenizer/src/main/java/SDKGenerator.java
+++ /dev/null
@@ -1,240 +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.
- */
-import java.io.*;
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.parsers.*;
-
-import air.AirCompilerGenerator;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-import air.AirFrameworkGenerator;
-import air.AirRuntimeGenerator;
-import flex.FlexCompilerGenerator;
-import flex.FlexFrameworkGenerator;
-import flex.FlexRuntimeGenerator;
-
-/**
- * Created with IntelliJ IDEA.
- * User: cdutz
- * Date: 11.05.12
- * Time: 12:03
- */
-public class SDKGenerator {
-
- protected List<String> generatedAirVersions = new ArrayList<String>();
-
- /**
- * All this little helper does is list up all directories in the given base directory and
- * trigger the actual import on that. If a flex sdk comes with an air runtime, the structure
- * is identical to that of an ordinary air sdk. Therefore the import works if a flex sdk or
- * an air sdk directory is passed to this method.
- *
- * @param sdkSourceDirectory source directory containing the air content
- * @param sdkTargetDirectory directory where to copy the content
- * @throws Exception
- */
- public void generateAllAir(File sdkSourceDirectory, File sdkTargetDirectory) throws Exception {
- final File sdkDirectories[] = sdkSourceDirectory.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.isDirectory();
- }
- });
- if (sdkDirectories != null) {
- System.out.println("---------------------------------------------");
- for (final File sdkDirectory : sdkDirectories) {
- String sdkVersion = getAirSdkVersion(sdkDirectory);
-
- // As we are eventually generating the air sdks first, a flex sdk processed
- // later could contain the same version of air, in this case we skip that.
- if((sdkVersion != null) && !generatedAirVersions.contains(sdkVersion)) {
- System.out.println("-- Generating Air SDK version: " + sdkVersion);
- System.out.println("---------------------------------------------");
-
- generateAir(sdkDirectory, sdkTargetDirectory, sdkVersion);
-
- System.out.println("---------------------------------------------");
-
- generatedAirVersions.add(sdkVersion);
- }
- }
- }
- }
-
- public void generateAir(final File sdkSourceDirectory, final File sdkTargetDirectory, final String sdkVersion) throws Exception {
- // Generate the artifacts, needed by the air compiler.
- new AirCompilerGenerator().process(sdkSourceDirectory, false, sdkTargetDirectory, sdkVersion, false);
-
- // Generate the artifacts, needed by the flex application.
- new AirFrameworkGenerator().process(sdkSourceDirectory, false, sdkTargetDirectory, sdkVersion, false);
-
- // Deploy the FlashPlayer and AIR runtime binaries.
- new AirRuntimeGenerator().process(sdkSourceDirectory, false, sdkTargetDirectory, sdkVersion, false);
- }
-
- public void generateAllFlex(File sdkSourceDirectory, File sdkTargetDirectory, boolean useApache) throws Exception {
- final File sdkDirectories[] = sdkSourceDirectory.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.isDirectory();
- }
- });
- if (sdkDirectories != null) {
- System.out.println("---------------------------------------------");
- for (final File sdkDirectory : sdkDirectories) {
- String sdkVersion = getFlexSdkVersion(sdkDirectory);
-
- // Apache FDKs (ok ... the only one available) have the version prefix "Apache-"
- // So this is what we use in order to determine what type of FDK it is.
- final boolean isApache = sdkVersion.startsWith("Apache-");
- if (isApache) {
- sdkVersion = sdkVersion.substring("Apache-".length());
- }
-
- System.out.println("-- Generating Flex SDK version: " + sdkVersion);
- System.out.println("---------------------------------------------");
-
- generateFlex(sdkDirectory, isApache, sdkTargetDirectory, sdkVersion, useApache);
-
- System.out.println("---------------------------------------------");
- }
- }
- }
-
- public void generateFlex(final File sdkSourceDirectory, final boolean isApache, final File sdkTargetDirectory,
- final String sdkVersion, final boolean useApache) throws Exception {
- // Generate the artifacts, needed by the flex compiler.
- new FlexCompilerGenerator().process(sdkSourceDirectory, isApache, sdkTargetDirectory, sdkVersion, useApache);
-
- // Generate the artifacts, needed by the flex application.
- new FlexFrameworkGenerator().process(sdkSourceDirectory, isApache, sdkTargetDirectory, sdkVersion, useApache);
-
- // Deploy the FlashPlayer and AIR runtime binaries.
- new FlexRuntimeGenerator().process(sdkSourceDirectory, isApache, sdkTargetDirectory, sdkVersion, useApache);
- }
-
- public static void main(String[] args) throws Exception {
-
- if (args.length != 3) {
- System.out.println("Usage: SDKGenerator {source-directory} {target-directory} {use-apache-gid}");
- System.exit(0);
- }
-
- final String sdkSourceDirectoryName = args[0];
- final String sdkTargetDirectoryName = args[1];
- final boolean useApache = Boolean.valueOf(args[2]);
-
- final File sdkSourceDirectory = new File(sdkSourceDirectoryName);
- final File sdkTargetDirectory = new File(sdkTargetDirectoryName);
-
- // When generating the fdks the generator tries to figure out the flashplayer-version and air-version
- // by comparing the hash of the playerglobal.swc and airglobal.swc with some hashes. This list of
- // hashes has to be created first. Therefore the Generator generates air artifacts by processing air
- // sdk directories and then by extracting the needed artifacts from the flex fdks.
- final SDKGenerator generator = new SDKGenerator();
- generator.generateAllAir(new File(sdkSourceDirectory, "air"), sdkTargetDirectory);
- generator.generateAllAir(new File(sdkSourceDirectory, "flex"), sdkTargetDirectory);
-
- // After the air artifacts are generated and
- generator.generateAllFlex(new File(sdkSourceDirectory, "flex"), sdkTargetDirectory, useApache);
- }
-
- /**
- * The only place I found where to extract the version of an Air SDK was the "AIR SDK Readme.txt" file.
- * In order to get the version we need to cut out the version-part from the title-row of that text file.
- * This file is present in the root of a pure air sdk or in the root of a flex sdk, therefore the same
- * algorithm works if sdkSourceDirectory points to a flex sdk or an air sdk.
- *
- * @param sdkSourceDirectory directory in which to look for the sdk descriptor file of an air sdk
- * @return version of the sdk in th given directory
- */
- public static String getAirSdkVersion(final File sdkSourceDirectory) {
- final File sdkDescriptor = new File(sdkSourceDirectory, "AIR SDK Readme.txt");
-
- if (sdkDescriptor.exists()) {
- DataInputStream in = null;
- try {
- final FileInputStream fstream = new FileInputStream(sdkDescriptor);
- in = new DataInputStream(fstream);
- final BufferedReader br = new BufferedReader(new InputStreamReader(in));
- final String strLine = br.readLine();
- return strLine.substring("Adobe AIR ".length(), strLine.indexOf(" ", "Adobe AIR ".length()));
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException ioe) {
- // Ignore.
- }
- }
- }
- }
- return null;
- }
-
- /**
- * The Flex SDK version is contained in the flex-sdk-description.xml file.
- *
- * @param sdkSourceDirectory directory where to look for the fdk descriptor file
- * @return version string of the fdk
- */
- public static String getFlexSdkVersion(final File sdkSourceDirectory) {
- final File sdkDescriptor = new File(sdkSourceDirectory, "flex-sdk-description.xml");
-
- final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- try {
- // Parse the document
- final DocumentBuilder db = dbf.newDocumentBuilder();
- final Document dom = db.parse(sdkDescriptor);
-
- // Get name, version and build nodes
- final Element root = dom.getDocumentElement();
- final String name = root.getElementsByTagName("name").item(0).getTextContent();
- final String version = root.getElementsByTagName("version").item(0).getTextContent();
- final String build = root.getElementsByTagName("build").item(0).getTextContent();
-
- // In general the version consists of the content of the version element with an appended build-number.
- String sdkVersion = (build.equals("0")) ? version + "-SNAPSHOT" : version + "." + build;
-
- // Deal with the patched re-releases of all older SDKs:
- // The patched versions have A or B appended to their name and not a modified version or build number.
- // In order to differentiate the patched versions from the un-patched ones, we appnd A or B to the
- // version string.
- if (name.endsWith("A")) {
- sdkVersion += "A";
- } else if (name.endsWith("B")) {
- sdkVersion += "B";
- }
-
- // If the name contains "Apache", we prefix the version with "Apache-". This is cut off
- // again later on.
- if (name.contains("Apache")) {
- sdkVersion = "Apache-" + sdkVersion;
- }
-
- return sdkVersion;
- } catch (ParserConfigurationException pce) {
- throw new RuntimeException(pce);
- } catch (SAXException se) {
- throw new RuntimeException(se);
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/src/main/java/air/AirCompilerGenerator.java
----------------------------------------------------------------------
diff --git a/mavenizer/src/main/java/air/AirCompilerGenerator.java b/mavenizer/src/main/java/air/AirCompilerGenerator.java
deleted file mode 100644
index b9c14eb..0000000
--- a/mavenizer/src/main/java/air/AirCompilerGenerator.java
+++ /dev/null
@@ -1,156 +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 air;
-
-import common.BaseGenerator;
-import common.MavenMetadata;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Created with IntelliJ IDEA.
- * User: cdutz
- * Date: 02.02.13
- * Time: 13:41
- */
-public class AirCompilerGenerator extends BaseGenerator {
-
- public void process(final File sdkSourceDirectory, final boolean isApache, final File sdkTargetDirectory,
- final String sdkVersion, boolean useApache)
- throws Exception {
-
- final File sdkCompilerLibsDirectory = new File(sdkSourceDirectory, "lib");
- final List<File> jars = new ArrayList<File>();
- jars.addAll(Arrays.asList(sdkCompilerLibsDirectory.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.equalsIgnoreCase("adt.jar") ||
- name.equalsIgnoreCase("baksmali.jar") ||
- name.equalsIgnoreCase("smali.jar");
- }
- })));
-
- // A pom artifact will be generated that has all libs as a dependency.
- final MavenMetadata metadata = new MavenMetadata();
- metadata.setGroupId("com.adobe.air");
- metadata.setArtifactId("compiler");
- metadata.setVersion(sdkVersion);
- metadata.setPackaging("pom");
-
- // Create an empty pom document.
- final Document pom = createPomDocument(metadata);
-
- // Get the root element, as we will be adding the dependencies to that.
- final Element root = pom.getDocumentElement();
- // Add a "dependencies" element.
- final Element dependencies = pom.createElementNS(BaseGenerator.MAVEN_SCHEMA_URI, "dependencies");
- root.appendChild(dependencies);
-
- // Generate artifacts for every jar in the input directories.
- for(final File sourceJarFile : jars) {
- // Calculate a checksum for the current file. We will use this checksum to query maven central
- // in order to find out if this lib has already been published. If it has, there is no need to
- // publish it again under a new name. In case a matching artifact is found the generated FDK
- // will use the already deployed version. Additionally the checksum will be saved and if a
- // fdk generated after this one uses the same version of a lib, the version of the older fdk is
- // used also reducing the amount of jars that have to be re-deployed.
- final String checksum = calculateChecksum(sourceJarFile);
-
- // Try to get artifact metadata based upon the checksum by looking up the internal cache.
- MavenMetadata artifactMetadata = BaseGenerator.checksums.get(checksum);
- // Reusing artifact from other sdk version.
- if(artifactMetadata != null) {
- System.out.println("Reusing artifact (" + checksum + ") : " + artifactMetadata.getGroupId() + ":" +
- artifactMetadata.getArtifactId() + ":" + artifactMetadata.getVersion());
- appendArtifact(artifactMetadata, dependencies);
- }
- // Id no artifact was found in the local cache, continue processing.
- else {
- // Do a lookup in maven central.
- artifactMetadata = lookupMetadataForChecksum(checksum);
-
- // The file was available on maven central, so use that version instead of the one coming with the sdk.
- if(artifactMetadata != null) {
- appendArtifact(artifactMetadata, dependencies);
- }
- // The file was not available on maven central, so we have to add it manually.
- else {
- // The artifact name is the name of the jar.
- final String dependencyArtifactId =
- sourceJarFile.getName().substring(0, sourceJarFile.getName().lastIndexOf("."));
-
- // Generate a new metadata object
- artifactMetadata = new MavenMetadata();
- artifactMetadata.setGroupId("com.adobe.air.compiler");
- artifactMetadata.setArtifactId(dependencyArtifactId);
- artifactMetadata.setVersion(sdkVersion);
- artifactMetadata.setPackaging("jar");
-
- // Create the name of the directory that will contain the artifact.
- final File targetJarDirectory = new File(sdkTargetDirectory,
- "com/adobe/air/compiler/" + artifactMetadata.getArtifactId() + "/" +
- artifactMetadata.getVersion());
- // Create the directory.
- if(targetJarDirectory.mkdirs()) {
- // Create the filename of the artifact.
- final File targetJarFile = new File(targetJarDirectory, artifactMetadata.getArtifactId() + "-" +
- artifactMetadata.getVersion() + "." + artifactMetadata.getPackaging());
-
- // Copy the file to it's destination.
- copyFile(sourceJarFile, targetJarFile);
-
- // Add the dependency to the compiler-poms dependency section.
- appendArtifact(artifactMetadata, dependencies);
- } else {
- throw new RuntimeException("Could not create directory: " + targetJarDirectory.getAbsolutePath());
- }
-
- // Create the pom document that will reside next to the artifact lib.
- final Document artifactPom = createPomDocument(artifactMetadata);
- final File artifactPomFile =
- new File(targetJarDirectory, dependencyArtifactId + "-" + sdkVersion + ".pom");
- writeDocument(artifactPom, artifactPomFile);
- }
-
- // Remember the checksum for later re-usage.
- BaseGenerator.checksums.put(checksum, artifactMetadata);
- }
- }
-
- // Add a reference to the versions pom of the framework. This is needed so the compiler can check which
- // versions of the framework libs belong to the current compiler version. This is especially needed to
- // perform the check if the correct version of framework.swc is included in the dependencies. This step
- // was needed due to the re-deployment of patched FDKs in 2011/2012 in which the framework.swc no longer
- // has the same version as the compiler.
- final MavenMetadata frameworkVersions = new MavenMetadata();
- frameworkVersions.setGroupId("com.adobe.air");
- frameworkVersions.setArtifactId("framework");
- frameworkVersions.setVersion(sdkVersion);
- frameworkVersions.setPackaging("pom");
- appendArtifact(frameworkVersions, dependencies);
-
- // Write the compiler-pom document to file.
- final File pomFile = new File(sdkTargetDirectory,
- "com/adobe/air/compiler/" + sdkVersion + "/compiler-" + sdkVersion + ".pom");
- writeDocument(pom, pomFile);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/src/main/java/air/AirFrameworkGenerator.java
----------------------------------------------------------------------
diff --git a/mavenizer/src/main/java/air/AirFrameworkGenerator.java b/mavenizer/src/main/java/air/AirFrameworkGenerator.java
deleted file mode 100644
index 1c9e111..0000000
--- a/mavenizer/src/main/java/air/AirFrameworkGenerator.java
+++ /dev/null
@@ -1,155 +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 air;
-
-import common.BaseGenerator;
-import common.MavenMetadata;
-import org.w3c.dom.Document;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * Created with IntelliJ IDEA.
- * User: cdutz
- * Date: 11.05.12
- * Time: 14:55
- */
-public class AirFrameworkGenerator extends BaseGenerator {
-
- protected Map<String, String> libraryVersions = new HashMap<String, String>();
- protected Map<String, String> libraryLocations = new HashMap<String, String>();
-
- public void process(File sdkSourceDirectory, final boolean isApache, File sdkTargetDirectory, String sdkVersion,
- boolean useApache)
- throws Exception
- {
- final File frameworksDirectory = new File(sdkSourceDirectory, "frameworks");
- final File targetBaseDirectory = new File(sdkTargetDirectory, "com/adobe/air/framework");
-
- // Generate the artifacts based upon the structure of the libraries in the lib-directory.
- final File swcsDirectory = new File(frameworksDirectory, "libs/air");
- generateArtifactsForDirectory(
- swcsDirectory, targetBaseDirectory, sdkVersion, "com.adobe.air.framework");
- }
-
- protected void generateArtifactsForDirectory(
- final File sourceDirectory, final File targetDirectory, final String sdkVersion, final String groupId)
- throws Exception
- {
- final MavenMetadata groupMetadata = new MavenMetadata();
- groupMetadata.setGroupId(groupId.substring(0, groupId.lastIndexOf(".")));
- groupMetadata.setArtifactId(groupId.substring(groupId.lastIndexOf(".") + 1, groupId.length()));
- groupMetadata.setVersion(sdkVersion);
- groupMetadata.setPackaging("pom");
- groupMetadata.setLibrariesWithResourceBundles(new ArrayList<String>());
- groupMetadata.setDependencies(new ArrayList<MavenMetadata>());
-
- // Don't deploy the player, as this has to be dealt with differently.
- final File[] directoryContent = sourceDirectory.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.getName().endsWith(".swc");
- }
- });
-
- if(directoryContent != null) {
- for(File file : directoryContent) {
- final MavenMetadata metadata = new MavenMetadata();
- metadata.setGroupId(groupId);
- String libraryName = file.getName().substring(0, file.getName().lastIndexOf("."));
-
- String libraryVersion = libraryVersions.get(libraryName);
- if(libraryVersion == null) {
- libraryVersion = sdkVersion;
- }
- final File targetSwcDirectory = new File(targetDirectory, libraryName + "/" + libraryVersion);
- if(!targetSwcDirectory.exists()) {
- if(!targetSwcDirectory.mkdirs()) {
- throw new RuntimeException(
- "Could not create directory: " + targetSwcDirectory.getAbsolutePath());
- }
- }
- final File targetSwcFile =
- new File(targetSwcDirectory, libraryName + "-" + libraryVersion + ".swc");
- copyFile(file, targetSwcFile);
-
- metadata.setArtifactId(libraryName);
- metadata.setVersion(libraryVersion);
- metadata.setPackaging("swc");
-
- generateSwcPom(targetSwcFile, metadata);
-
- groupMetadata.getDependencies().add(metadata);
-
- // Save the checksum and metadata of the playerglobal, so we can
- // find out which air sdk is used when deploying the flex sdks later
- // on.
- if("airglobal".equals(libraryName)) {
- final String checksum = calculateChecksum(file);
- checksums.put(checksum, metadata);
- }
-
- libraryLocations.put(libraryName, targetSwcDirectory.getAbsolutePath());
- libraryVersions.put(libraryName, libraryVersion);
- }
- }
-
- final MavenMetadata commonFrameworkMetaData = new MavenMetadata();
- commonFrameworkMetaData.setGroupId(groupId);
- commonFrameworkMetaData.setArtifactId("common-framework");
- commonFrameworkMetaData.setVersion(groupMetadata.getVersion());
- commonFrameworkMetaData.setPackaging("pom");
- commonFrameworkMetaData.setDependencies(new ArrayList<MavenMetadata>());
- commonFrameworkMetaData.setLibrariesWithResourceBundles(new ArrayList<String>());
-
- for(final MavenMetadata dependency : groupMetadata.getDependencies()) {
- commonFrameworkMetaData.getDependencies().add(dependency);
- if(groupMetadata.getLibrariesWithResourceBundles().contains(dependency.getArtifactId())) {
- commonFrameworkMetaData.getLibrariesWithResourceBundles().add(dependency.getArtifactId());
- }
- }
- final File commonFrameworkPom = new File(targetDirectory,
- "common-framework/" + groupMetadata.getVersion() + "/common-framework-" +
- groupMetadata.getVersion() + ".pom");
- generateSwcPom(commonFrameworkPom, commonFrameworkMetaData);
-
- // Generate the master pom for the current library (Pom that defines
- // all versions of the current sdk libraries.
- final File groupPomFile = new File(targetDirectory,
- groupMetadata.getVersion() + "/" + groupMetadata.getArtifactId() + "-" +
- groupMetadata.getVersion() + ".pom");
- generateDependencyManagementPom(groupPomFile, groupMetadata);
- }
-
- protected void generateSwcPom(final File targetSwc, final MavenMetadata metadata) throws Exception {
- final String swcPath = targetSwc.getAbsolutePath();
- final String pomPath = swcPath.substring(0, swcPath.lastIndexOf(".")) + ".pom";
-
- final Document pom = createPomDocument(metadata);
-
- writeDocument(pom, new File(pomPath));
- }
-
- protected void generateDependencyManagementPom(final File targetSwc, final MavenMetadata metadata) throws Exception {
- final String swcPath = targetSwc.getAbsolutePath();
- final String pomPath = swcPath.substring(0, swcPath.lastIndexOf(".")) + ".pom";
-
- final Document pom = createPomDocumentDependencyManagement(metadata);
-
- writeDocument(pom, new File(pomPath));
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/38514b56/mavenizer/src/main/java/air/AirRuntimeGenerator.java
----------------------------------------------------------------------
diff --git a/mavenizer/src/main/java/air/AirRuntimeGenerator.java b/mavenizer/src/main/java/air/AirRuntimeGenerator.java
deleted file mode 100644
index fd329ad..0000000
--- a/mavenizer/src/main/java/air/AirRuntimeGenerator.java
+++ /dev/null
@@ -1,205 +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 air;
-
-import common.BaseGenerator;
-import common.MavenMetadata;
-import org.apache.commons.compress.archivers.ArchiveEntry;
-import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
-import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
-
-import java.io.*;
-import java.text.NumberFormat;
-import java.util.Locale;
-
-/**
- * Created with IntelliJ IDEA.
- * User: cdutz
- * Date: 14.05.12
- * Time: 22:42
- */
-public class AirRuntimeGenerator extends BaseGenerator {
-
- @Override
- public void process(File sdkSourceDirectory, boolean isApache, File sdkTargetDirectory, String sdkVersion,
- boolean useApache)
- throws Exception
- {
- processFlashRuntime(sdkSourceDirectory, sdkTargetDirectory);
- }
-
- protected void processFlashRuntime(File sdkSourceDirectory, File sdkTargetDirectory)
- throws Exception
- {
- final File runtimeDirectory = new File(sdkSourceDirectory, "runtimes");
- final File flashPlayerDirectory = new File(runtimeDirectory, "player");
-
- File[] versions = flashPlayerDirectory.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.isDirectory() && !"win".equalsIgnoreCase(pathname.getName()) &&
- !"lnx".equalsIgnoreCase(pathname.getName()) && !"mac".equalsIgnoreCase(pathname.getName());
- }
- });
- // The flash-player 9 is installed directly in the player directory.
- if(new File(flashPlayerDirectory, "win").exists()) {
- final File[] extendedVersions = new File[versions.length + 1];
- System.arraycopy(versions, 0, extendedVersions, 0, versions.length);
- extendedVersions[versions.length] = flashPlayerDirectory;
- versions = extendedVersions;
- }
-
- if(versions != null) {
- for(final File versionDir : versions) {
- // If the versionDir is called "player", then this is the home of the flash-player version 9.
- final String playerVersionString = "player".equalsIgnoreCase(versionDir.getName()) ? "9.0" : versionDir.getName();
- final double playerVersion = Double.valueOf(playerVersionString);
- final NumberFormat doubleFormat = NumberFormat.getInstance(Locale.US);
- doubleFormat.setMinimumFractionDigits(1);
- doubleFormat.setMaximumFractionDigits(1);
- final String version = doubleFormat.format(playerVersion);
-
- final File targetDir = new File(sdkTargetDirectory, "com/adobe/flash/runtime/" + version);
-
- // Deploy Windows binaries.
- final File windowsDirectory = new File(versionDir, "win");
- if(windowsDirectory.exists()) {
- // Find out if a flash-player binary exists.
- File flashPlayerBinary = null;
- if(new File(windowsDirectory, "FlashPlayerDebugger.exe").exists()) {
- flashPlayerBinary = new File(windowsDirectory, "FlashPlayerDebugger.exe");
- } else if(new File(windowsDirectory, "FlashPlayer.exe").exists()) {
- flashPlayerBinary = new File(windowsDirectory, "FlashPlayer.exe");
- }
-
- // If a binary exists, copy it to the target and create a pom for it.
- if (flashPlayerBinary != null) {
- if(!targetDir.exists()) {
- if(!targetDir.mkdirs()) {
- throw new RuntimeException("Could not create directory: " + targetDir.getAbsolutePath());
- }
- }
- final File targetFile = new File(targetDir, "/runtime-" + version + "-win.exe");
- copyFile(flashPlayerBinary, targetFile);
- }
- }
-
- // Deploy Mac binaries.
- final File macDirectory = new File(versionDir, "mac");
- if(macDirectory.exists()) {
- // Find out if a flash-player binary exists.
- File flashPlayerBinary = null;
- if(new File(macDirectory, "Flash Player.app.zip").exists()) {
- flashPlayerBinary = new File(macDirectory, "Flash Player.app.zip");
- } else if(new File(macDirectory, "Flash Player Debugger.app.zip").exists()) {
- flashPlayerBinary = new File(macDirectory, "Flash Player Debugger.app.zip");
- }
-
- // If a binary exists, copy it to the target and create a pom for it.
- if (flashPlayerBinary != null) {
- if(!targetDir.exists()) {
- if(!targetDir.mkdirs()) {
- throw new RuntimeException("Could not create directory: " + targetDir.getAbsolutePath());
- }
- }
- final File targetFile = new File(targetDir, "/runtime-" + version + "-mac.zip");
- copyFile(flashPlayerBinary, targetFile);
- }
- }
-
- // Deploy Linux binaries.
- final File lnxDirectory = new File(versionDir, "lnx");
- if(lnxDirectory.exists()) {
- // Find out if a flash-player binary exists.
- File flashPlayerBinary = null;
- if(new File(lnxDirectory, "flashplayer.tar.gz").exists()) {
- flashPlayerBinary = new File(lnxDirectory, "flashplayer.tar.gz");
- } else if(new File(lnxDirectory, "flashplayerdebugger.tar.gz").exists()) {
- flashPlayerBinary = new File(lnxDirectory, "flashplayerdebugger.tar.gz");
- }
-
- // Decompress the archive.
- // First unzip it.
- final FileInputStream fin = new FileInputStream(flashPlayerBinary);
- final BufferedInputStream in = new BufferedInputStream(fin);
- final File tempTarFile = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".tar");
- final FileOutputStream out = new FileOutputStream(tempTarFile);
- final GzipCompressorInputStream gzIn = new GzipCompressorInputStream(in);
- final byte[] buffer = new byte[1024];
- int n;
- while (-1 != (n = gzIn.read(buffer))) {
- out.write(buffer, 0, n);
- }
- out.close();
- gzIn.close();
-
- // Then untar it.
- File uncompressedBinary = null;
- final FileInputStream tarFileInputStream = new FileInputStream(tempTarFile);
- final TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(tarFileInputStream);
- ArchiveEntry entry;
- while((entry = tarArchiveInputStream.getNextEntry()) != null) {
- if("flashplayer".equals(entry.getName())) {
- uncompressedBinary = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".uexe");
- final FileOutputStream uncompressedBinaryOutputStream = new FileOutputStream(uncompressedBinary);
- while(-1 != (n = tarArchiveInputStream.read(buffer))) {
- uncompressedBinaryOutputStream.write(buffer, 0, n);
- }
- uncompressedBinaryOutputStream.close();
- } else if("flashplayerdebugger".equals(entry.getName())) {
- uncompressedBinary = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".uexe");
- final FileOutputStream uncompressedBinaryOutputStream = new FileOutputStream(uncompressedBinary);
- while(-1 != (n = tarArchiveInputStream.read(buffer))) {
- uncompressedBinaryOutputStream.write(buffer, 0, n);
- }
- uncompressedBinaryOutputStream.close();
- }
- }
- tarFileInputStream.close();
-
- // If a binary exists, copy it to the target and create a pom for it.
- if (uncompressedBinary != null) {
- if(!targetDir.exists()) {
- if(!targetDir.mkdirs()) {
- throw new RuntimeException("Could not create directory: " + targetDir.getAbsolutePath());
- }
- }
- final File targetFile = new File(targetDir, "/runtime-" + version + "-linux.uexe");
- copyFile(uncompressedBinary, targetFile);
-
- // Clean up in the temp directory.
- if(!uncompressedBinary.delete()) {
- System.out.println("Could not delete: " + uncompressedBinary.getAbsolutePath());
- }
- }
-
- // Clean up in the temp directory.
- if(!tempTarFile.delete()) {
- System.out.println("Could not delete: " + tempTarFile.getAbsolutePath());
- }
- }
-
- final MavenMetadata playerArtifact = new MavenMetadata();
- playerArtifact.setGroupId("com.adobe.flash");
- playerArtifact.setArtifactId("runtime");
- playerArtifact.setVersion(version);
- playerArtifact.setPackaging("exe");
-
- writeDocument(createPomDocument(playerArtifact), new File(targetDir, "runtime-" + version + ".pom"));
- }
- }
- }
-}
[19/28] git commit: [flex-utilities] [refs/heads/develop] -
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future
mavenized releases of Flex - Added the maven assembly plugin to create the
fat jar that can be executed from the commandl
Posted by cd...@apache.org.
FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future mavenized releases of Flex
- Added the maven assembly plugin to create the fat jar that can be executed from the commandline.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/0ee60fc9
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/0ee60fc9
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/0ee60fc9
Branch: refs/heads/develop
Commit: 0ee60fc95df3c5a42d74a7eec734c719ddbf6503
Parents: 07dc119
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sat Jul 12 12:58:10 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sat Jul 12 12:58:10 2014 +0200
----------------------------------------------------------------------
mavenizer/core/pom.xml | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/0ee60fc9/mavenizer/core/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/core/pom.xml b/mavenizer/core/pom.xml
index 21dd31c..a46530d 100644
--- a/mavenizer/core/pom.xml
+++ b/mavenizer/core/pom.xml
@@ -32,6 +32,39 @@
<version>1.0.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>
+ </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>
[28/28] git commit: [flex-utilities] [refs/heads/develop] - Merge
branch 'feature/mavenizer-refactoring' into develop
Posted by cd...@apache.org.
Merge branch 'feature/mavenizer-refactoring' into develop
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/a1d4c672
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/a1d4c672
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/a1d4c672
Branch: refs/heads/develop
Commit: a1d4c67255672ed0893e3e18d1b6b1821d765c3d
Parents: 62fb6a4 1eefc9d
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Fri Sep 5 15:14:41 2014 +0200
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Fri Sep 5 15:14:41 2014 +0200
----------------------------------------------------------------------
mavenizer/README.txt | 9 +-
mavenizer/converters/air/pom.xml | 43 +
.../utilities/converter/air/AirConverter.java | 263 ++++++
mavenizer/converters/base/pom.xml | 53 ++
.../flex/utilities/converter/BaseConverter.java | 437 ++++++++++
.../flex/utilities/converter/Converter.java | 30 +
.../exceptions/ConverterException.java | 32 +
.../converter/model/MavenArtifact.java | 168 ++++
.../src/main/resources/templates/default.vm | 23 +
.../base/src/main/resources/templates/pom.vm | 37 +
.../base/src/main/resources/velocity.properties | 10 +
mavenizer/converters/flash/pom.xml | 48 ++
.../converter/flash/FlashConverter.java | 279 ++++++
mavenizer/converters/flex/pom.xml | 56 ++
.../utilities/converter/flex/FlexConverter.java | 686 +++++++++++++++
mavenizer/converters/pom.xml | 45 +
mavenizer/core/pom.xml | 82 ++
.../utilities/converter/core/AirDownloader.java | 51 ++
.../converter/core/BatchConverter.java | 87 ++
.../converter/core/FlashDownloader.java | 61 ++
.../utilities/converter/core/SdkConverter.java | 70 ++
mavenizer/deployers/aether/pom.xml | 127 +++
.../deployer/aether/AetherDeployer.java | 248 ++++++
mavenizer/deployers/maven/pom.xml | 35 +
.../converter/deployer/maven/MavenDeployer.java | 189 +++++
mavenizer/deployers/pom.xml | 40 +
mavenizer/pom.xml | 152 +---
mavenizer/retrievers/base/pom.xml | 53 ++
.../converter/retrievers/BaseRetriever.java | 116 +++
.../converter/retrievers/Retriever.java | 32 +
.../exceptions/RetrieverException.java | 32 +
.../retrievers/types/PlatformType.java | 28 +
.../converter/retrievers/types/SdkType.java | 28 +
.../converter/retrievers/utils/ProgressBar.java | 47 ++
mavenizer/retrievers/download/pom.xml | 43 +
.../retrievers/download/DownloadRetriever.java | 307 +++++++
.../src/main/resources/message.properties | 21 +
mavenizer/retrievers/pom.xml | 40 +
mavenizer/src/main/java/SDKDeployer.java | 186 ----
mavenizer/src/main/java/SDKGenerator.java | 240 ------
.../src/main/java/air/AirCompilerGenerator.java | 156 ----
.../main/java/air/AirFrameworkGenerator.java | 155 ----
.../src/main/java/air/AirRuntimeGenerator.java | 205 -----
.../src/main/java/common/BaseGenerator.java | 389 ---------
.../src/main/java/common/MavenMetadata.java | 91 --
.../main/java/flex/FlexCompilerGenerator.java | 246 ------
.../main/java/flex/FlexFrameworkGenerator.java | 844 -------------------
.../main/java/flex/FlexRuntimeGenerator.java | 205 -----
48 files changed, 3992 insertions(+), 2833 deletions(-)
----------------------------------------------------------------------
[17/28] git commit: [flex-utilities] [refs/heads/develop] - Added a
feature to zip up the Air runtime directories to the AirConverter.
Posted by cd...@apache.org.
Added a feature to zip up the Air runtime directories to the AirConverter.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/4eb49a5e
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/4eb49a5e
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/4eb49a5e
Branch: refs/heads/develop
Commit: 4eb49a5e8d688c9366bacf6e05d21b4e42bf83eb
Parents: 7d6c9f6
Author: cdutz <ch...@c-ware.de>
Authored: Thu Jun 26 16:13:21 2014 +0200
Committer: cdutz <ch...@c-ware.de>
Committed: Thu Jun 26 16:13:21 2014 +0200
----------------------------------------------------------------------
.../utilities/converter/air/AirConverter.java | 41 ++++-
.../flex/utilities/converter/BaseConverter.java | 162 +++++++------------
2 files changed, 95 insertions(+), 108 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4eb49a5e/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java b/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
index 596ff5c..c655df5 100644
--- a/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
+++ b/mavenizer/converters/air/src/main/java/org/apache/flex/utilities/converter/air/AirConverter.java
@@ -113,12 +113,18 @@ public class AirConverter extends BaseConverter implements Converter {
final List<File> files = new ArrayList<File>();
files.addAll(Arrays.asList(directory.listFiles(new AirRuntimeFilter())));
- // Generate artifacts for every jar in the input directories.
+ // Generate artifacts for every jar in the input directories (Actually this is only one file).
for(final File sourceFile : files) {
final MavenArtifact artifact = resolveArtifact(sourceFile, "com.adobe.air.runtime", airSdkVersion);
runtime.addDependency(artifact);
}
+ // Zip up the AIR runtime directory.
+ final MavenArtifact airRuntimeArtifact = generateAirRuntimeArtifact(rootSourceDirectory);
+ if(airRuntimeArtifact != null) {
+ runtime.addDependency(airRuntimeArtifact);
+ }
+
// Write this artifact to file.
writeArtifact(runtime);
}
@@ -161,7 +167,38 @@ public class AirConverter extends BaseConverter implements Converter {
//
///////////////////////////////////////////////////////////////////////////////////////////////////
- /**
+ protected MavenArtifact generateAirRuntimeArtifact(File rootDirectory) throws ConverterException {
+ final MavenArtifact airRuntimeArtifact = new MavenArtifact();
+ airRuntimeArtifact.setGroupId("com.adobe.air.runtime");
+ airRuntimeArtifact.setArtifactId("air-runtime");
+ airRuntimeArtifact.setVersion(airSdkVersion);
+ airRuntimeArtifact.setPackaging("zip");
+
+ final File runtimeRoot = new File(rootDirectory, "runtimes.air".replace(".", File.separator));
+ final File[] platforms = runtimeRoot.listFiles();
+ if(platforms != null) {
+ for (final File platform : platforms) {
+ if (!platform.isDirectory()) {
+ continue;
+ }
+ final String platformName = platform.getName();
+ try {
+ final File zip = File.createTempFile("AirRuntime-" + platformName + "-" + airSdkVersion, "zip");
+ generateZip(platform.listFiles(), zip);
+ airRuntimeArtifact.addBinaryArtifact(platformName, zip);
+ } catch (IOException e) {
+ throw new ConverterException("Error creating runtime zip.", e);
+ }
+ }
+ } else {
+ return null;
+ }
+
+ writeArtifact(airRuntimeArtifact);
+ return airRuntimeArtifact;
+ }
+
+ /**
* Get the version of an AIR SDK from the content of the SDK directory.
*
* @return version string for the current AIR SDK
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4eb49a5e/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
----------------------------------------------------------------------
diff --git a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
index 499b8e9..9747209 100644
--- a/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
+++ b/mavenizer/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
@@ -277,112 +277,6 @@ public abstract class BaseConverter {
} catch (Exception e) {
throw new ConverterException("Error generating template output.", e);
}
-
- /*final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- final DocumentBuilder builder;
- try {
- builder = factory.newDocumentBuilder();
- DOMImplementation domImpl = builder.getDOMImplementation();
- final Document pom = domImpl.createDocument(MAVEN_SCHEMA_URI, "project", null);
-
- final Element root = pom.getDocumentElement();
- final Element modelVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "modelVersion");
- modelVersion.setTextContent("4.0.0");
- root.appendChild(modelVersion);
- final Element groupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
- groupId.setTextContent(metadata.getGroupId());
- root.appendChild(groupId);
- final Element artifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
- artifactId.setTextContent(metadata.getArtifactId());
- root.appendChild(artifactId);
- final Element version = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
- version.setTextContent(metadata.getVersion());
- root.appendChild(version);
- final Element packaging = pom.createElementNS(MAVEN_SCHEMA_URI, "packaging");
- packaging.setTextContent(metadata.getPackaging());
- root.appendChild(packaging);
-
- // Output dependency data.
- if((metadata.getDependencies() != null) && !metadata.getDependencies().isEmpty()) {
- final Element dependencies = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencies");
- root.appendChild(dependencies);
- final Element dependencyManagement = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencyManagement");
- final Element dependencyManagementDependencies = pom.createElementNS(MAVEN_SCHEMA_URI, "dependencies");
- dependencyManagement.appendChild(dependencyManagementDependencies);
- root.appendChild(dependencyManagement);
-
- final Map<String, MavenArtifact> dependencyIndex = new HashMap<String, MavenArtifact>();
- for(final MavenArtifact dependencyMetadata : metadata.getDependencies()) {
- Element dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
- dependencies.appendChild(dependency);
-
- // Generate the normal dependency.
- Element dependencyGroupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
- dependencyGroupId.setTextContent(dependencyMetadata.getGroupId());
- dependency.appendChild(dependencyGroupId);
- Element dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
- dependencyArtifactId.setTextContent(dependencyMetadata.getArtifactId());
- dependency.appendChild(dependencyArtifactId);
- Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
- dependencyVersion.setTextContent(dependencyMetadata.getVersion());
- dependency.appendChild(dependencyVersion);
- Element dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
- dependencyPackaging.setTextContent(dependencyMetadata.getPackaging());
- dependency.appendChild(dependencyPackaging);
- if(dependencyMetadata.getClassifier() != null) {
- final Element dependencyClassifier = pom.createElementNS(MAVEN_SCHEMA_URI, "classifier");
- dependencyClassifier.setTextContent(dependencyMetadata.getClassifier());
- dependency.appendChild(dependencyClassifier);
- }
-
- // Configure the dependency including version in the dependency management section of the pom.
- dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
- dependencyGroupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
- dependencyGroupId.setTextContent(dependencyMetadata.getGroupId());
- dependency.appendChild(dependencyGroupId);
- dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
- dependencyArtifactId.setTextContent(dependencyMetadata.getArtifactId());
- dependency.appendChild(dependencyArtifactId);
- Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
- dependencyVersion.setTextContent(dependencyMetadata.getVersion());
- dependency.appendChild(dependencyVersion);
- dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
- dependencyPackaging.setTextContent(dependencyMetadata.getPackaging());
- dependency.appendChild(dependencyPackaging);
- dependencyManagementDependencies.appendChild(dependency);
-
- dependencyIndex.put(dependencyMetadata.getArtifactId(), dependencyMetadata);
- }
-
- // Output the rb.swc dependencies.
- if(metadata.getLibrariesWithResourceBundles() != null) {
- for(final String artifactWithResourceBundle : metadata.getLibrariesWithResourceBundles()) {
- final MavenArtifact dependencyMetadata = dependencyIndex.get(artifactWithResourceBundle);
- if(dependencyMetadata != null) {
- final Element dependency = pom.createElementNS(MAVEN_SCHEMA_URI, "dependency");
- dependencies.appendChild(dependency);
-
- final Element dependencyGroupId = pom.createElementNS(MAVEN_SCHEMA_URI, "groupId");
- dependencyGroupId.setTextContent(dependencyMetadata.getGroupId());
- dependency.appendChild(dependencyGroupId);
- final Element dependencyArtifactId = pom.createElementNS(MAVEN_SCHEMA_URI, "artifactId");
- dependencyArtifactId.setTextContent(dependencyMetadata.getArtifactId());
- dependency.appendChild(dependencyArtifactId);
- final Element dependencyVersion = pom.createElementNS(MAVEN_SCHEMA_URI, "version");
- dependencyVersion.setTextContent(dependencyMetadata.getVersion());
- dependency.appendChild(dependencyVersion);
- final Element dependencyPackaging = pom.createElementNS(MAVEN_SCHEMA_URI, "type");
- dependencyPackaging.setTextContent("rb.swc");
- dependency.appendChild(dependencyPackaging);
- }
- }
- }
- }
- return pom;
- } catch (ParserConfigurationException e) {
- throw new ConverterException("Error creating pom document.", e);
- }*/
}
protected void writeDummy(final File targetFile) throws ConverterException {
@@ -484,4 +378,60 @@ public abstract class BaseConverter {
}
}
+ protected void generateZip(File[] sourceFiles, File targetFile) throws ConverterException {
+ if((sourceFiles == null) || (sourceFiles.length == 0)) {
+ return;
+ }
+ final File rootDir = sourceFiles[0].getParentFile();
+ final File zipInputFiles[] = new File[sourceFiles.length];
+ System.arraycopy(sourceFiles, 0, zipInputFiles, 0, sourceFiles.length);
+
+ try {
+ // Add all the content to a zip-file.
+ final ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(targetFile));
+ for (final File file : zipInputFiles) {
+ addFileToZip(zipOutputStream, file, rootDir);
+ }
+ zipOutputStream.close();
+ } catch(IOException e) {
+ throw new ConverterException("Error generating " + targetFile.getName() + " zip.", e);
+ }
+ }
+
+ private void addFileToZip(ZipOutputStream zipOutputStream, File inputFile, File rootDirectory)
+ throws ConverterException {
+
+ if (inputFile == null) {
+ return;
+ }
+
+ // If this is a directory, add all it's children.
+ if (inputFile.isDirectory()) {
+ final File directoryContent[] = inputFile.listFiles();
+ if (directoryContent != null) {
+ for (final File file : directoryContent) {
+ addFileToZip(zipOutputStream, file, rootDirectory);
+ }
+ }
+ }
+ // If this is a file, add it to the zips output.
+ else {
+ byte[] buf = new byte[1024];
+ try {
+ final FileInputStream in = new FileInputStream(inputFile);
+ final String zipPath = inputFile.getAbsolutePath().substring(
+ rootDirectory.getAbsolutePath().length() + 1).replace("\\", "/");
+ zipOutputStream.putNextEntry(new ZipEntry(zipPath));
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ zipOutputStream.write(buf, 0, len);
+ }
+ zipOutputStream.closeEntry();
+ in.close();
+ } catch(IOException e) {
+ throw new ConverterException("Error adding files to zip.", e);
+ }
+ }
+ }
+
}