From commits-return-18799-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Tue Jul 08 15:49:57 2008 Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 68628 invoked from network); 8 Jul 2008 15:49:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Jul 2008 15:49:56 -0000 Received: (qmail 68432 invoked by uid 500); 8 Jul 2008 15:49:57 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 68385 invoked by uid 500); 8 Jul 2008 15:49:57 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 68338 invoked by uid 99); 8 Jul 2008 15:49:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jul 2008 08:49:57 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jul 2008 15:49:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 60F7E2388A2A; Tue, 8 Jul 2008 08:49:26 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r674862 - in /directory/daemon/branches/bigbang/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:49:26 -0000 To: commits@directory.apache.org From: pamarcelot@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080708154926.60F7E2388A2A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pamarcelot Date: Tue Jul 8 08:49:25 2008 New Revision: 674862 URL: http://svn.apache.org/viewvc?rev=674862&view=rev Log: Fix for DIRSERVER-931 (Provide a zip/tar.gz download for DS). Added: directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/ directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.bat directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh Modified: directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java Modified: directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java?rev=674862&r1=674861&r2=674862&view=diff ============================================================================== --- directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java (original) +++ directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java Tue Jul 8 08:49:25 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/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java?rev=674862&view=auto ============================================================================== --- directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java (added) +++ directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java Tue Jul 8 08:49:25 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 Apache Directory Project + * @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: + *
    + *
  1. Bail if the archive type is unknown
  2. + *
  3. Creates the Archive Installer for Apache DS
  4. + *
+ */ + 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/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java?rev=674862&view=auto ============================================================================== --- directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java (added) +++ directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java Tue Jul 8 08:49:25 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 Apache Directory Project + * @version $Rev$, $Date$ + */ +public class ArchiveTarget extends Target +{ + /** The archive type */ + /** + * The archive type. + *

+ * Possible types are: + *

    + *
  • zip (default)
  • + *
  • tar
  • + *
  • tar.gz
  • + *
  • tar.bz2
  • + *
+ */ + 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/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.bat URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.bat?rev=674862&view=auto ============================================================================== --- directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.bat (added) +++ directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.bat Tue Jul 8 08:49:25 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/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh?rev=674862&view=auto ============================================================================== --- directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh (added) +++ directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh Tue Jul 8 08:49:25 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