incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erikdebr...@apache.org
Subject svn commit: r1407430 - in /incubator/flex/utilities/trunk/mavenizer: README.txt pom.xml src/main/java/SDKDeployer.java
Date Fri, 09 Nov 2012 12:12:31 GMT
Author: erikdebruin
Date: Fri Nov  9 12:12:30 2012
New Revision: 1407430

URL: http://svn.apache.org/viewvc?rev=1407430&view=rev
Log:
Added Frederic Thomas' contribution of the SDKDeployer to the Mavenizer utility.

Added:
    incubator/flex/utilities/trunk/mavenizer/src/main/java/SDKDeployer.java   (with props)
Modified:
    incubator/flex/utilities/trunk/mavenizer/README.txt
    incubator/flex/utilities/trunk/mavenizer/pom.xml

Modified: incubator/flex/utilities/trunk/mavenizer/README.txt
URL: http://svn.apache.org/viewvc/incubator/flex/utilities/trunk/mavenizer/README.txt?rev=1407430&r1=1407429&r2=1407430&view=diff
==============================================================================
--- incubator/flex/utilities/trunk/mavenizer/README.txt (original)
+++ incubator/flex/utilities/trunk/mavenizer/README.txt Fri Nov  9 12:12:30 2012
@@ -113,3 +113,17 @@ Flex SDKs (From Adobe):
 (Unfortunately the page seems messed-up, but you can get the URLs from there)
 http://sourceforge.net/adobe/flexsdk/wiki/downloads/
 
+/////////////////////////////////////////////////////////////////////////////////////////
+Some information (HOWTO) to go with the SDKDeployer  
+/////////////////////////////////////////////////////////////////////////////////////////
+
+The SDKDeployer 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-deployer-1.0.jar SDKDeployer "directory" "repositoryId" "url" "mvn".
+
+The SDKDeployer 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.
+    4- mvn: The path to the mvn.bat / mvn.sh.

Modified: incubator/flex/utilities/trunk/mavenizer/pom.xml
URL: http://svn.apache.org/viewvc/incubator/flex/utilities/trunk/mavenizer/pom.xml?rev=1407430&r1=1407429&r2=1407430&view=diff
==============================================================================
--- incubator/flex/utilities/trunk/mavenizer/pom.xml (original)
+++ incubator/flex/utilities/trunk/mavenizer/pom.xml Fri Nov  9 12:12:30 2012
@@ -26,4 +26,15 @@
         </dependency>
     </dependencies>
 
+    <developers>
+        <developer>
+            <id>cdutz</id>
+            <name>Christofer Dutz</name>
+        </developer>
+        <developer>
+            <id>fthomas</id>
+            <name>Frederic Thomas</name>
+        </developer>
+    </developers>
+
 </project>
\ No newline at end of file

Added: incubator/flex/utilities/trunk/mavenizer/src/main/java/SDKDeployer.java
URL: http://svn.apache.org/viewvc/incubator/flex/utilities/trunk/mavenizer/src/main/java/SDKDeployer.java?rev=1407430&view=auto
==============================================================================
--- incubator/flex/utilities/trunk/mavenizer/src/main/java/SDKDeployer.java (added)
+++ incubator/flex/utilities/trunk/mavenizer/src/main/java/SDKDeployer.java Fri Nov  9 12:12:30
2012
@@ -0,0 +1,152 @@
+import java.io.*;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: fthomas
+ * Date: 11.08.12
+ * Time: 18:17
+ */
+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) {
+            System.out.println("\nUsage: java -cp flex-sdk-deployer-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.");
+            return;
+        }
+
+        SDKDeployer deployer = new SDKDeployer(args);
+        deployer.start();
+    }
+
+    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) {
+            final File artifacts[] = new File(pom.getParent()).listFiles(new ArtifactFilter());
+            final String DEPLOY = mvn + " deploy:deploy-file -DrepositoryId=" + repositoryId
+ " -Durl=" + url;
+
+            String packaging;
+            String classifier = null;
+
+            String mavenDeploy = DEPLOY;
+
+            if (artifacts != null && artifacts.length > 0) {
+                for (File artifact : artifacts) {
+                    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*/}
+                    ;
+
+                    mavenDeploy = DEPLOY;
+                    mavenDeploy += " -Dfile=\"" + artifact.getAbsolutePath() + "\"";
+                    mavenDeploy += " -DpomFile=\"" + pom.getAbsolutePath() + "\"";
+                    if (classifier != null && classifier.length() > 0) {
+                        mavenDeploy += " -Dclassifier=\"" + classifier + "\"";
+                    }
+                    mavenDeploy += " -Dpackaging=\"" + packaging + "\"";
+                    exec(mavenDeploy);
+                }
+            } else {
+                mavenDeploy += " -Dfile=\"" + pom.getAbsolutePath() + "\"";
+                mavenDeploy += " -DpomFile=\"" + pom.getAbsolutePath() + "\"";
+                exec(mavenDeploy);
+            }
+        }
+    }
+
+    private void exec(String exec) throws InterruptedException, IOException {
+        System.out.println(exec);
+        Process p = Runtime.getRuntime().exec(exec);
+        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);
+        }
+        bri.close();
+        while ((line = bre.readLine()) != null) {
+            System.out.println(line);
+        }
+        bre.close();
+        p.waitFor();
+        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");
+        }
+    }
+}

Propchange: incubator/flex/utilities/trunk/mavenizer/src/main/java/SDKDeployer.java
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message