Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 88DADC2F7 for ; Mon, 5 Jan 2015 11:56:20 +0000 (UTC) Received: (qmail 92365 invoked by uid 500); 5 Jan 2015 11:56:21 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 92311 invoked by uid 500); 5 Jan 2015 11:56:21 -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 92301 invoked by uid 99); 5 Jan 2015 11:56:21 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jan 2015 11:56:21 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id BD575AC003F; Mon, 5 Jan 2015 11:56:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1649508 [1/2] - in /directory/apacheds/trunk/installers-maven-plugin/src/main: java/org/apache/directory/server/installers/ java/org/apache/directory/server/installers/archive/ java/org/apache/directory/server/installers/bin/ java/org/apac... Date: Mon, 05 Jan 2015 11:56:18 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150105115619.BD575AC003F@hades.apache.org> Author: elecharny Date: Mon Jan 5 11:56:17 2015 New Revision: 1649508 URL: http://svn.apache.org/r1649508 Log: Applied the changes made in the installer maven plugin Added: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/LinuxInstallerCommand.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveType.java Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/AbstractMojoCommand.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/GenerateMojo.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/MojoHelperUtils.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/Target.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveInstallerCommand.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveTarget.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/bin/BinInstallerCommand.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/bin/BinTarget.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/deb/DebInstallerCommand.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/deb/DebTarget.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/macosxpkg/MacOsXPkgInstallerCommand.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/nsis/NsisInstallerCommand.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/rpm/RpmInstallerCommand.java directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/rpm/RpmTarget.java directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/apacheds directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.sh directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/install.sh directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/nsis/installer.nsi directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/rpm/apacheds.spec Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/AbstractMojoCommand.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/AbstractMojoCommand.java?rev=1649508&r1=1649507&r2=1649508&view=diff ============================================================================== --- directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/AbstractMojoCommand.java (original) +++ directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/AbstractMojoCommand.java Mon Jan 5 11:56:17 2015 @@ -32,7 +32,7 @@ import org.apache.maven.plugin.logging.L /** - * A Mojo command pattern interface. + * A Mojo command pattern abstract class. * * @author Apache Directory Project */ @@ -50,14 +50,65 @@ public abstract class AbstractMojoComman /** The logger */ protected Log log; + /** The log4j.properties file name */ + protected static final String LOG4J_PROPERTIES_FILE = "log4j.properties"; + + /** The config.ldif file */ + protected static final String CONFIG_LDIF_FILE = "config.ldif"; + + /** The wrapper-instance.conf file */ + protected static final String WRAPPER_INSTANCE_CONF_FILE = "wrapper-instance.conf"; + + /** The 'default' name */ + protected static final String DEFAULT = "default"; + + /** The instances directory */ + protected static final String INSTANCES = "instances"; + + /** The instances default directory */ + protected static final String INSTANCE_DEFAULT_DIR = INSTANCES + "/" + DEFAULT; + + /** The 'apacheds' name */ + protected static final String APACHEDS = "apacheds"; + + /** The apacheds- prefix */ + protected static final String APACHEDS_DASH = APACHEDS + "-"; + + /** The chmod command */ + protected static final String CHMOD = "chmod"; + + /** The rights for a command */ + protected static final String RWX_RX_RX = "755"; + + /** The rights for a user command */ + protected static final String RWX_R__R_ = "744"; + + /** The os.name property key */ + protected static final String OS_NAME = "os.name"; + + /** The local path where the installers are created */ + protected static final String INSTALLERS_PATH = "/org/apache/directory/server/installers/"; + + /** The commented wrapper java command */ + protected static final String WRAPPER_JAVA_COMMAND = "# wrapper.java.command="; + + /** The property keys we are using */ + protected static final String ARCH_PROP = "arch"; + protected static final String INSTALLATION_DIRECTORY_PROP = "installation.directory"; + protected static final String INSTANCES_DIRECTORY_PROP = "instances.directory"; + protected static final String DOUBLE_QUOTE_PROP = "double.quote"; + protected static final String USER_PROP = "user"; + protected static final String GROUP_PROP = "group"; + protected static final String WRAPPER_JAVA_COMMAND_PROP = "wrapper.java.command"; + protected static final String FINAL_NAME_PROP = "finalName"; + protected static final String VERSION_PROP = "version"; + /** * Creates a new instance of AbstractMojoCommand. * - * @param mojo - * the associated mojo - * @param target - * the associated target + * @param mojo the associated mojo + * @param target the associated target */ public AbstractMojoCommand( GenerateMojo mojo, T target ) { @@ -66,7 +117,16 @@ public abstract class AbstractMojoComman log = mojo.getLog(); - initializeFilterProperties(); + /* + this.initializeFilterProperties(); + + Properties properties = mojo.getProject().getProperties(); + + for ( Object key : properties.keySet() ) + { + log.info( "Using property [" + key + ", " + properties.getProperty( ( String ) key ) + "]" ); + } + */ } @@ -82,8 +142,7 @@ public abstract class AbstractMojoComman /** * Gets the filter properties. * - * @return - * the filter properties + * @return the filter properties */ public Properties getFilterProperties() { @@ -103,8 +162,7 @@ public abstract class AbstractMojoComman /** * Gets the installation directory file. * - * @return - * the installation directory file + * @return the installation directory file */ public abstract File getInstallationDirectory(); @@ -112,8 +170,7 @@ public abstract class AbstractMojoComman /** * Get the instance directory file. * - * @return - * the instance directory file + * @return the instance directory file */ public abstract File getInstanceDirectory(); @@ -121,8 +178,7 @@ public abstract class AbstractMojoComman /** * Gets the directory associated with the target. * - * @return - * the directory associated with the target + * @return the directory associated with the target */ protected File getTargetDirectory() { @@ -154,7 +210,10 @@ public abstract class AbstractMojoComman */ public void createLayouts( boolean includeWrapperDependencies ) throws MojoFailureException, IOException { + log.info( "Creating the installation layout" ); createInstallationLayout( includeWrapperDependencies ); + + log.info( "Creating the instance layout" ); createInstanceLayout(); } @@ -187,42 +246,65 @@ public abstract class AbstractMojoComman { // Getting the installation layout and creating directories InstallationLayout installationLayout = getInstallationLayout(); + + /* + log.info( "Create installation layout directories : " ); + + for ( File file : installationLayout.getRequiredDirectories() ) + { + log.info( " File " + file.getAbsolutePath() ); + } + + log.info( "Filter properties : " ); + + Properties properties = filterProperties; + + for ( Object key : properties.keySet() ) + { + log.info( " property : [ " + key + ", '" + properties.get( ( String ) key ) + "']" ); + } + */ + + // Create the installation layout directories installationLayout.mkdirs(); // Copying dependencies artifacts to the lib folder of the installation layout MojoHelperUtils.copyDependencies( mojo, installationLayout, includeWrapperDependencies ); // Copying the LICENSE and NOTICE files - MojoHelperUtils.copyBinaryFile( - getClass().getResourceAsStream( "/org/apache/directory/server/installers/LICENSE" ), + MojoHelperUtils.copyBinaryFile( mojo, INSTALLERS_PATH + "LICENSE", + getClass().getResourceAsStream( INSTALLERS_PATH + "LICENSE" ), new File( installationLayout.getInstallationDirectory(), "LICENSE" ) ); - MojoHelperUtils.copyBinaryFile( - getClass().getResourceAsStream( "/org/apache/directory/server/installers/NOTICE" ), - new File( installationLayout.getInstallationDirectory(), - "NOTICE" ) ); + MojoHelperUtils.copyBinaryFile( mojo, INSTALLERS_PATH + "NOTICE", + getClass().getResourceAsStream( INSTALLERS_PATH + "NOTICE" ), + new File( installationLayout.getInstallationDirectory(), "NOTICE" ) ); // Copying the 'apacheds' shell script (only for Linux, Solaris or Mac OS X) if ( target.isOsNameLinux() || target.isOsNameSolaris() || target.isOsNameMacOSX() ) { - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, - getClass().getResourceAsStream( "/org/apache/directory/server/installers/apacheds" ), - new File( installationLayout.getBinDirectory(), "apacheds" ), true ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, INSTALLERS_PATH + APACHEDS, + getClass().getResourceAsStream( INSTALLERS_PATH + APACHEDS ), + new File( installationLayout.getBinDirectory(), APACHEDS ), true ); MojoHelperUtils.exec( new String[] - { "chmod", "755", "apacheds" }, installationLayout.getBinDirectory(), false ); + { CHMOD, RWX_RX_RX, APACHEDS }, installationLayout.getBinDirectory(), false ); } // Copying the wrappers files (native wrapper executable and library [.jnilib, .so, .dll]) - copyWrapperFiles(); + copyWrapperFiles( mojo ); // Copying the wrapper configuration file MojoHelperUtils.copyAsciiFile( mojo, filterProperties, - getClass() - .getResourceAsStream( "/org/apache/directory/server/installers/wrapper-installation.conf" ), + INSTALLERS_PATH + "wrapper-installation.conf", + getClass().getResourceAsStream( INSTALLERS_PATH + "wrapper-installation.conf" ), new File( installationLayout.getConfDirectory(), "wrapper.conf" ), true ); + } + abstract public void copyWrapperFiles( GenerateMojo mojo ) throws MojoFailureException; + + /** * Creates the instance layout. * @@ -232,30 +314,48 @@ public abstract class AbstractMojoComman { // Getting the instance layout and creating directories InstanceLayout instanceLayout = getInstanceLayout(); + + /* + log.info( "Create instance layout directories : " ); + + for ( File file : instanceLayout.getRequiredDirectories() ) + { + log.info( " File " + file.getAbsolutePath() ); + } + + log.info( "Filter properties : " ); + + Properties properties = filterProperties; + + for ( Object key : properties.keySet() ) + { + log.info( " property : [ " + key + "," + properties.get( ( String ) key ) + "]" ); + } + */ + instanceLayout.mkdirs(); // Copying the log4j.properties file - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, - getClass().getResourceAsStream( "/org/apache/directory/server/installers/log4j.properties" ), - new File( instanceLayout.getConfDirectory(), "log4j.properties" ), true ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, INSTALLERS_PATH + LOG4J_PROPERTIES_FILE, + getClass().getResourceAsStream( INSTALLERS_PATH + LOG4J_PROPERTIES_FILE ), + new File( instanceLayout.getConfDirectory(), LOG4J_PROPERTIES_FILE ), true ); // Copying the wrapper configuration file - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, - getClass().getResourceAsStream( "/org/apache/directory/server/installers/wrapper-instance.conf" ), - new File( instanceLayout.getConfDirectory(), "wrapper.conf" ), true ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, INSTALLERS_PATH + WRAPPER_INSTANCE_CONF_FILE, + getClass().getResourceAsStream( INSTALLERS_PATH + WRAPPER_INSTANCE_CONF_FILE ), + new File( instanceLayout.getConfDirectory(), WRAPPER_INSTANCE_CONF_FILE ), true ); // Copying ApacheDS LDIF configuration file - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, - getClass().getResourceAsStream( "/org/apache/directory/server/installers/config.ldif" ), - new File( instanceLayout.getConfDirectory(), "config.ldif" ), false ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, INSTALLERS_PATH + CONFIG_LDIF_FILE, + getClass().getResourceAsStream( INSTALLERS_PATH + CONFIG_LDIF_FILE ), + new File( instanceLayout.getConfDirectory(), CONFIG_LDIF_FILE ), false ); } /** * Gets the installation layout. * - * @return - * the installation layout + * @return the installation layout */ protected InstallationLayout getInstallationLayout() { @@ -266,115 +366,12 @@ public abstract class AbstractMojoComman /** * Gets the instance layout. * - * @return - * the instance layout + * @return the instance layout */ protected InstanceLayout getInstanceLayout() { - return new InstanceLayout( getInstanceDirectory() ); - } + File instanceDirectory = getInstanceDirectory(); - - /** - * Copies wrapper files to the installation layout. - * - * @param installationLayout - * the installation layout - * @throws MojoFailureException - */ - private void copyWrapperFiles() - throws MojoFailureException - { - try - { - // Mac OS X x86 - if ( target.isOsNameMacOSX() && target.isOsArchx86() ) - { - MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/bin/wrapper-macosx-universal-32" ), new File( - getInstallationLayout().getBinDirectory(), "wrapper" ) ); - MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/lib/libwrapper-macosx-universal-32.jnilib" ), - new File( getInstallationLayout().getLibDirectory(), - "libwrapper.jnilib" ) ); - } - - // Mac OS X x86_64 - if ( target.isOsNameMacOSX() && target.isOsArchX86_64() ) - { - MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/bin/wrapper-macosx-universal-64" ), new File( - getInstallationLayout().getBinDirectory(), "wrapper" ) ); - MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/lib/libwrapper-macosx-universal-64.jnilib" ), - new File( getInstallationLayout().getLibDirectory(), - "libwrapper.jnilib" ) ); - } - - // Linux i386 & x86 - if ( target.isOsNameLinux() && ( target.isOsArchI386() || target.isOsArchx86() ) ) - { - MojoHelperUtils.copyBinaryFile( - getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/bin/wrapper-linux-x86-32" ), - new File( getInstallationLayout().getBinDirectory(), "wrapper" ) ); - MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/lib/libwrapper-linux-x86-32.so" ), - new File( getInstallationLayout().getLibDirectory(), "libwrapper.so" ) ); - } - - // Linux x86_64 & amd64 - if ( target.isOsNameLinux() && ( target.isOsArchX86_64() || target.isOsArchAmd64() ) ) - { - MojoHelperUtils.copyBinaryFile( - getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/bin/wrapper-linux-x86-64" ), - new File( getInstallationLayout().getBinDirectory(), "wrapper" ) ); - MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/lib/libwrapper-linux-x86-64.so" ), - new File( getInstallationLayout().getLibDirectory(), "libwrapper.so" ) ); - } - - // Solaris x86 - if ( target.isOsNameSolaris() && target.isOsArchx86() ) - { - MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/bin/wrapper-solaris-x86-32" ), - new File( getInstallationLayout().getBinDirectory(), "wrapper" ) ); - MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/lib/libwrapper-solaris-x86-32.so" ), new File( - getInstallationLayout().getLibDirectory(), - "libwrapper.so" ) ); - } - - // Solaris Sparc - if ( target.isOsNameSolaris() && target.isOsArchSparc() ) - { - MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/bin/wrapper-solaris-sparc-32" ), - new File( getInstallationLayout().getBinDirectory(), "wrapper" ) ); - MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/lib/libwrapper-solaris-sparc-32.so" ), - new File( - getInstallationLayout().getLibDirectory(), - "libwrapper.so" ) ); - } - - // Windows - if ( target.isOsNameWindows() ) - { - MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/bin/wrapper-windows-x86-32.exe" ), - new File( getInstallationLayout().getBinDirectory(), "wrapper.exe" ) ); - MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( - "/org/apache/directory/server/installers/wrapper/lib/wrapper-windows-x86-32.dll" ), new File( - getInstallationLayout().getLibDirectory(), - "wrapper.dll" ) ); - } - } - catch ( IOException e ) - { - throw new MojoFailureException( "Failed to copy Tanuki binary files to lib and bin directories" ); - } + return new InstanceLayout( instanceDirectory ); } } Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/GenerateMojo.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/GenerateMojo.java?rev=1649508&r1=1649507&r2=1649508&view=diff ============================================================================== --- directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/GenerateMojo.java (original) +++ directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/GenerateMojo.java Mon Jan 5 11:56:17 2015 @@ -119,7 +119,7 @@ public class GenerateMojo extends Abstra * * @parameter */ - private Set excludes; + private Set excludes; /** * The dpkg utility executable. @@ -173,12 +173,14 @@ public class GenerateMojo extends Abstra if ( allTargets.isEmpty() ) { getLog().info( "No installers to generate." ); + return; } getLog().info( "-------------------------------------------------------" ); // Creating the output directory + getLog().info( "Creating the putput directory : " + outputDirectory.getAbsolutePath() ); FileUtils.mkdir( outputDirectory.getAbsolutePath() ); // Generating installers for all targets @@ -238,26 +240,37 @@ public class GenerateMojo extends Abstra /** - * Collects all targets. + * Collects all targets. A target is a plugin configuration element + * where we declare a tuple with the target's ID, the target + * name, architecture, os name and archive typelike in : + *
+     * <nsisTargets>
+     *   <nsisTarget>
+     *     <id>apacheds-win32</id>
+     *     <finalName>apacheds-${project.version}.exe</finalName>
+     *   </nsisTarget>
+     * </nsisTargets>
+     * 
+ * We have targets for windows, RPM, Deb, macOSX, binary and archive, + * and we may have more than one, depending on the compression scheme (zip, + * gz, bz2). */ private void collectAllTargets() { - addAllTargets( allTargets, nsisTargets ); - addAllTargets( allTargets, rpmTargets ); - addAllTargets( allTargets, debTargets ); - addAllTargets( allTargets, macOsXPkgTargets ); - addAllTargets( allTargets, binTargets ); - addAllTargets( allTargets, archiveTargets ); + addAllTargets( allTargets, nsisTargets ); // For Windows + addAllTargets( allTargets, rpmTargets ); // For RPM base linux + addAllTargets( allTargets, debTargets ); // For Debian based Linux + addAllTargets( allTargets, macOsXPkgTargets ); // For Mac OSX + addAllTargets( allTargets, binTargets ); // Pure linux + addAllTargets( allTargets, archiveTargets ); // tar } /** * Adds an array of targets to the given list. * - * @param list - * the list of targets - * @param array - * an array of targets + * @param list the list of targets + * @param array an array of targets */ private void addAllTargets( List list, Target[] array ) { @@ -271,8 +284,7 @@ public class GenerateMojo extends Abstra /** * Gets the output directory. * - * @return - * the output directory + * @return the output directory */ public File getOutputDirectory() { @@ -283,8 +295,7 @@ public class GenerateMojo extends Abstra /** * Gets the associated Maven project. * - * @return - * the associated Maven project + * @return the associated Maven project */ public MavenProject getProject() { @@ -295,10 +306,9 @@ public class GenerateMojo extends Abstra /** * Gets the excluded artifacts. * - * @return - * the excluded artifacts + * @return the excluded artifacts */ - public Set getExcludes() + public Set getExcludes() { return excludes; } @@ -307,8 +317,7 @@ public class GenerateMojo extends Abstra /** * Gets the dpkg utility. * - * @return - * the dpkg utility + * @return the dpkg utility */ public File getDpkgUtility() { @@ -319,8 +328,7 @@ public class GenerateMojo extends Abstra /** * Gets the dpkg utility. * - * @return - * the dpkg utility + * @return the dpkg utility */ public File getPackageMakerUtility() { Added: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/LinuxInstallerCommand.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/LinuxInstallerCommand.java?rev=1649508&view=auto ============================================================================== --- directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/LinuxInstallerCommand.java (added) +++ directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/LinuxInstallerCommand.java Mon Jan 5 11:56:17 2015 @@ -0,0 +1,105 @@ +/* + * 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.server.installers; + + +import java.io.File; +import java.io.IOException; + +import org.apache.maven.plugin.MojoFailureException; + + +/** + * A Deb package for the Debian platform. + * + * To create a Deb package we use the dpkg utility that is bundled in the + * Debian operating system. + * + * @author Apache Directory Project + */ +public abstract class LinuxInstallerCommand extends AbstractMojoCommand +{ + /** Some file postfix */ + protected static final String TAR = "tar"; + + /** The etc/init.d script file */ + protected static final String ETC_INITD_SCRIPT = "etc-initd-script"; + + /** The /opt/apacheds- root directory */ + protected static final String OPT_APACHEDS_DIR = "/opt/apacheds-"; + + /** The /var/lib/apacheds- root directory */ + protected static final String VAR_LIB_APACHEDS_DIR = "/var/lib/apacheds-"; + + /** The default instance name property */ + protected static final String DEFAULT_INSTANCE_NAME_PROP = "default.instance.name"; + + + protected LinuxInstallerCommand( GenerateMojo mojo, T target ) + { + super( mojo, target ); + } + + + /** + * Copies wrapper files to the installation layout. + * + * @param mojo The maven plugin Mojo + * @throws MojoFailureException If the copy failed + */ + public void copyWrapperFiles( GenerateMojo mojo ) throws MojoFailureException + { + try + { + if ( target.isOsArchI386() || target.isOsArchx86() ) + { + mojo.getLog().info( "Copying wrapper files for " + target.getOsArch() ); + MojoHelperUtils.copyBinaryFile( mojo, INSTALLERS_PATH + "wrapper/bin/wrapper-linux-x86-32", + getClass().getResourceAsStream( INSTALLERS_PATH + "wrapper/bin/wrapper-linux-x86-32" ), + new File( getInstallationLayout().getBinDirectory(), "wrapper" ) ); + MojoHelperUtils.copyBinaryFile( mojo, INSTALLERS_PATH + "wrapper/lib/libwrapper-linux-x86-32.so", + getClass().getResourceAsStream( + INSTALLERS_PATH + "wrapper/lib/libwrapper-linux-x86-32.so" ), + new File( getInstallationLayout().getLibDirectory(), "libwrapper.so" ) ); + } + // Linux x86_64 & amd64 + else if ( ( target.isOsArchX86_64() || target.isOsArchAmd64() ) ) + { + mojo.getLog().info( "Copying wrapper files for " + target.getOsArch() ); + MojoHelperUtils.copyBinaryFile( mojo, INSTALLERS_PATH + "wrapper/bin/wrapper-linux-x86-64", + getClass().getResourceAsStream( + INSTALLERS_PATH + "wrapper/bin/wrapper-linux-x86-64" ), + new File( getInstallationLayout().getBinDirectory(), "wrapper" ) ); + MojoHelperUtils.copyBinaryFile( mojo, INSTALLERS_PATH + "wrapper/lib/libwrapper-linux-x86-64.so", + getClass().getResourceAsStream( INSTALLERS_PATH + "wrapper/lib/libwrapper-linux-x86-64.so" ), + new File( getInstallationLayout().getLibDirectory(), "libwrapper.so" ) ); + } + else + { + mojo.getLog().info( "No wrapper files to copy for " + target.getOsArch() ); + } + } + catch ( IOException e ) + { + throw new MojoFailureException( "Failed to copy Tanuki binary files to lib and bin directories" ); + } + } +} Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/MojoHelperUtils.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/MojoHelperUtils.java?rev=1649508&r1=1649507&r2=1649508&view=diff ============================================================================== --- directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/MojoHelperUtils.java (original) +++ directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/MojoHelperUtils.java Mon Jan 5 11:56:17 2015 @@ -31,7 +31,7 @@ import java.io.OutputStreamWriter; import java.io.Reader; import java.io.Writer; import java.util.HashSet; -import java.util.Iterator; +import java.util.List; import java.util.Properties; import java.util.Set; @@ -52,9 +52,13 @@ import org.codehaus.plexus.util.Interpol */ public class MojoHelperUtils { - public static void copyBinaryFile( InputStream from, File to ) throws IOException + public static void copyBinaryFile( GenerateMojo mojo, String fileName, InputStream from, File to ) + throws IOException { FileOutputStream out = null; + + mojo.getLog().info( "Copying " + fileName + " to " + to ); + try { out = new FileOutputStream( to ); @@ -68,8 +72,8 @@ public class MojoHelperUtils } - public static void copyAsciiFile( GenerateMojo mymojo, Properties filterProperties, InputStream from, - File to, boolean filtering ) throws IOException + public static void copyAsciiFile( GenerateMojo mymojo, Properties filterProperties, String fileName, + InputStream from, File to, boolean filtering ) throws IOException { // buffer so it isn't reading a byte at a time! Reader fileReader = null; @@ -114,7 +118,7 @@ public class MojoHelperUtils public static void copyAsciiFile( GenerateMojo mymojo, Properties filterProperties, File from, File to, boolean filtering ) throws IOException { - copyAsciiFile( mymojo, filterProperties, new FileInputStream( from ), to, filtering ); + copyAsciiFile( mymojo, filterProperties, from.getAbsolutePath(), new FileInputStream( from ), to, filtering ); } @@ -125,15 +129,16 @@ public class MojoHelperUtils } - public static void copyDependencies( GenerateMojo mymojo, InstallationLayout layout, + public static void copyDependencies( GenerateMojo myMojo, InstallationLayout layout, boolean includeWrapperDependencies ) throws MojoFailureException { // Creating the excludes set Set excludes = new HashSet(); - if ( mymojo.getExcludes() != null ) + + if ( myMojo.getExcludes() != null ) { - excludes.addAll( mymojo.getExcludes() ); + excludes.addAll( myMojo.getExcludes() ); } // Adding the wrapper dependencies to the excludes set @@ -144,16 +149,17 @@ public class MojoHelperUtils } // Filtering and copying dependencies - Iterator artifacts = mymojo.getProject().getRuntimeArtifacts().iterator(); - while ( artifacts.hasNext() ) + List artifacts = ( List ) ( myMojo.getProject().getRuntimeArtifacts() ); + + for ( Artifact artifact : artifacts ) { - Artifact artifact = ( Artifact ) artifacts.next(); String key = artifact.getGroupId() + ":" + artifact.getArtifactId(); if ( !excludes.contains( key ) ) { try { + myMojo.getLog().info( "Copying " + artifact.getFile() + " to " + layout.getLibDirectory() ); FileUtils.copyFileToDirectory( artifact.getFile(), layout.getLibDirectory() ); } catch ( IOException e ) Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/Target.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/Target.java?rev=1649508&r1=1649507&r2=1649508&view=diff ============================================================================== --- directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/Target.java (original) +++ directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/Target.java Mon Jan 5 11:56:17 2015 @@ -20,12 +20,14 @@ package org.apache.directory.server.installers; + + /** * The superclass for all installer targets. * * @author Apache Directory Project */ -public class Target +public abstract class Target { /** The OS name for 'Any' */ public static final String OS_NAME_ANY = "Any"; @@ -67,8 +69,7 @@ public class Target /** * Gets the final name. * - * @return - * the final name + * @return the final name */ public String getFinalName() { @@ -77,82 +78,75 @@ public class Target /** - * Gets the id. + * Sets the final name. * - * @return - * the id + * @param finalName the final name */ - public String getId() + public void setFinalName( String finalName ) { - return id; + this.finalName = finalName; } /** - * Gets the OS architecture. + * Gets the id. * - * @return - * the OS architecture + * @return the id */ - public String getOsArch() + public String getId() { - return osArch; + return id; } /** - * Gets the OS name. + * Sets the id. * - * @return - * the OS name + * @param id the id */ - public String getOsName() + public void setId( String id ) { - return osName; + this.id = id; } /** - * Sets the final name. + * Gets the OS architecture. * - * @param finalName - * the final name + * @return the OS architecture */ - public void setFinalName( String finalName ) + public String getOsArch() { - this.finalName = finalName; + return osArch; } /** - * Sets the id. + * Sets the OS architecture. * - * @param id - * the id + * @param osArch the OS architecture */ - public void setId( String id ) + public void setOsArch( String osArch ) { - this.id = id; + this.osArch = osArch; } /** - * Sets the OS architecture. + * Gets the OS name. * - * @param osArch - * the OS architecture + * @return the OS name */ - public void setOsArch( String osArch ) + public String getOsName() { - this.osArch = osArch; + return osName; } /** * Sets the OS name. * - * @param osName - * the OS name + * @param osName the OS name */ public void setOsName( String osName ) { Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveInstallerCommand.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveInstallerCommand.java?rev=1649508&r1=1649507&r2=1649508&view=diff ============================================================================== --- directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveInstallerCommand.java (original) +++ directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveInstallerCommand.java Mon Jan 5 11:56:17 2015 @@ -25,8 +25,8 @@ import java.io.IOException; import org.apache.directory.server.core.api.InstanceLayout; import org.apache.directory.server.i18n.I18n; -import org.apache.directory.server.installers.AbstractMojoCommand; import org.apache.directory.server.installers.GenerateMojo; +import org.apache.directory.server.installers.LinuxInstallerCommand; import org.apache.directory.server.installers.MojoHelperUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -39,26 +39,77 @@ import org.codehaus.plexus.util.FileUtil /** - * Archive Installer command for any platform. - * + * Archive Installer command for any platform. We will create the following layout : + *
+ * apacheds-archive-zip/
+ *  |
+ *  +-- apacheds-<version>
+ *       |
+ *       +-- lib/
+ *       |    |
+ *       |    +-- apacheds-service-<version>.jar
+ *       |
+ *       +-- instances/
+ *       |    |
+ *       |    +-- default/
+ *       |         |    
+ *       |         +-- run/
+ *       |         |    
+ *       |         +-- partitions/
+ *       |         |    
+ *       |         +-- log/
+ *       |         |    
+ *       |         +-- conf/
+ *       |         |    |
+ *       |         |    +-- log4j.properties
+ *       |         |    |
+ *       |         |    +-- config.ldif
+ *       |         |
+ *       |         +-- cache/
+ *       |
+ *       +-- bin/
+ *       |    |
+ *       |    +-- apacheds.bat
+ *       |    |
+ *       |    +-- apacheds.sh
+ *       |    |
+ *       |    +-- cpappend.bat
+ *       |    
+ *       +-- NOTICE
+ *       |
+ *       +-- LICENSE
+ * 
* @author Apache Directory Project */ -public class ArchiveInstallerCommand extends AbstractMojoCommand +public class ArchiveInstallerCommand extends LinuxInstallerCommand { + /** The apacheds.bat file */ + private static final String APACHE_BAT_FILE = "apacheds.bat"; + + /** The apacheds.sh file */ + private static final String APACHE_SH_FILE = "apacheds.sh"; + + /** The cpappend.bat file */ + private static final String CPAPPEND_BAT_FILE = "cpappend.bat"; + + /** Some extensions */ + private static final String DOT_TAR = ".tar"; + private static final String ALL_FILES = "/**"; + + /** * Creates a new instance of ArchiveInstallerCommand. * - * @param mojo - * the Server Installers Mojo - * @param target - * the target + * @param mojo the Server Installers Mojo + * @param target the target */ public ArchiveInstallerCommand( GenerateMojo mojo, ArchiveTarget target ) { super( mojo, target ); initializeFilterProperties(); } - + + /** * {@inheritDoc} */ @@ -69,19 +120,24 @@ public class ArchiveInstallerCommand ext instanceLayout.mkdirs(); // Copying the log4j.properties file - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, - getClass().getResourceAsStream( "/org/apache/directory/server/installers/archive/log4j.properties" ), - new File( instanceLayout.getConfDirectory(), "log4j.properties" ), true ); + MojoHelperUtils + .copyAsciiFile( + mojo, + filterProperties, + INSTALLERS_PATH + "archive/" + LOG4J_PROPERTIES_FILE, + getClass().getResourceAsStream( + INSTALLERS_PATH + "archive/" + LOG4J_PROPERTIES_FILE ), + new File( instanceLayout.getConfDirectory(), LOG4J_PROPERTIES_FILE ), true ); // Copying the wrapper configuration file - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, - getClass().getResourceAsStream( "/org/apache/directory/server/installers/wrapper-instance.conf" ), - new File( instanceLayout.getConfDirectory(), "wrapper.conf" ), true ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, INSTALLERS_PATH + WRAPPER_INSTANCE_CONF_FILE, + getClass().getResourceAsStream( INSTALLERS_PATH + WRAPPER_INSTANCE_CONF_FILE ), + new File( instanceLayout.getConfDirectory(), WRAPPER_INSTANCE_CONF_FILE ), true ); // Copying ApacheDS LDIF configuration file - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, - getClass().getResourceAsStream( "/org/apache/directory/server/installers/config.ldif" ), - new File( instanceLayout.getConfDirectory(), "config.ldif" ), false ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, INSTALLERS_PATH + CONFIG_LDIF_FILE, + getClass().getResourceAsStream( INSTALLERS_PATH + CONFIG_LDIF_FILE ), + new File( instanceLayout.getConfDirectory(), CONFIG_LDIF_FILE ), false ); } @@ -105,7 +161,8 @@ public class ArchiveInstallerCommand ext log.info( " Creating " + archiveType + " archive..." ); - // Creating the target directory + // Creating the target directory, where we will store the files which + // will be packaged to form the installer if ( !getTargetDirectory().mkdirs() ) { Exception e = new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECORY, getTargetDirectory() ) ); @@ -117,28 +174,26 @@ public class ArchiveInstallerCommand ext try { - // Creating the installation and instance layouts + // Creating the installation and instance layouts. createLayouts( false ); // Copy bat and sh scripts to bin - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream( - "apacheds.bat" ), new File( getInstallationLayout().getBinDirectory(), - "apacheds.bat" ), false ); - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream( - "apacheds.sh" ), new File( getInstallationLayout().getBinDirectory(), - "apacheds.sh" ), false ); - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream( - "cpappend.bat" ), new File( getInstallationLayout().getBinDirectory(), - "cpappend.bat" ), false ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, APACHE_BAT_FILE, getClass().getResourceAsStream( + APACHE_BAT_FILE ), new File( getInstallationLayout().getBinDirectory(), APACHE_BAT_FILE ), false ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, APACHE_SH_FILE, getClass().getResourceAsStream( + APACHE_SH_FILE ), new File( getInstallationLayout().getBinDirectory(), APACHE_SH_FILE ), false ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, CPAPPEND_BAT_FILE, getClass().getResourceAsStream( + CPAPPEND_BAT_FILE ), new File( getInstallationLayout().getBinDirectory(), + CPAPPEND_BAT_FILE ), false ); // Removing unnecessary directories and files FileUtils.deleteDirectory( getInstallationLayout().getConfDirectory() ); - File wrapperConf = new File( getInstanceLayout().getConfDirectory(), "wrapper.conf" ); + File wrapperConf = new File( getInstanceLayout().getConfDirectory(), WRAPPER_INSTANCE_CONF_FILE ); + if ( !wrapperConf.delete() ) { throw new IOException( I18n.err( I18n.ERR_113_COULD_NOT_DELETE_FILE_OR_DIRECTORY, wrapperConf ) ); } - FileUtils.deleteDirectory( getInstanceLayout().getRunDirectory() ); } catch ( Exception e ) { @@ -151,10 +206,12 @@ public class ArchiveInstallerCommand ext // Creating the final file String finalName = target.getFinalName(); + if ( !finalName.endsWith( archiveType ) ) { finalName = finalName + archiveType; } + File finalFile = new File( mojo.getOutputDirectory(), finalName ); // Preparing the Ant project @@ -162,74 +219,78 @@ public class ArchiveInstallerCommand ext project.setBaseDir( mojo.getOutputDirectory() ); // ZIP Archive - if ( archiveType.equalsIgnoreCase( "zip" ) ) - { - Zip zipTask = new Zip(); - zipTask.setProject( project ); - zipTask.setDestFile( finalFile ); - zipTask.setBasedir( getTargetDirectory() ); - zipTask.setIncludes( getArchiveDirectory().getName() + "/**" ); - zipTask.execute(); - } - // TAR Archive - else if ( archiveType.equalsIgnoreCase( "tar" ) ) - { - Tar tarTask = new Tar(); - tarTask.setProject( project ); - tarTask.setDestFile( finalFile ); - tarTask.setBasedir( getTargetDirectory() ); - tarTask.setIncludes( getArchiveDirectory().getName() + "/**" ); - tarTask.execute(); - } - // TAR.GZ Archive - else if ( archiveType.equalsIgnoreCase( "tar.gz" ) ) - { - File tarFile = new File( mojo.getOutputDirectory(), target.getId() + ".tar" ); + ArchiveType type = ArchiveType.getType( archiveType ); - Tar tarTask = new Tar(); - tarTask.setProject( project ); - tarTask.setDestFile( tarFile ); - tarTask.setBasedir( getTargetDirectory() ); - tarTask.setIncludes( getArchiveDirectory().getName() + "/**" ); - tarTask.execute(); - - GZip gzipTask = new GZip(); - gzipTask.setProject( project ); - gzipTask.setDestfile( finalFile ); - gzipTask.setSrc( tarFile ); - gzipTask.execute(); - - if ( !tarFile.delete() ) - { - Exception e = new IOException( I18n.err( I18n.ERR_113_COULD_NOT_DELETE_FILE_OR_DIRECTORY, tarFile ) ); - log.error( e.getLocalizedMessage() ); - throw new MojoFailureException( e.getMessage() ); - } - } - // TAR.BZ2 Archive - else if ( archiveType.equalsIgnoreCase( "tar.bz2" ) ) + switch ( type ) { - File tarFile = new File( mojo.getOutputDirectory(), target.getId() + ".tar" ); - - Tar tarTask = new Tar(); - tarTask.setProject( project ); - tarTask.setDestFile( tarFile ); - tarTask.setBasedir( getTargetDirectory() ); - tarTask.setIncludes( getArchiveDirectory().getName() + "/**" ); - tarTask.execute(); - - BZip2 bzip2Task = new BZip2(); - bzip2Task.setProject( project ); - bzip2Task.setDestfile( finalFile ); - bzip2Task.setSrc( tarFile ); - bzip2Task.execute(); - - if ( !tarFile.delete() ) - { - Exception e = new IOException( I18n.err( I18n.ERR_113_COULD_NOT_DELETE_FILE_OR_DIRECTORY, tarFile ) ); + case ZIP: + // ZIP Archive + Zip zipTask = new Zip(); + zipTask.setProject( project ); + zipTask.setDestFile( finalFile ); + zipTask.setBasedir( getTargetDirectory() ); + zipTask.setIncludes( getArchiveDirectory().getName() + ALL_FILES ); + zipTask.execute(); + break; + + case TAR: + // TAR Archive + createTarFile( project, finalFile ); + break; + + case TAR_GZ: + // TAR.GZ Archive + File tarFile = new File( mojo.getOutputDirectory(), target.getId() + DOT_TAR ); + + // First create the tar file that will be gzipped + createTarFile( project, tarFile ); + + // And gzip it + GZip gzipTask = new GZip(); + gzipTask.setProject( project ); + gzipTask.setDestfile( finalFile ); + gzipTask.setSrc( tarFile ); + gzipTask.execute(); + + if ( !tarFile.delete() ) + { + Exception e = new IOException( I18n.err( I18n.ERR_113_COULD_NOT_DELETE_FILE_OR_DIRECTORY, tarFile ) ); + log.error( e.getLocalizedMessage() ); + throw new MojoFailureException( e.getMessage() ); + } + + break; + + case TAR_BZ2: + // TAR.BZ2 Archive + tarFile = new File( mojo.getOutputDirectory(), target.getId() + DOT_TAR ); + + // First create the tar file that will be zipped + createTarFile( project, finalFile ); + + // And bzip it + BZip2 bzip2Task = new BZip2(); + bzip2Task.setProject( project ); + bzip2Task.setDestfile( finalFile ); + bzip2Task.setSrc( tarFile ); + bzip2Task.execute(); + + if ( !tarFile.delete() ) + { + Exception e = new IOException( I18n.err( I18n.ERR_113_COULD_NOT_DELETE_FILE_OR_DIRECTORY, tarFile ) ); + log.error( e.getLocalizedMessage() ); + throw new MojoFailureException( e.getMessage() ); + } + + break; + + default: + // Unkown archive type + Exception e = new IOException( + "Cannot determinate the archive type. Only \"tar\", \"tar.gz\", \"tar.bz2\" and \"zip\" are accepted : " + + archiveType ); log.error( e.getLocalizedMessage() ); throw new MojoFailureException( e.getMessage() ); - } } log.info( "=> Archive Installer (" + archiveType + ") archive generated at " @@ -238,6 +299,20 @@ public class ArchiveInstallerCommand ext /** + * Create a tar file will all the files in the project + */ + private void createTarFile( Project project, File tarFile ) + { + Tar tarTask = new Tar(); + tarTask.setProject( project ); + tarTask.setDestFile( tarFile ); + tarTask.setBasedir( getTargetDirectory() ); + tarTask.setIncludes( getArchiveDirectory().getName() + ALL_FILES ); + tarTask.execute(); + } + + + /** * Verifies the target. * * @return @@ -258,11 +333,14 @@ public class ArchiveInstallerCommand ext } // Checking for a known archive type - if ( !archiveType.equalsIgnoreCase( "zip" ) && !archiveType.equalsIgnoreCase( "tar" ) - && !archiveType.equalsIgnoreCase( "tar.gz" ) && !archiveType.equalsIgnoreCase( "tar.bz2" ) ) + ArchiveType type = ArchiveType.getType( archiveType ); + + if ( ( type != ArchiveType.ZIP ) && ( type != ArchiveType.TAR ) && + ( type != ArchiveType.TAR_GZ ) && ( type != ArchiveType.TAR_BZ2 ) ) { log.warn( "Archive type is unknwown (" + archiveType + ")!" ); log.warn( "The build will continue, but please check the archive type of this installer target" ); + return false; } @@ -293,18 +371,17 @@ public class ArchiveInstallerCommand ext */ public File getInstanceDirectory() { - return new File( getArchiveDirectory(), "instances/default" ); + return new File( getArchiveDirectory(), INSTANCE_DEFAULT_DIR ); } /** * Gets the directory for the archive. * - * @return - * the directory for the archive + * @return the directory for the archive */ private File getArchiveDirectory() { - return new File( getTargetDirectory(), "apacheds-" + mojo.getProject().getVersion() ); + return new File( getTargetDirectory(), APACHEDS_DASH + mojo.getProject().getVersion() ); } } Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveTarget.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveTarget.java?rev=1649508&r1=1649507&r2=1649508&view=diff ============================================================================== --- directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveTarget.java (original) +++ directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveTarget.java Mon Jan 5 11:56:17 2015 @@ -24,7 +24,7 @@ import org.apache.directory.server.insta /** - * An archive installer for any platform. + * An archive installer for any platform. We generate * * @author Apache Directory Project */ Added: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveType.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveType.java?rev=1649508&view=auto ============================================================================== --- directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveType.java (added) +++ directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveType.java Mon Jan 5 11:56:17 2015 @@ -0,0 +1,87 @@ +/* + * 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.server.installers.archive; + + +/** + * The list of possible Archive types. + * + * @author Apache Directory Project + */ +public enum ArchiveType +{ + ZIP("zip"), + TAR("tar"), + TAR_GZ("tar.gz"), + TAR_BZ2("tar.bz2"), + UNKNOWN(""); + + /** The archive type */ + private String type; + + + /** + * Creates a new instance of ArchiveType. + */ + private ArchiveType( String type ) + { + this.type = type; + } + + + /** + * @return The archive type as a String + */ + public String getType() + { + return type; + } + + + /** + * @param type The wanted type + * @return The ArchiveType + */ + public static ArchiveType getType( String type ) + { + if ( ZIP.type.equals( type ) ) + { + return ZIP; + } + + if ( TAR.type.equals( type ) ) + { + return TAR; + } + + if ( TAR_BZ2.type.equals( type ) ) + { + return TAR_BZ2; + } + + if ( TAR_GZ.type.equals( type ) ) + { + return TAR_GZ; + } + + return UNKNOWN; + } +} Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/bin/BinInstallerCommand.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/bin/BinInstallerCommand.java?rev=1649508&r1=1649507&r2=1649508&view=diff ============================================================================== --- directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/bin/BinInstallerCommand.java (original) +++ directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/bin/BinInstallerCommand.java Mon Jan 5 11:56:17 2015 @@ -24,8 +24,8 @@ import java.io.File; import java.io.IOException; import org.apache.directory.server.i18n.I18n; -import org.apache.directory.server.installers.AbstractMojoCommand; import org.apache.directory.server.installers.GenerateMojo; +import org.apache.directory.server.installers.LinuxInstallerCommand; import org.apache.directory.server.installers.MojoHelperUtils; import org.apache.directory.server.installers.Target; import org.apache.maven.plugin.MojoExecutionException; @@ -34,14 +34,20 @@ import org.apache.tools.ant.taskdefs.Exe /** - * Bin (Binary) Installer command for Linux. + * Bin (Binary) Installer command for Linux. This creates a pure Linux installer, that can be used on any + * linux or unix box. This is an alternative for boxes not supporting RPM or DEB format. + * + * The way it works is that it creates * * @author Apache Directory Project */ -public class BinInstallerCommand extends AbstractMojoCommand +public class BinInstallerCommand extends LinuxInstallerCommand { + /** The /bin/sh executable */ + private static final String BIN_SH_EXE = "/bin/sh"; + /** The sh utility executable */ - private File shUtility = new File( "/bin/sh" ); + private File shUtility = new File( BIN_SH_EXE ); /** The final name of the installer */ private String finalName; @@ -50,10 +56,8 @@ public class BinInstallerCommand extends /** * Creates a new instance of BinInstallerCommand. * - * @param mojo - * the Server Installers Mojo - * @param target - * the Bin target + * @param mojo the Server Installers Mojo + * @param target the Bin target */ public BinInstallerCommand( GenerateMojo mojo, BinTarget target ) { @@ -97,6 +101,7 @@ public class BinInstallerCommand extends // Creating the instance directory File instanceDirectory = getInstanceDirectory(); + if ( !instanceDirectory.mkdirs() ) { Exception e = new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECORY, instanceDirectory ) ); @@ -105,23 +110,24 @@ public class BinInstallerCommand extends } // Copying configuration files to the instance directory - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, - getClass().getResourceAsStream( "/org/apache/directory/server/installers/log4j.properties" ), - new File( instanceDirectory, "log4j.properties" ), true ); - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, - getClass().getResourceAsStream( "/org/apache/directory/server/installers/wrapper-instance.conf" ), - new File( instanceDirectory, "wrapper.conf" ), true ); - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, - getClass().getResourceAsStream( "/org/apache/directory/server/installers/config.ldif" ), - new File( instanceDirectory, "config.ldif" ), false ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, INSTALLERS_PATH + LOG4J_PROPERTIES_FILE, + getClass().getResourceAsStream( INSTALLERS_PATH + LOG4J_PROPERTIES_FILE ), + new File( instanceDirectory, LOG4J_PROPERTIES_FILE ), true ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, INSTALLERS_PATH + WRAPPER_INSTANCE_CONF_FILE, + getClass().getResourceAsStream( INSTALLERS_PATH + WRAPPER_INSTANCE_CONF_FILE ), + new File( instanceDirectory, WRAPPER_INSTANCE_CONF_FILE ), true ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, INSTALLERS_PATH + CONFIG_LDIF_FILE, + getClass().getResourceAsStream( INSTALLERS_PATH + CONFIG_LDIF_FILE ), + new File( instanceDirectory, CONFIG_LDIF_FILE ), false ); // Copying the init script to the instance directory - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, - getClass().getResourceAsStream( "/org/apache/directory/server/installers/etc-initd-script" ), - new File( instanceDirectory, "etc-initd-script" ), true ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, INSTALLERS_PATH + ETC_INITD_SCRIPT, + getClass().getResourceAsStream( INSTALLERS_PATH + ETC_INITD_SCRIPT ), + new File( instanceDirectory, ETC_INITD_SCRIPT ), true ); // Creating the sh directory for the shell scripts File binShDirectory = new File( getBinInstallerDirectory(), "sh" ); + if ( !binShDirectory.mkdirs() ) { Exception e = new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECORY, binShDirectory ) ); @@ -130,15 +136,20 @@ public class BinInstallerCommand extends } // Copying shell script utilities for the installer - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream( "bootstrap.sh" ), + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, "bootstrap.sh", + getClass().getResourceAsStream( "bootstrap.sh" ), new File( getBinInstallerDirectory(), "bootstrap.sh" ), true ); - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream( - "createInstaller.sh" ), new File( getBinInstallerDirectory(), "createInstaller.sh" ), true ); - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream( "functions.sh" ), + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, "createInstaller.sh", + getClass().getResourceAsStream( "createInstaller.sh" ), + new File( getBinInstallerDirectory(), "createInstaller.sh" ), true ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, "functions.sh", + getClass().getResourceAsStream( "functions.sh" ), new File( binShDirectory, "functions.sh" ), false ); - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream( "install.sh" ), + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, "install.sh", + getClass().getResourceAsStream( "install.sh" ), new File( binShDirectory, "install.sh" ), false ); - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream( "variables.sh" ), + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, "variables.sh", + getClass().getResourceAsStream( "variables.sh" ), new File( binShDirectory, "variables.sh" ), false ); } catch ( Exception e ) @@ -154,6 +165,7 @@ public class BinInstallerCommand extends { shUtility.getAbsolutePath(), "createInstaller.sh" }; createBinTask.setCommandline( cmd ); createBinTask.setWorkingDirectory( getBinInstallerDirectory() ); + try { createBinTask.execute(); @@ -186,8 +198,9 @@ public class BinInstallerCommand extends } // Verifying the currently used OS to build the installer is Linux or Mac OS X - if ( !( Target.OS_NAME_LINUX.equalsIgnoreCase( System.getProperty( "os.name" ) ) || Target.OS_NAME_MAC_OS_X - .equalsIgnoreCase( System.getProperty( "os.name" ) ) ) ) + String osName = System.getProperty( OS_NAME ); + + if ( !( Target.OS_NAME_LINUX.equalsIgnoreCase( osName ) || Target.OS_NAME_MAC_OS_X.equalsIgnoreCase( osName ) ) ) { log.warn( "Bin package installer can only be built on a machine running Linux or Mac OS X!" ); log.warn( "The build will continue, generation of this target is skipped." ); @@ -215,14 +228,16 @@ public class BinInstallerCommand extends filterProperties.put( "tmpArchive", "__tmp.tar.gz" ); finalName = target.getFinalName(); + if ( !finalName.endsWith( ".bin" ) ) { finalName = finalName + ".bin"; } - filterProperties.put( "finalName", finalName ); + + filterProperties.put( FINAL_NAME_PROP, finalName ); filterProperties.put( "apacheds.version", mojo.getProject().getVersion() ); - filterProperties.put( "wrapper.java.command", "# wrapper.java.command=" ); - filterProperties.put( "double.quote", "" ); + filterProperties.put( WRAPPER_JAVA_COMMAND_PROP, WRAPPER_JAVA_COMMAND ); + filterProperties.put( DOUBLE_QUOTE_PROP, "" ); } Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/bin/BinTarget.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/bin/BinTarget.java?rev=1649508&r1=1649507&r2=1649508&view=diff ============================================================================== --- directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/bin/BinTarget.java (original) +++ directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/bin/BinTarget.java Mon Jan 5 11:56:17 2015 @@ -24,7 +24,7 @@ import org.apache.directory.server.insta /** - * A Bin installer for the Linux platform. + * A Bin installer for the Linux platform. The default OsName parameter is Linux. * * To create a Bin installer we use the shell (SH) utility that is bundled * in every Linux. Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/deb/DebInstallerCommand.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/deb/DebInstallerCommand.java?rev=1649508&r1=1649507&r2=1649508&view=diff ============================================================================== --- directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/deb/DebInstallerCommand.java (original) +++ directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/deb/DebInstallerCommand.java Mon Jan 5 11:56:17 2015 @@ -24,8 +24,8 @@ import java.io.File; import java.io.IOException; import org.apache.directory.server.i18n.I18n; -import org.apache.directory.server.installers.AbstractMojoCommand; import org.apache.directory.server.installers.GenerateMojo; +import org.apache.directory.server.installers.LinuxInstallerCommand; import org.apache.directory.server.installers.MojoHelperUtils; import org.apache.directory.server.installers.Target; import org.apache.maven.plugin.MojoExecutionException; @@ -38,15 +38,38 @@ import org.apache.tools.ant.taskdefs.Exe * * @author Apache Directory Project */ -public class DebInstallerCommand extends AbstractMojoCommand +public class DebInstallerCommand extends LinuxInstallerCommand { + /** The debian directory */ + private static final String DEBIAN_DIR = "DEBIAN"; + + /** The debian control file */ + private static final String CONTROL_FILE = "control"; + + /** The debian preinst file */ + private static final String POSTINST_FILE = "postinst"; + + /** The debian postints file for files */ + private static final String PRERM_FILE = "prerm"; + + /** The debian extension for files */ + private static final String DOT_DEB_EXTENSION = ".deb"; + + /** The debian extension for files */ + private static final String DEB_EXTENSION = "deb"; + + /** The default extension */ + private static final String DASH_DEFAULT = "-" + DEFAULT; + + /** The etc/init.d directory */ + private static final String ETC_INITD = "etc/init.d"; + + /** * Creates a new instance of DebInstallerCommand. * - * @param mojo - * the Server Installers Mojo - * @param target - * the DEB target + * @param mojo the Server Installers Mojo + * @param target the DEB target */ public DebInstallerCommand( GenerateMojo mojo, DebTarget target ) { @@ -72,7 +95,11 @@ public class DebInstallerCommand extends log.info( " Creating Deb installer..." ); - // Creating the target directory + // Creating the target directory, which uses the ID of the Target + File targetDirectory = getTargetDirectory(); + + log.info( "Creating target directory : " + targetDirectory.getAbsolutePath() ); + if ( !getTargetDirectory().mkdirs() ) { Exception e = new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECORY, getTargetDirectory() ) ); @@ -88,16 +115,18 @@ public class DebInstallerCommand extends createLayouts(); // Copying the init script in /etc/init.d/ - File debEtcInitdDirectory = new File( getDebDirectory(), "etc/init.d" ); + File debEtcInitdDirectory = new File( getDebDirectory(), ETC_INITD ); + if ( !debEtcInitdDirectory.mkdirs() ) { Exception e = new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECORY, debEtcInitdDirectory ) ); log.error( e.getLocalizedMessage() ); throw new MojoFailureException( e.getMessage() ); } - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, - getClass().getResourceAsStream( "/org/apache/directory/server/installers/etc-initd-script" ), - new File( debEtcInitdDirectory, "apacheds-" + mojo.getProject().getVersion() + "-default" ), true ); + + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, INSTALLERS_PATH + ETC_INITD_SCRIPT, + getClass().getResourceAsStream( INSTALLERS_PATH + ETC_INITD_SCRIPT ), + new File( debEtcInitdDirectory, APACHEDS_DASH + mojo.getProject().getVersion() + DASH_DEFAULT ), true ); } catch ( Exception e ) { @@ -106,7 +135,8 @@ public class DebInstallerCommand extends } // Create DEBIAN directory - File debDebianDirectory = new File( getDebDirectory(), "DEBIAN" ); + File debDebianDirectory = new File( getDebDirectory(), DEBIAN_DIR ); + if ( !debDebianDirectory.mkdirs() ) { Exception e = new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECORY, debDebianDirectory ) ); @@ -114,17 +144,20 @@ public class DebInstallerCommand extends throw new MojoFailureException( e.getMessage() ); } - // Copying the 'control' file + // Copying the 'control', 'postinst' and 'prerm' files try { - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream( "control" ), - new File( debDebianDirectory, "control" ), true ); - - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream( "postinst" ), - new File( debDebianDirectory, "postinst" ), true ); - - MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream( "prerm" ), - new File( debDebianDirectory, "prerm" ), true ); + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, CONTROL_FILE, + getClass().getResourceAsStream( CONTROL_FILE ), + new File( debDebianDirectory, CONTROL_FILE ), true ); + + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, POSTINST_FILE, + getClass().getResourceAsStream( POSTINST_FILE ), + new File( debDebianDirectory, POSTINST_FILE ), true ); + + MojoHelperUtils.copyAsciiFile( mojo, filterProperties, PRERM_FILE, + getClass().getResourceAsStream( PRERM_FILE ), + new File( debDebianDirectory, PRERM_FILE ), true ); } catch ( IOException e ) { @@ -134,21 +167,23 @@ public class DebInstallerCommand extends // Setting correct permission on the postinst script MojoHelperUtils.exec( new String[] - { "chmod", "755", new File( debDebianDirectory, "postinst" ).toString() }, debDebianDirectory, + { CHMOD, RWX_RX_RX, new File( debDebianDirectory, POSTINST_FILE ).toString() }, debDebianDirectory, false ); MojoHelperUtils.exec( new String[] - { "chmod", "755", new File( debDebianDirectory, "prerm" ).toString() }, debDebianDirectory, false ); + { CHMOD, RWX_RX_RX, new File( debDebianDirectory, PRERM_FILE ).toString() }, debDebianDirectory, false ); // Generating the Deb log.info( " Generating Deb installer" ); String finalName = target.getFinalName(); - if ( !finalName.endsWith( ".deb" ) ) + + if ( !finalName.endsWith( DOT_DEB_EXTENSION ) ) { - finalName = finalName + ".deb"; + finalName = finalName + DOT_DEB_EXTENSION; } Execute createDebTask = new Execute(); + String[] cmd = new String[] { mojo.getDpkgUtility().getAbsolutePath(), @@ -156,6 +191,16 @@ public class DebInstallerCommand extends getTargetDirectory().getName() + "/" + getDebDirectory().getName(), finalName }; + + StringBuilder antTask = new StringBuilder(); + + for ( String command : cmd ) + { + antTask.append( command ).append( " " ); + } + + log.info( "Executing the ant task with command : " + antTask.toString() + " into directory " + + mojo.getOutputDirectory() ); createDebTask.setCommandline( cmd ); createDebTask.setWorkingDirectory( mojo.getOutputDirectory() ); @@ -174,7 +219,8 @@ public class DebInstallerCommand extends /** - * Verifies the target. + * Verifies the target. The OsName must be 'Linux', it must be executed on a Linux box + * or a mac, the dpkg utility must be present locally. * * @return * true if the target is correct, @@ -187,15 +233,18 @@ public class DebInstallerCommand extends { log.warn( "Deb package installer can only be targeted for Linux platforms!" ); log.warn( "The build will continue, but please check the the platform of this installer target" ); + return false; } // Verifying the currently used OS to build the installer is Linux or Mac OS X - if ( !( Target.OS_NAME_LINUX.equalsIgnoreCase( System.getProperty( "os.name" ) ) || Target.OS_NAME_MAC_OS_X - .equalsIgnoreCase( System.getProperty( "os.name" ) ) ) ) + String osName = System.getProperty( OS_NAME ); + + if ( !( Target.OS_NAME_LINUX.equalsIgnoreCase( osName ) || Target.OS_NAME_MAC_OS_X.equalsIgnoreCase( osName ) ) ) { log.warn( "Deb package installer can only be built on a machine running Linux or Mac OS X!" ); log.warn( "The build will continue, generation of this target is skipped." ); + return false; } @@ -204,6 +253,7 @@ public class DebInstallerCommand extends { log.warn( "Cannot find dpkg utility at this location: " + mojo.getDpkgUtility() ); log.warn( "The build will continue, but please check the location of your dpkg utility." ); + return false; } @@ -219,6 +269,7 @@ public class DebInstallerCommand extends super.initializeFilterProperties(); String version = mojo.getProject().getVersion(); + if ( version != null ) { if ( version.endsWith( "-SNAPSHOT" ) ) @@ -230,15 +281,15 @@ public class DebInstallerCommand extends filterProperties.put( "version.debian", version ); } } - filterProperties.put( "arch", target.getOsArch() ); - filterProperties.put( "installation.directory", "/opt/apacheds-" + mojo.getProject().getVersion() ); - filterProperties.put( "instances.directory", "/var/lib/apacheds-" + mojo.getProject().getVersion() ); - filterProperties.put( "user", "apacheds" ); - filterProperties.put( "wrapper.java.command", "# wrapper.java.command=" ); - filterProperties.put( "double.quote", "" ); - filterProperties.put( "default.instance.name", "default" ); - filterProperties.put( "installation.directory", "/opt/apacheds-" + mojo.getProject().getVersion() ); + filterProperties.put( ARCH_PROP, target.getOsArch() ); + filterProperties.put( INSTALLATION_DIRECTORY_PROP, OPT_APACHEDS_DIR + mojo.getProject().getVersion() ); + filterProperties.put( INSTANCES_DIRECTORY_PROP, VAR_LIB_APACHEDS_DIR + mojo.getProject().getVersion() ); + filterProperties.put( USER_PROP, APACHEDS ); + filterProperties.put( GROUP_PROP, APACHEDS ); + filterProperties.put( WRAPPER_JAVA_COMMAND_PROP, WRAPPER_JAVA_COMMAND ); + filterProperties.put( DOUBLE_QUOTE_PROP, "" ); + filterProperties.put( DEFAULT_INSTANCE_NAME_PROP, DEFAULT ); } @@ -247,7 +298,7 @@ public class DebInstallerCommand extends */ public File getInstallationDirectory() { - return new File( getDebDirectory(), "opt/apacheds-" + mojo.getProject().getVersion() ); + return new File( getDebDirectory(), OPT_APACHEDS_DIR + mojo.getProject().getVersion() ); } @@ -256,18 +307,17 @@ public class DebInstallerCommand extends */ public File getInstanceDirectory() { - return new File( getDebDirectory(), "var/lib/apacheds-" + mojo.getProject().getVersion() + "/default" ); + return new File( getDebDirectory(), VAR_LIB_APACHEDS_DIR + mojo.getProject().getVersion() + "/" + DEFAULT ); } /** * Gets the directory for the Deb installer. * - * @return - * the directory for the Deb installer + * @return the directory for the Deb installer */ private File getDebDirectory() { - return new File( getTargetDirectory(), "deb" ); + return new File( getTargetDirectory(), DEB_EXTENSION ); } } Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/deb/DebTarget.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/deb/DebTarget.java?rev=1649508&r1=1649507&r2=1649508&view=diff ============================================================================== --- directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/deb/DebTarget.java (original) +++ directory/apacheds/trunk/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/deb/DebTarget.java Mon Jan 5 11:56:17 2015 @@ -24,7 +24,7 @@ import org.apache.directory.server.insta /** - * A Deb package for the Debian platform. + * A Deb package for the Debian platform. The default OsName parameter is Linux. * * To create a Deb package we use the dpkg utility that is bundled in the * Debian operating system. @@ -34,7 +34,7 @@ import org.apache.directory.server.insta public class DebTarget extends Target { /** - * Creates a new instance of DebTarget. + * Creates a new instance of DebTarget, default to X86_64. */ public DebTarget() {