http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/657a7def/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 deleted file mode 100644 index 6def8a1..0000000 --- a/mavenizer/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java +++ /dev/null @@ -1,735 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.flex.utilities.converter.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; - protected String flexBuild; - - /** - * @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); - this.flexBuild = getFlexBuild(rootSourceDirectory); - } - - /** - * Entry point for generating the Maven artifacts for an Flex SDK. - * - * @throws ConverterException - */ - @Override - protected void processDirectory() throws ConverterException { - if((flexSdkVersion == null) || !rootSourceDirectory.exists() || !rootSourceDirectory.isDirectory()) { - System.out.println("Skipping Flex SDK generation."); - return; - } - - 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()))); - } - - // 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); - } - } - - // 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())) { - final File mobileExperimental = new File(directory.getParent(), "experimental_mobile.swc"); - if(mobileExperimental.exists()) { - 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() { - public boolean accept(File pathname) { - return pathname.isDirectory() && !"player".equals(pathname.getName()) && - !"mx".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. - 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); - artifact.addBinaryArtifact("rsl", rslSourceFile); - } - - // Copy the swzc. - 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); - artifact.addBinaryArtifact("caching", rslSourceFile); - } - - // Copy the language resources. - 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); - } - - // 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); - } - - 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 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"); - 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"); - - final File targetSwcFile; - 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"); - final String targetPlayer = getTargetPlayer(new File(frameworkDir, "libs/player")); - if(targetPlayer == null) { - System.out.println("Skipping theme compilation due to missing playerglobl.swc"); - return null; - } - - processCmd.add("java"); - processCmd.add("-Xmx384m"); - processCmd.add("-Dsun.io.useCanonCaches=false"); - processCmd.add("-jar"); - processCmd.add(compcLibrary.getCanonicalPath()); - processCmd.add("+flexlib=" + frameworkDir.getCanonicalPath()); - processCmd.add("-target-player=" + targetPlayer); - - if (themeDirectory.isDirectory()) { - // Add all the content files. - final File contents[] = themeDirectory.listFiles(new FileFilter() { - 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"); - - // If the descriptor is not present, return null as this FDK directory doesn't - // seem to contain a Flex SDK. - if(!sdkDescriptor.exists()) { - return null; - } - - 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; - } catch (ParserConfigurationException pce) { - throw new RuntimeException(pce); - } catch (SAXException se) { - throw new RuntimeException(se); - } catch (IOException ioe) { - throw new RuntimeException(ioe); - } - } - - /** - * Get the version of an Flex SDK from the content of the SDK directory. - * - * @return version string for the current Flex SDK - */ - protected String getFlexBuild(File rootDirectory) throws ConverterException { - final File sdkDescriptor = new File(rootDirectory, "flex-sdk-description.xml"); - - // If the descriptor is not present, return null as this FDK directory doesn't - // seem to contain a Flex SDK. - if(!sdkDescriptor.exists()) { - return null; - } - - 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(); - return root.getElementsByTagName("build").item(0).getTextContent(); - } 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, flexBuild); - 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; - } - - protected String getTargetPlayer(File playerDir) { - if(playerDir.exists() && playerDir.isDirectory()) { - File[] files = playerDir.listFiles(); - if((files != null) && files.length > 0) { - return files[0].getName(); - } - } - return null; - } - - public static class FlexCompilerFilter implements FilenameFilter { - private AirConverter.AirCompilerFilter airFilter = new AirConverter.AirCompilerFilter(); - - 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, String build) { - this.fileName = artifactName + "_" + artifactVersion + "." + build + ".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/657a7def/mavenizer/converters/fontkit/pom.xml ---------------------------------------------------------------------- diff --git a/mavenizer/converters/fontkit/pom.xml b/mavenizer/converters/fontkit/pom.xml deleted file mode 100644 index 3d472e0..0000000 --- a/mavenizer/converters/fontkit/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>converters</artifactId> - <version>1.0.0-SNAPSHOT</version> - </parent> - - <artifactId>fontkit-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/657a7def/mavenizer/converters/fontkit/src/main/java/org/apache/flex/utilities/converter/fontkit/FontkitConverter.java ---------------------------------------------------------------------- diff --git a/mavenizer/converters/fontkit/src/main/java/org/apache/flex/utilities/converter/fontkit/FontkitConverter.java b/mavenizer/converters/fontkit/src/main/java/org/apache/flex/utilities/converter/fontkit/FontkitConverter.java deleted file mode 100644 index 81fbe09..0000000 --- a/mavenizer/converters/fontkit/src/main/java/org/apache/flex/utilities/converter/fontkit/FontkitConverter.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.apache.flex.utilities.converter.fontkit; - -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.File; - -/** - * Created by christoferdutz on 06.04.15. - */ -public class FontkitConverter extends BaseConverter implements Converter { - - public FontkitConverter(File rootSourceDirectory, File rootTargetDirectory) throws ConverterException { - super(rootSourceDirectory, rootTargetDirectory); - } - - @Override - protected void processDirectory() throws ConverterException { - File fontkitRootDir = new File(rootSourceDirectory, "lib/external/optional"); - if(!fontkitRootDir.exists() || !fontkitRootDir.isDirectory()) { - System.out.println("Skipping Fontkit generation."); - return; - } - - File afeJar = new File(fontkitRootDir, "afe.jar"); - File aglj40Jar = new File(fontkitRootDir, "aglj40.jar"); - File rideauJar = new File(fontkitRootDir, "rideau.jar"); - File flexFontkitJar = new File(fontkitRootDir, "flex-fontkit.jar"); - - if(!afeJar.exists() || !aglj40Jar.exists() || !rideauJar.exists() || !flexFontkitJar.exists()) { - throw new ConverterException("Fontkit directory '" + fontkitRootDir.getPath() + "' must contain the jar " + - "files afe.jar, aglj40.jar, rideau.jar and flex-fontkit.jar."); - } - - final MavenArtifact fontkit = new MavenArtifact(); - fontkit.setGroupId("com.adobe"); - fontkit.setArtifactId("fontkit"); - fontkit.setVersion("1.0"); - fontkit.setPackaging("jar"); - fontkit.addDefaultBinaryArtifact(flexFontkitJar); - - final MavenArtifact afe = new MavenArtifact(); - afe.setGroupId("com.adobe.fontkit"); - afe.setArtifactId("afe"); - afe.setVersion("1.0"); - afe.setPackaging("jar"); - afe.addDefaultBinaryArtifact(afeJar); - fontkit.addDependency(afe); - - final MavenArtifact aglj40 = new MavenArtifact(); - aglj40.setGroupId("com.adobe.fontkit"); - aglj40.setArtifactId("aglj40"); - aglj40.setVersion("1.0"); - aglj40.setPackaging("jar"); - aglj40.addDefaultBinaryArtifact(aglj40Jar); - fontkit.addDependency(aglj40); - - final MavenArtifact rideau = new MavenArtifact(); - rideau.setGroupId("com.adobe.fontkit"); - rideau.setArtifactId("rideau"); - rideau.setVersion("1.0"); - rideau.setPackaging("jar"); - rideau.addDefaultBinaryArtifact(rideauJar); - fontkit.addDependency(rideau); - - writeArtifact(afe); - writeArtifact(aglj40); - writeArtifact(rideau); - writeArtifact(fontkit); - } - -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/657a7def/mavenizer/converters/pom.xml ---------------------------------------------------------------------- diff --git a/mavenizer/converters/pom.xml b/mavenizer/converters/pom.xml deleted file mode 100644 index 69a859b..0000000 --- a/mavenizer/converters/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>apache-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> - <module>fontkit</module> - <module>wrapper</module> - </modules> - -</project> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/657a7def/mavenizer/converters/wrapper/pom.xml ---------------------------------------------------------------------- diff --git a/mavenizer/converters/wrapper/pom.xml b/mavenizer/converters/wrapper/pom.xml deleted file mode 100644 index 86f8a43..0000000 --- a/mavenizer/converters/wrapper/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>converters</artifactId> - <version>1.0.0-SNAPSHOT</version> - </parent> - - <artifactId>wrapper-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/657a7def/mavenizer/converters/wrapper/src/main/java/org/apache/flex/utilities/converter/wrapper/WrapperConverter.java ---------------------------------------------------------------------- diff --git a/mavenizer/converters/wrapper/src/main/java/org/apache/flex/utilities/converter/wrapper/WrapperConverter.java b/mavenizer/converters/wrapper/src/main/java/org/apache/flex/utilities/converter/wrapper/WrapperConverter.java deleted file mode 100644 index 7e4af4c..0000000 --- a/mavenizer/converters/wrapper/src/main/java/org/apache/flex/utilities/converter/wrapper/WrapperConverter.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.apache.flex.utilities.converter.wrapper; - -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 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.File; -import java.io.IOException; - -/** - * Created by christoferdutz on 06.04.15. - */ -public class WrapperConverter extends BaseConverter implements Converter { - - public WrapperConverter(File rootSourceDirectory, File rootTargetDirectory) throws ConverterException { - super(rootSourceDirectory, rootTargetDirectory); - } - - @Override - protected void processDirectory() throws ConverterException { - File wrapperRootDir = new File(rootSourceDirectory, "templates/swfobject"); - if(!wrapperRootDir.exists() || !wrapperRootDir.isDirectory()) { - System.out.println("Skipping Wrapper generation."); - return; - } - - try { - // Rename the index.template.html to index.html - File indexHtml = new File(wrapperRootDir, "index.template.html"); - if(!indexHtml.renameTo(new File(wrapperRootDir, "index.html"))) { - System.out.println("Could not rename index.template.html to index.html."); - } - - final File wrapperWar = File.createTempFile("SWFObjectWrapper-2.2", ".war"); - generateZip(wrapperRootDir.listFiles(), wrapperWar); - - final MavenArtifact swfobjectWrapper = new MavenArtifact(); - swfobjectWrapper.setGroupId("org.apache.flex.wrapper"); - swfobjectWrapper.setArtifactId("swfobject"); - swfobjectWrapper.setVersion(getFlexVersion(rootSourceDirectory)); - swfobjectWrapper.setPackaging("war"); - swfobjectWrapper.addDefaultBinaryArtifact(wrapperWar); - - writeArtifact(swfobjectWrapper); - } catch (IOException e) { - throw new ConverterException("Error creating wrapper war.", 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"); - - // If the descriptor is not present, return null as this FDK directory doesn't - // seem to contain a Flex SDK. - if(!sdkDescriptor.exists()) { - return null; - } - - 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; - } 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/657a7def/mavenizer/deployers/aether/pom.xml ---------------------------------------------------------------------- diff --git a/mavenizer/deployers/aether/pom.xml b/mavenizer/deployers/aether/pom.xml deleted file mode 100644 index 692b99c..0000000 --- a/mavenizer/deployers/aether/pom.xml +++ /dev/null @@ -1,125 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>deployers</artifactId> - <version>1.0.0-SNAPSHOT</version> - </parent> - - <artifactId>aether-deployer</artifactId> - <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.deployer.aether.AetherDeployer</mainClass> - </manifest> - <manifestEntries> - <Implementation-Build>${project.version}</Implementation-Build> - </manifestEntries> - </archive> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - <finalName>aether-deployer-${project.version}-full</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> - <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/657a7def/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 deleted file mode 100644 index 89b991b..0000000 --- a/mavenizer/deployers/aether/src/main/java/org/apache/flex/utilities/converter/deployer/aether/AetherDeployer.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.flex.utilities.converter.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. - * Date: 03.11.13 - */ -public class AetherDeployer { - - private File directory; - private String url; - private String username; - private String password; - - public AetherDeployer(File directory, String url, String username, String password) { - this.directory = directory; - this.url = url; - this.username = username; - this.password = password; - } - - public AetherDeployer(String[] parameters) { - this.directory = new File(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.deploy(); - } - - 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."); - } - - public void deploy() { - 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 = 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(); - - // 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()) == '-') { - 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 { - public boolean accept(File pathname) { - return pathname.getName().endsWith(".pom"); - } - } - - private class DirFilter implements java.io.FileFilter { - public boolean accept(File pathname) { - return pathname.isDirectory(); - } - } - - private class ArtifactFilter implements java.io.FileFilter { - public boolean accept(File pathname) { - return !pathname.getName().endsWith(".pom") && !pathname.isDirectory(); - } - } - -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/657a7def/mavenizer/deployers/maven/pom.xml ---------------------------------------------------------------------- diff --git a/mavenizer/deployers/maven/pom.xml b/mavenizer/deployers/maven/pom.xml deleted file mode 100644 index c1fc93c..0000000 --- a/mavenizer/deployers/maven/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>deployers</artifactId> - <version>1.0.0-SNAPSHOT</version> - </parent> - - <artifactId>maven-deployer</artifactId> - <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.deployer.maven.MavenDeployer</mainClass> - </manifest> - <manifestEntries> - <Implementation-Build>${project.version}</Implementation-Build> - </manifestEntries> - </archive> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - <finalName>maven-deployer-${project.version}-full</finalName> - <appendAssemblyId>false</appendAssemblyId> - </configuration> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/657a7def/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 deleted file mode 100644 index 6b2da53..0000000 --- a/mavenizer/deployers/maven/src/main/java/org/apache/flex/utilities/converter/deployer/maven/MavenDeployer.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.flex.utilities.converter.deployer.maven; - -import java.io.*; -import java.util.ArrayList; -import java.util.List; - -/** - * Created with IntelliJ IDEA. - * Date: 11.08.12 - * Time: 18:17 - */ -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/657a7def/mavenizer/deployers/pom.xml ---------------------------------------------------------------------- diff --git a/mavenizer/deployers/pom.xml b/mavenizer/deployers/pom.xml deleted file mode 100644 index 692b45d..0000000 --- a/mavenizer/deployers/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>apache-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/657a7def/mavenizer/maven-extension/pom.xml ---------------------------------------------------------------------- diff --git a/mavenizer/maven-extension/pom.xml b/mavenizer/maven-extension/pom.xml deleted file mode 100644 index 4a96355..0000000 --- a/mavenizer/maven-extension/pom.xml +++ /dev/null @@ -1,118 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>apache-flex-sdk-converter</artifactId> - <version>1.0.0-SNAPSHOT</version> - </parent> - - <artifactId>maven-extension</artifactId> - <version>1.0.0-SNAPSHOT</version> - <packaging>jar</packaging> - - <build> - <plugins> - <plugin> - <groupId>org.sonatype.plugins</groupId> - <artifactId>sisu-maven-plugin</artifactId> - <version>1.4</version> - <executions> - <execution> - <id>generate-index</id> - <goals> - <goal>main-index</goal> - </goals> - </execution> - </executions> - </plugin> - - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <version>2.4</version> - <configuration> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - <finalName>flex-maven-extension-${project.version}</finalName> - <appendAssemblyId>false</appendAssemblyId> - </configuration> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>download-retriever</artifactId> - <version>1.0.0-SNAPSHOT</version> - </dependency> - <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>flash-converter</artifactId> - <version>1.0.0-SNAPSHOT</version> - </dependency> - <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>fontkit-converter</artifactId> - <version>1.0.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.apache.flex.utilities.converter</groupId> - <artifactId>wrapper-converter</artifactId> - <version>1.0.0-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>javax.inject</groupId> - <artifactId>javax.inject</artifactId> - <version>1</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-core</artifactId> - <version>3.1.1</version> - <scope>provided</scope> - </dependency> - </dependencies> - -</project>
