directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r674860 - in /directory/daemon/trunk/plugin/src/main: java/org/apache/directory/daemon/installers/ java/org/apache/directory/daemon/installers/archive/ resources/org/apache/directory/daemon/installers/archive/
Date Tue, 08 Jul 2008 15:48:58 GMT
Author: pamarcelot
Date: Tue Jul  8 08:48:58 2008
New Revision: 674860

URL: http://svn.apache.org/viewvc?rev=674860&view=rev
Log:
Fix for DIRSERVER-931 (Provide a zip/tar.gz download for DS).

Added:
    directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/archive/
    directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java
    directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java
    directory/daemon/trunk/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/
    directory/daemon/trunk/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.bat
    directory/daemon/trunk/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh
Modified:
    directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java

Modified: directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java
URL: http://svn.apache.org/viewvc/directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java?rev=674860&r1=674859&r2=674860&view=diff
==============================================================================
--- directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java
(original)
+++ directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java
Tue Jul  8 08:48:58 2008
@@ -28,6 +28,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.apache.directory.daemon.installers.archive.ArchiveInstallerCommand;
+import org.apache.directory.daemon.installers.archive.ArchiveTarget;
 import org.apache.directory.daemon.installers.bin.BinInstallerCommand;
 import org.apache.directory.daemon.installers.bin.BinTarget;
 import org.apache.directory.daemon.installers.deb.DebInstallerCommand;
@@ -135,6 +137,10 @@
      * @parameter
      */
     private BinTarget[] binTargets;
+    /**
+     * @parameter
+     */
+    private ArchiveTarget[] archiveTargets;
 
     /**
      * @parameter 
@@ -295,6 +301,13 @@
                 binCmd = new BinInstallerCommand( this, ( BinTarget ) target );
                 binCmd.execute();
             }
+
+            if ( target instanceof ArchiveTarget )
+            {
+                ArchiveInstallerCommand archiveCmd = null;
+                archiveCmd = new ArchiveInstallerCommand( this, ( ArchiveTarget ) target
);
+                archiveCmd.execute();
+            }
         }
     }
 
@@ -310,6 +323,7 @@
         addAll( allTargets, macOsXPkgTargets );
         addAll( allTargets, solarisPkgTargets );
         addAll( allTargets, binTargets );
+        addAll( allTargets, archiveTargets );
     }
 
 

Added: directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java
URL: http://svn.apache.org/viewvc/directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java?rev=674860&view=auto
==============================================================================
--- directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java
(added)
+++ directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java
Tue Jul  8 08:48:58 2008
@@ -0,0 +1,250 @@
+/*
+ *  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.directory.daemon.installers.archive;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.directory.daemon.installers.MojoCommand;
+import org.apache.directory.daemon.installers.MojoHelperUtils;
+import org.apache.directory.daemon.installers.ServiceInstallersMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.BZip2;
+import org.apache.tools.ant.taskdefs.GZip;
+import org.apache.tools.ant.taskdefs.Tar;
+import org.apache.tools.ant.taskdefs.Zip;
+import org.apache.tools.ant.types.FileSet;
+import org.codehaus.plexus.util.FileUtils;
+
+
+/**
+ * Archive Installer command for any platform.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 434414 $
+ */
+public class ArchiveInstallerCommand extends MojoCommand
+{
+    private final Properties filterProperties = new Properties( System.getProperties() );
+    /** The archive target */
+    private final ArchiveTarget target;
+    /** The Maven logger */
+    private final Log log;
+
+
+    /**
+     * Creates a new instance of ArchiveInstallerCommand.
+     *
+     * @param mymojo
+     *      the Server Installers Mojo
+     * @param target
+     *      the target
+     */
+    public ArchiveInstallerCommand( ServiceInstallersMojo mymojo, ArchiveTarget target )
+    {
+        super( mymojo );
+        this.target = target;
+        this.log = mymojo.getLog();
+        initializeFiltering();
+    }
+
+
+    /**
+     * Performs the following:
+     * <ol>
+     *   <li>Bail if the archive type is unknown</li>
+     *   <li>Creates the Archive Installer for Apache DS</li>
+     * </ol>
+     */
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        // Getting the archive type
+        String archiveType = target.getArchiveType();
+
+        // Checking for a null archive type
+        if ( archiveType == null )
+        {
+            log.warn( "Archive type is null!" );
+            log.warn( "The build will continue, but please check the archive type of this
installer " );
+            log.warn( "target" );
+            return;
+        }
+
+        // Checking for a known archive type
+        if ( !archiveType.equalsIgnoreCase( "zip" ) && !archiveType.equalsIgnoreCase(
"tar" )
+            && !archiveType.equalsIgnoreCase( "tar.gz" ) && !archiveType.equalsIgnoreCase(
"tar.bz2" ) )
+        {
+            log.warn( "Archive type is unknwown (" + archiveType + ")!" );
+            log.warn( "The build will continue, but please check the archive type of this
installer " );
+            log.warn( "target" );
+            return;
+        }
+
+        File baseDirectory = target.getLayout().getBaseDirectory();
+        File imagesDirectory = baseDirectory.getParentFile();
+
+        log.info( "Creating Archive Installer..." );
+
+        // Creating the archive directory
+        File archiveDirectory = new File( imagesDirectory, target.getId() );
+
+        log.info( "Copying Archive Installer files" );
+
+        // Copying the resources files
+        try
+        {
+            // Copying the apacheds.bat file
+            MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream(
"apacheds.bat" ),
+                new File( archiveDirectory, "apacheds.bat" ), false );
+
+            // Copying the apacheds.sh file
+            MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream(
"apacheds.sh" ),
+                new File( archiveDirectory, "apacheds.sh" ), false );
+        }
+        catch ( IOException e )
+        {
+            log.error( e.getMessage() );
+            throw new MojoFailureException( "Failed to copy Archive Installer resources files."
);
+        }
+
+        // Generating the Bin
+        log.info( "Generating Archive Installer" );
+        
+        Project project = new Project();
+        project.setBaseDir( archiveDirectory );
+        
+        // ZIP Archive
+        if ( archiveType.equalsIgnoreCase( "zip" ) )
+        {   
+            Zip zipTask = new Zip();
+            zipTask.setProject( project );
+            zipTask.setDestFile( new File( imagesDirectory, target.getFinalName() ) );
+            zipTask.setBasedir( archiveDirectory );
+            zipTask.execute();
+        }
+        // TAR Archive
+        else if ( archiveType.equalsIgnoreCase( "tar" ) )
+        {
+            Tar tarTask = new Tar();
+            tarTask.setProject( project );
+            tarTask.setDestFile( new File( imagesDirectory, target.getFinalName() ) );
+            tarTask.setBasedir( archiveDirectory );
+            tarTask.execute();
+        }
+        // TAR.GZ Archive
+        else if ( archiveType.equalsIgnoreCase( "tar.gz" ) )
+        {
+            File tarFile = new File( imagesDirectory, target.getId() + ".tar" );
+
+            Tar tarTask = new Tar();
+            tarTask.setProject( project );
+            tarTask.setDestFile( tarFile );
+            tarTask.setBasedir( archiveDirectory );
+            tarTask.execute();
+
+            GZip gzipTask = new GZip();
+            gzipTask.setProject( project );
+            gzipTask.setDestfile( new File( imagesDirectory, target.getFinalName() ) );
+            gzipTask.setSrc( tarFile );
+            gzipTask.execute();
+
+            tarFile.delete();
+        }
+        // TAR.BZ2 Archive
+        else if ( archiveType.equalsIgnoreCase( "tar.bz2" ) )
+        {
+            File tarFile = new File( imagesDirectory, target.getId() + ".tar" );
+
+            Tar tarTask = new Tar();
+            tarTask.setProject( project );
+            tarTask.setDestFile( tarFile );
+            tarTask.setBasedir( archiveDirectory );
+            tarTask.execute();
+
+            BZip2 bzip2Task = new BZip2();
+            bzip2Task.setProject( project );
+            bzip2Task.setDestfile( new File( imagesDirectory, target.getFinalName() ) );
+            bzip2Task.setSrc( tarFile );
+            bzip2Task.execute();
+
+            tarFile.delete();
+        }
+
+        log.info( "Archive Installer generated at " + new File( imagesDirectory, target.getFinalName()
) );
+    }
+
+
+    /**
+     * Recursively copy files from the given source to the given destination.
+     *
+     * @param src
+     *      the source
+     * @param dest
+     *      the destination
+     * @throws IOException
+     *      If an error occurs when copying a file
+     */
+    public void copyFiles( File src, File dest ) throws IOException
+    {
+        if ( src.isDirectory() )
+        {
+            dest.mkdirs();
+
+            for ( File file : src.listFiles() )
+            {
+                copyFiles( file, new File( dest, file.getName() ) );
+            }
+        }
+        else
+        {
+            FileUtils.copyFile( src, dest );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.daemon.installers.MojoCommand#getFilterProperties()
+     */
+    public Properties getFilterProperties()
+    {
+        return filterProperties;
+    }
+
+
+    private void initializeFiltering()
+    {
+        filterProperties.putAll( mymojo.getProject().getProperties() );
+        filterProperties.put( "app", target.getApplication().getName() );
+        String version = target.getApplication().getVersion();
+        if ( version != null )
+        {
+            filterProperties.put( "app.version", version );
+        }
+        else
+        {
+            filterProperties.put( "app.version", "1.0" );
+        }
+    }
+}

Added: directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java
URL: http://svn.apache.org/viewvc/directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java?rev=674860&view=auto
==============================================================================
--- directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java
(added)
+++ directory/daemon/trunk/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java
Tue Jul  8 08:48:58 2008
@@ -0,0 +1,70 @@
+/*
+ *  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.directory.daemon.installers.archive;
+
+
+import org.apache.directory.daemon.installers.Target;
+
+
+/**
+ * An archive installer for any platform.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ArchiveTarget extends Target
+{
+    /** The archive type */
+    /**
+     * The archive type.
+     * <p>
+     * Possible types are:
+     * <ul>
+     *   <li>zip (default)</li>
+     *   <li>tar</li>
+     *   <li>tar.gz</li>
+     *   <li>tar.bz2</li>
+     * </ul>
+     */
+    private String archiveType = "zip";
+
+
+    /**
+     * Gets the archive type.
+     *
+     * @return
+     *      the archive type
+     */
+    public String getArchiveType()
+    {
+        return archiveType;
+    }
+
+
+    /**
+     * Sets the archive type.
+     *
+     * @param archiveType
+     */
+    public void setArchiveType( String archiveType )
+    {
+        this.archiveType = archiveType;
+    }
+}
\ No newline at end of file

Added: directory/daemon/trunk/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.bat
URL: http://svn.apache.org/viewvc/directory/daemon/trunk/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.bat?rev=674860&view=auto
==============================================================================
--- directory/daemon/trunk/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.bat
(added)
+++ directory/daemon/trunk/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.bat
Tue Jul  8 08:48:58 2008
@@ -0,0 +1,2 @@
+@echo off
+java -Dlog4j.configuration="file:conf/log4j.properties" -cp lib\antlr-2.7.7.jar;lib\apacheds-bootstrap-extract-1.5.3-SNAPSHOT.jar;lib\apacheds-bootstrap-partition-1.5.3-SNAPSHOT.jar;lib\apacheds-btree-base-1.5.3-SNAPSHOT.jar;lib\apacheds-core-1.5.3-SNAPSHOT.jar;lib\apacheds-core-constants-1.5.3-SNAPSHOT.jar;lib\apacheds-core-entry-1.5.3-SNAPSHOT.jar;lib\apacheds-core-shared-1.5.3-SNAPSHOT.jar;lib\apacheds-jdbm-1.5.3-SNAPSHOT.jar;lib\apacheds-jdbm-store-1.5.3-SNAPSHOT.jar;lib\apacheds-kerberos-shared-1.5.3-SNAPSHOT.jar;lib\apacheds-noarch-installer-1.5.3-SNAPSHOT.jar;lib\apacheds-protocol-changepw-1.5.3-SNAPSHOT.jar;lib\apacheds-protocol-dhcp-1.5.3-SNAPSHOT.jar;lib\apacheds-protocol-dns-1.5.3-SNAPSHOT.jar;lib\apacheds-protocol-kerberos-1.5.3-SNAPSHOT.jar;lib\apacheds-protocol-ldap-1.5.3-SNAPSHOT.jar;lib\apacheds-protocol-ntp-1.5.3-SNAPSHOT.jar;lib\apacheds-protocol-shared-1.5.3-SNAPSHOT.jar;lib\apacheds-schema-bootstrap-1.5.3-SNAPSHOT.jar;lib\apacheds-schema-extras-1.5.3-SNAP
 SHOT.jar;lib\apacheds-schema-registries-1.5.3-SNAPSHOT.jar;lib\apacheds-server-jndi-1.5.3-SNAPSHOT.jar;lib\apacheds-server-xml-1.5.3-SNAPSHOT.jar;lib\apacheds-utils-1.5.3-SNAPSHOT.jar;lib\apacheds-xbean-spring-1.5.3-SNAPSHOT.jar;lib\bootstrapper.jar;lib\commons-cli-1.1.jar;lib\commons-collections-3.2.jar;lib\commons-daemon-1.0.1.jar;lib\commons-lang-2.3.jar;lib\jcl104-over-slf4j-1.4.3.jar;lib\log4j-1.2.14.jar;lib\mina-core-1.1.6.jar;lib\mina-filter-ssl-1.1.6.jar;lib\shared-asn1-0.9.11-SNAPSHOT.jar;lib\shared-asn1-codec-0.9.11-SNAPSHOT.jar;lib\shared-bouncycastle-reduced-0.9.11-SNAPSHOT.jar;lib\shared-ldap-0.9.11-SNAPSHOT.jar;lib\shared-ldap-constants-0.9.11-SNAPSHOT.jar;lib\slf4j-api-1.4.3.jar;lib\slf4j-log4j12-1.4.3.jar;lib\spring-beans-2.0.6.jar;lib\spring-context-2.0.6.jar;lib\spring-core-2.0.6.jar;lib\xbean-spring-3.3.jar
org.apache.directory.server.UberjarMain conf\server.xml
\ No newline at end of file

Added: directory/daemon/trunk/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh
URL: http://svn.apache.org/viewvc/directory/daemon/trunk/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh?rev=674860&view=auto
==============================================================================
--- directory/daemon/trunk/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh
(added)
+++ directory/daemon/trunk/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh
Tue Jul  8 08:48:58 2008
@@ -0,0 +1,2 @@
+#!/bin/sh
+java -Dlog4j.configuration=file:conf/log4j.properties -cp lib/antlr-2.7.7.jar:lib/apacheds-bootstrap-extract-1.5.3-SNAPSHOT.jar:lib/apacheds-bootstrap-partition-1.5.3-SNAPSHOT.jar:lib/apacheds-btree-base-1.5.3-SNAPSHOT.jar:lib/apacheds-core-1.5.3-SNAPSHOT.jar:lib/apacheds-core-constants-1.5.3-SNAPSHOT.jar:lib/apacheds-core-entry-1.5.3-SNAPSHOT.jar:lib/apacheds-core-shared-1.5.3-SNAPSHOT.jar:lib/apacheds-jdbm-1.5.3-SNAPSHOT.jar:lib/apacheds-jdbm-store-1.5.3-SNAPSHOT.jar:lib/apacheds-kerberos-shared-1.5.3-SNAPSHOT.jar:lib/apacheds-noarch-installer-1.5.3-SNAPSHOT.jar:lib/apacheds-protocol-changepw-1.5.3-SNAPSHOT.jar:lib/apacheds-protocol-dhcp-1.5.3-SNAPSHOT.jar:lib/apacheds-protocol-dns-1.5.3-SNAPSHOT.jar:lib/apacheds-protocol-kerberos-1.5.3-SNAPSHOT.jar:lib/apacheds-protocol-ldap-1.5.3-SNAPSHOT.jar:lib/apacheds-protocol-ntp-1.5.3-SNAPSHOT.jar:lib/apacheds-protocol-shared-1.5.3-SNAPSHOT.jar:lib/apacheds-schema-bootstrap-1.5.3-SNAPSHOT.jar:lib/apacheds-schema-extras-1.5.3-SNAPSH
 OT.jar:lib/apacheds-schema-registries-1.5.3-SNAPSHOT.jar:lib/apacheds-server-jndi-1.5.3-SNAPSHOT.jar:lib/apacheds-server-xml-1.5.3-SNAPSHOT.jar:lib/apacheds-utils-1.5.3-SNAPSHOT.jar:lib/apacheds-xbean-spring-1.5.3-SNAPSHOT.jar:lib/bootstrapper.jar:lib/commons-cli-1.1.jar:lib/commons-collections-3.2.jar:lib/commons-daemon-1.0.1.jar:lib/commons-lang-2.3.jar:lib/jcl104-over-slf4j-1.4.3.jar:lib/log4j-1.2.14.jar:lib/mina-core-1.1.6.jar:lib/mina-filter-ssl-1.1.6.jar:lib/shared-asn1-0.9.11-SNAPSHOT.jar:lib/shared-asn1-codec-0.9.11-SNAPSHOT.jar:lib/shared-bouncycastle-reduced-0.9.11-SNAPSHOT.jar:lib/shared-ldap-0.9.11-SNAPSHOT.jar:lib/shared-ldap-constants-0.9.11-SNAPSHOT.jar:lib/slf4j-api-1.4.3.jar:lib/slf4j-log4j12-1.4.3.jar:lib/spring-beans-2.0.6.jar:lib/spring-context-2.0.6.jar:lib/spring-core-2.0.6.jar:lib/xbean-spring-3.3.jar
org.apache.directory.server.UberjarMain conf/server.xml
\ No newline at end of file



Mime
View raw message