You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2013/11/03 16:03:46 UTC

[1/2] git commit: [flex-utilities] [refs/heads/master] - NO JIRA: - Made the SDKGenerator process all found air and flex sdks in the right order by sorting the conversions according to the version information found in the sdks themselves.

Updated Branches:
  refs/heads/master f57d54194 -> 4d387c682


NO JIRA:
- Made the SDKGenerator process all found air and flex sdks in the right order by sorting the conversions according to the version information found in the sdks themselves.


Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/1845ac53
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/1845ac53
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/1845ac53

Branch: refs/heads/master
Commit: 1845ac53b6dcc3e5cf37975b1a283b2550f965bb
Parents: f57d541
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sun Nov 3 15:37:42 2013 +0100
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sun Nov 3 15:37:42 2013 +0100

----------------------------------------------------------------------
 mavenizer/src/main/java/SDKGenerator.java       | 91 +++++++++++---------
 .../src/main/java/common/ConversionPlan.java    | 57 ++++++++++++
 2 files changed, 107 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/1845ac53/mavenizer/src/main/java/SDKGenerator.java
----------------------------------------------------------------------
diff --git a/mavenizer/src/main/java/SDKGenerator.java b/mavenizer/src/main/java/SDKGenerator.java
index 401367c..c69eda6 100644
--- a/mavenizer/src/main/java/SDKGenerator.java
+++ b/mavenizer/src/main/java/SDKGenerator.java
@@ -15,11 +15,10 @@
  * limitations under the License.
  */
 import java.io.*;
-import java.util.ArrayList;
-import java.util.List;
 import javax.xml.parsers.*;
 
 import air.AirCompilerGenerator;
+import common.ConversionPlan;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
@@ -37,7 +36,21 @@ import flex.FlexRuntimeGenerator;
  */
 public class SDKGenerator {
 
-    protected List<String> generatedAirVersions = new ArrayList<String>();
+    protected void buildAirConversionPlan(ConversionPlan plan, File sdkSourceDirectory) {
+        final File sdkDirectories[] = sdkSourceDirectory.listFiles(new FileFilter() {
+            public boolean accept(File pathname) {
+                return pathname.isDirectory();
+            }
+        });
+        if (sdkDirectories != null) {
+            for (final File sdkDirectory : sdkDirectories) {
+                final String sdkVersion = getAirSdkVersion(sdkDirectory);
+                if(sdkVersion != null) {
+                    plan.addVersion(sdkVersion, sdkDirectory, false);
+                }
+            }
+        }
+    }
 
     /**
      * All this little helper does is list up all directories in the given base directory and
@@ -45,34 +58,19 @@ public class SDKGenerator {
      * 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 plan conversion plan for converting the air sdks 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);
+    public void generateAllAir(ConversionPlan plan, File sdkTargetDirectory) throws Exception {
+        for(final String airVersion : plan.getVersionIterator()) {
+            final File airDirectory = plan.getDirectory(airVersion);
 
-                    System.out.println("---------------------------------------------");
+            System.out.println("---------------------------------------------");
+            System.out.println("-- Generating Air SDK version: " + airVersion);
+            System.out.println("---------------------------------------------");
 
-                    generatedAirVersions.add(sdkVersion);
-                }
-            }
+            generateAir(airDirectory, sdkTargetDirectory, airVersion);
         }
     }
 
@@ -87,31 +85,38 @@ public class SDKGenerator {
         new AirRuntimeGenerator().process(sdkSourceDirectory, false, sdkTargetDirectory, sdkVersion, false);
     }
 
-    public void generateAllFlex(File sdkSourceDirectory, File sdkTargetDirectory, boolean useApache) throws Exception {
+    protected void buildFlexConversionPlan(ConversionPlan plan, File sdkSourceDirectory) {
         final File sdkDirectories[] = sdkSourceDirectory.listFiles(new FileFilter() {
             public boolean accept(File pathname) {
                 return pathname.isDirectory();
             }
         });
         if (sdkDirectories != null) {
-            System.out.println("---------------------------------------------");
+            // Build a sorted set of versions as well as maps for the additional information
+            // to allow sorted conversion of the Flex SDKs.
             for (final File sdkDirectory : sdkDirectories) {
-                String sdkVersion = getFlexSdkVersion(sdkDirectory);
-
-                // Apache FDKs (ok ... the only one available) have the version prefix "Apache-"
+                String fdkVersion = getFlexSdkVersion(sdkDirectory);
+                // Apache FDKs 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-");
+                final boolean isApache = fdkVersion.startsWith("Apache-");
                 if (isApache) {
-                    sdkVersion = sdkVersion.substring("Apache-".length());
+                    fdkVersion = fdkVersion.substring("Apache-".length());
                 }
+                plan.addVersion(fdkVersion, sdkDirectory, isApache);
+            }
+        }
+    }
 
-                System.out.println("-- Generating Flex SDK version: " + sdkVersion);
-                System.out.println("---------------------------------------------");
+    public void generateAllFlex(ConversionPlan plan, File sdkTargetDirectory, boolean useApache) throws Exception {
+        for(final String fdkVersion : plan.getVersionIterator()) {
+            final File fdkDirectory = plan.getDirectory(fdkVersion);
+            final boolean isApache = plan.getApacheFlag(fdkVersion);
 
-                generateFlex(sdkDirectory, isApache, sdkTargetDirectory, sdkVersion, useApache);
+            System.out.println("---------------------------------------------");
+            System.out.println("-- Generating Flex SDK version: " + fdkVersion);
+            System.out.println("---------------------------------------------");
 
-                System.out.println("---------------------------------------------");
-            }
+            generateFlex(fdkDirectory, isApache, sdkTargetDirectory, fdkVersion, useApache);
         }
     }
 
@@ -146,11 +151,15 @@ public class SDKGenerator {
         // 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);
+        final ConversionPlan airPlan = new ConversionPlan();
+        generator.buildAirConversionPlan(airPlan, new File(sdkSourceDirectory, "air"));
+        generator.buildAirConversionPlan(airPlan, new File(sdkSourceDirectory, "flex"));
+        generator.generateAllAir(airPlan, sdkTargetDirectory);
 
         // After the air artifacts are generated and
-        generator.generateAllFlex(new File(sdkSourceDirectory, "flex"), sdkTargetDirectory, useApache);
+        final ConversionPlan flexPlan = new ConversionPlan();
+        generator.buildFlexConversionPlan(flexPlan, new File(sdkSourceDirectory, "flex"));
+        generator.generateAllFlex(flexPlan, sdkTargetDirectory, useApache);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/1845ac53/mavenizer/src/main/java/common/ConversionPlan.java
----------------------------------------------------------------------
diff --git a/mavenizer/src/main/java/common/ConversionPlan.java b/mavenizer/src/main/java/common/ConversionPlan.java
new file mode 100644
index 0000000..ec83ecf
--- /dev/null
+++ b/mavenizer/src/main/java/common/ConversionPlan.java
@@ -0,0 +1,57 @@
+package common;
+
+import java.io.File;
+import java.util.*;
+
+/**
+ * Created by cdutz on 01.11.13.
+ */
+public class ConversionPlan {
+
+    private final Set<String> versions;
+    private final Map<String, File> directories;
+    private final Map<String, Boolean> apacheFlags;
+
+    public ConversionPlan() {
+        final Comparator<String> versionComparator = new Comparator<String>() {
+            public int compare(String o1, String o2) {
+                final String[] versionSegments1 = o1.split("\\.");
+                final String[] versionSegments2 = o2.split("\\.");
+                final int length = Math.min(versionSegments1.length, versionSegments2.length);
+                // Compare each of the segments.
+                for(int i = 0; i < length; i++) {
+                    final int result = new Integer(versionSegments1[i]).compareTo(Integer.parseInt(versionSegments2[i]));
+                    if(result != 0) {
+                        return result;
+                    }
+                }
+                // If all segments were equal, the string that has more segments wins.
+                return Integer.compare(versionSegments1.length, versionSegments2.length);
+            }
+        };
+        versions = new TreeSet<String>(versionComparator);
+        directories = new HashMap<String, File>();
+        apacheFlags = new HashMap<String, Boolean>();
+    }
+
+    public void addVersion(String version, File directory, Boolean apacheFlag) {
+        if(!versions.contains(version)) {
+            versions.add(version);
+            directories.put(version, directory);
+            apacheFlags.put(version, apacheFlag);
+        }
+    }
+
+    public Set<String> getVersionIterator() {
+        return versions;
+    }
+
+    public File getDirectory(String version) {
+        return directories.get(version);
+    }
+
+    public Boolean getApacheFlag(String version) {
+        return apacheFlags.get(version);
+    }
+
+}


[2/2] git commit: [flex-utilities] [refs/heads/master] - NO JIRA: - Implemented an alternative Deployer "SDKInVMDeployer" that allows deploying artifacts without installed Maven and with far greater performance, as all deployments are performed in VM wit

Posted by cd...@apache.org.
NO JIRA:
- Implemented an alternative Deployer "SDKInVMDeployer" that allows deploying artifacts without installed Maven and with far greater performance, as all deployments are performed in VM without having to spawn a new VM for every file that should be deployed.


Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/4d387c68
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/4d387c68
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/4d387c68

Branch: refs/heads/master
Commit: 4d387c6824388a2f3da1c7c27bde77cfe7588af8
Parents: 1845ac5
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Sun Nov 3 15:53:10 2013 +0100
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Sun Nov 3 15:53:10 2013 +0100

----------------------------------------------------------------------
 mavenizer/pom.xml                            |  56 +++++
 mavenizer/src/main/java/SDKInVMDeployer.java | 241 ++++++++++++++++++++++
 2 files changed, 297 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4d387c68/mavenizer/pom.xml
----------------------------------------------------------------------
diff --git a/mavenizer/pom.xml b/mavenizer/pom.xml
index 7933d55..3f0213f 100644
--- a/mavenizer/pom.xml
+++ b/mavenizer/pom.xml
@@ -26,6 +26,10 @@
     <artifactId>flex-sdk-converter</artifactId>
     <version>1.0</version>
 
+    <properties>
+        <aetherVersion>0.9.0.M3</aetherVersion>
+    </properties>
+
     <dependencies>
         <dependency>
             <groupId>com.sun.jersey</groupId>
@@ -42,6 +46,58 @@
             <artifactId>commons-compress</artifactId>
             <version>1.4</version>
         </dependency>
+
+        <!-- Needed for Aether Repository Client -->
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-aether-provider</artifactId>
+            <version>3.1.0</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-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-transport-classpath</artifactId>
+            <version>${aetherVersion}</version>
+        </dependency>
     </dependencies>
 
     <developers>

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4d387c68/mavenizer/src/main/java/SDKInVMDeployer.java
----------------------------------------------------------------------
diff --git a/mavenizer/src/main/java/SDKInVMDeployer.java b/mavenizer/src/main/java/SDKInVMDeployer.java
new file mode 100644
index 0000000..d1643ab
--- /dev/null
+++ b/mavenizer/src/main/java/SDKInVMDeployer.java
@@ -0,0 +1,241 @@
+/*
+ * 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 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 SDKInVMDeployer {
+
+    private String directory;
+    private String url;
+    private String username;
+    private String password;
+
+
+    public SDKInVMDeployer(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 SDKInVMDeployer deployer = new SDKInVMDeployer(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();
+        }
+    }
+
+}