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 <[email protected]> Authored: Sat May 24 21:56:49 2014 +0200 Committer: Christofer Dutz <[email protected]> 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")); - } - } - } -}
