You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2016/10/01 06:46:52 UTC
svn commit: r1762982 [1/5] - in
/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src:
checkstyle/ main/java/org/apache/directory/server/installers/
main/java/org/apache/directory/server/installers/archive/
main/java/org/apache/direct...
Author: elecharny
Date: Sat Oct 1 06:46:51 2016
New Revision: 1762982
URL: http://svn.apache.org/viewvc?rev=1762982&view=rev
Log:
Added the installer maven plugin code
Modified:
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/checkstyle/suppressions.xml
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/AbstractMojoCommand.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/GenerateMojo.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/LinuxInstallerCommand.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/MojoHelperUtils.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/ReflectionProperties.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/Target.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveInstallerCommand.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveTarget.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveType.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/bin/BinInstallerCommand.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/bin/BinTarget.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/deb/DebInstallerCommand.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/deb/DebTarget.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/macosxpkg/MacOsXPkgInstallerCommand.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/macosxpkg/MacOsXPkgTarget.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/nsis/NsisInstallerCommand.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/nsis/NsisTarget.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/rpm/RpmInstallerCommand.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/rpm/RpmTarget.java
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/LICENSE
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/NOTICE
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/apacheds
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.bat
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.sh
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/cpappend.bat
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/log4j.properties
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/bootstrap.sh
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/createInstaller.sh
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/functions.sh
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/install.sh
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/variables.sh
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/deb/control
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/deb/postinst
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/deb/prerm
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/etc-initd-script
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/log4j.properties
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/macosxpkg/Info.plist
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/macosxpkg/License.rtf
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/macosxpkg/apacheds-usr-bin.sh
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/macosxpkg/org.apache.directory.server.plist
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/macosxpkg/postflight
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/macosxpkg/preflight
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/nsis/installer.nsi
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/rpm/apacheds.spec
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper-installation.conf
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper-instance.conf
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/conf/wrapper.conf
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/App.bat.in
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/AppCommand.bat.in
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/AppNoWrapper.bat.in
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/InstallApp-NT.bat.in
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/PauseApp-NT.bat.in
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/ResumeApp-NT.bat.in
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/SimpleApp.bat.in
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/SimpleInstallApp-NT.bat.in
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/SimpleUninstallApp-NT.bat.in
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/StartApp-NT.bat.in
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/StopApp-NT.bat.in
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/UninstallApp-NT.bat.in
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/sh.script.in
directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/site/site.xml
Modified: directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/checkstyle/suppressions.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/checkstyle/suppressions.xml?rev=1762982&r1=1762981&r2=1762982&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/checkstyle/suppressions.xml (original)
+++ directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/checkstyle/suppressions.xml Sat Oct 1 06:46:51 2016
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+
+<!--
+ 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.
+-->
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.1//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
+
+<suppressions>
+ <suppress files="org.apache.directory.server.installers.Target" checks="MethodName"/>
+</suppressions>
Modified: directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/AbstractMojoCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/AbstractMojoCommand.java?rev=1762982&r1=1762981&r2=1762982&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/AbstractMojoCommand.java (original)
+++ directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/AbstractMojoCommand.java Sat Oct 1 06:46:51 2016
@@ -0,0 +1,374 @@
+/*
+ * 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 java.util.Properties;
+
+import org.apache.directory.server.InstallationLayout;
+import org.apache.directory.server.core.api.InstanceLayout;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+
+
+/**
+ * A Mojo command pattern abstract class.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class AbstractMojoCommand<T extends Target>
+{
+ /** The filter properties */
+ protected Properties filterProperties = new Properties( System.getProperties() );
+
+ /** The associated mojo */
+ protected GenerateMojo mojo;
+
+ /** The associated target */
+ protected T target;
+
+ /** 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 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=<path-to-java-executable>";
+
+ /** 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
+ */
+ public AbstractMojoCommand( GenerateMojo mojo, T target )
+ {
+ this.mojo = mojo;
+ this.target = target;
+
+ log = mojo.getLog();
+
+ /*
+ this.initializeFilterProperties();
+
+ Properties properties = mojo.getProject().getProperties();
+
+ for ( Object key : properties.keySet() )
+ {
+ log.info( "Using property [" + key + ", " + properties.getProperty( ( String ) key ) + "]" );
+ }
+ */
+ }
+
+
+ /**
+ * Executes the command.
+ *
+ * @throws MojoExecutionException
+ * @throws MojoFailureException
+ */
+ public abstract void execute() throws MojoExecutionException, MojoFailureException;
+
+
+ /**
+ * Gets the filter properties.
+ *
+ * @return the filter properties
+ */
+ public Properties getFilterProperties()
+ {
+ return filterProperties;
+ }
+
+
+ /**
+ * Initializes filter properties.
+ */
+ protected void initializeFilterProperties()
+ {
+ filterProperties.putAll( mojo.getProject().getProperties() );
+ }
+
+
+ /**
+ * Gets the installation directory file.
+ *
+ * @return the installation directory file
+ */
+ public abstract File getInstallationDirectory();
+
+
+ /**
+ * Get the instance directory file.
+ *
+ * @return the instance directory file
+ */
+ public abstract File getInstanceDirectory();
+
+
+ /**
+ * Gets the directory associated with the target.
+ *
+ * @return the directory associated with the target
+ */
+ protected File getTargetDirectory()
+ {
+ return new File( mojo.getOutputDirectory(), target.getId() );
+ }
+
+
+ /**
+ * Creates both installation and instance layouts.
+ *
+ * @throws MojoFailureException
+ * @throws IOException
+ */
+ public void createLayouts() throws MojoFailureException, IOException
+ {
+ createLayouts( true );
+ }
+
+
+ /**
+ * Creates both installation and instance layouts.
+ *
+ * @param includeWrapperDependencies
+ * <code>true</code> if wrapper dependencies are included,
+ * <code>false</code> if wrapper dependencies are excluded
+ *
+ * @throws MojoFailureException
+ * @throws IOException
+ */
+ public void createLayouts( boolean includeWrapperDependencies ) throws MojoFailureException, IOException
+ {
+ log.info( "Creating the installation layout" );
+ createInstallationLayout( includeWrapperDependencies );
+
+ log.info( "Creating the instance layout" );
+ createInstanceLayout();
+ }
+
+
+ /**
+ * Creates the installation layout.
+ *
+ * @throws MojoFailureException
+ * @throws IOException
+ */
+ protected void createInstallationLayout() throws MojoFailureException,
+ IOException
+ {
+ createInstallationLayout( true );
+ }
+
+
+ /**
+ * Creates the installation layout.
+ *
+ * @param includeWrapperDependencies
+ * <code>true</code> if wrapper dependencies are included,
+ * <code>false</code> if wrapper dependencies are excluded
+ *
+ * @throws MojoFailureException
+ * @throws IOException
+ */
+ protected void createInstallationLayout( boolean includeWrapperDependencies ) throws MojoFailureException,
+ IOException
+ {
+ // 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( mojo, INSTALLERS_PATH + "LICENSE",
+ getClass().getResourceAsStream( INSTALLERS_PATH + "LICENSE" ),
+ new File( installationLayout.getInstallationDirectory(), "LICENSE" ) );
+ 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, INSTALLERS_PATH + APACHEDS,
+ getClass().getResourceAsStream( INSTALLERS_PATH + APACHEDS ),
+ new File( installationLayout.getBinDirectory(), APACHEDS ), true );
+
+ MojoHelperUtils.exec( new String[]
+ { CHMOD, RWX_RX_RX, APACHEDS }, installationLayout.getBinDirectory(), false );
+ }
+
+ // Copying the wrappers files (native wrapper executable and library [.jnilib, .so, .dll])
+ copyWrapperFiles( mojo );
+
+ // Copying the wrapper configuration file
+ MojoHelperUtils.copyAsciiFile( mojo, filterProperties,
+ INSTALLERS_PATH + "wrapper-installation.conf",
+ getClass().getResourceAsStream( INSTALLERS_PATH + "wrapper-installation.conf" ),
+ new File( installationLayout.getConfDirectory(), "wrapper.conf" ), true );
+
+ }
+
+
+ public abstract void copyWrapperFiles( GenerateMojo mojo ) throws MojoFailureException;
+
+
+ /**
+ * Creates the instance layout.
+ *
+ * @throws IOException
+ */
+ protected void createInstanceLayout() throws IOException
+ {
+ // 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, 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, 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, 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
+ */
+ protected InstallationLayout getInstallationLayout()
+ {
+ return new InstallationLayout( getInstallationDirectory() );
+ }
+
+
+ /**
+ * Gets the instance layout.
+ *
+ * @return the instance layout
+ */
+ protected InstanceLayout getInstanceLayout()
+ {
+ File instanceDirectory = getInstanceDirectory();
+
+ return new InstanceLayout( instanceDirectory );
+ }
+}
Modified: directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/GenerateMojo.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/GenerateMojo.java?rev=1762982&r1=1762981&r2=1762982&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/GenerateMojo.java (original)
+++ directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/GenerateMojo.java Sat Oct 1 06:46:51 2016
@@ -0,0 +1,355 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.directory.server.installers.archive.ArchiveInstallerCommand;
+import org.apache.directory.server.installers.archive.ArchiveTarget;
+import org.apache.directory.server.installers.bin.BinInstallerCommand;
+import org.apache.directory.server.installers.bin.BinTarget;
+import org.apache.directory.server.installers.deb.DebInstallerCommand;
+import org.apache.directory.server.installers.deb.DebTarget;
+import org.apache.directory.server.installers.macosxpkg.MacOsXPkgInstallerCommand;
+import org.apache.directory.server.installers.macosxpkg.MacOsXPkgTarget;
+import org.apache.directory.server.installers.nsis.NsisInstallerCommand;
+import org.apache.directory.server.installers.nsis.NsisTarget;
+import org.apache.directory.server.installers.rpm.RpmInstallerCommand;
+import org.apache.directory.server.installers.rpm.RpmTarget;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.FileUtils;
+
+
+/**
+ * Maven 2 mojo creating the platform specific installation layout images.
+ *
+ * @goal generate
+ * @description Creates platform specific installation layout images.
+ * @phase package
+ * @requiresDependencyResolution runtime
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class GenerateMojo extends AbstractMojo
+{
+ /**
+ * The target directory into which the mojo creates os and platform
+ * specific images.
+ *
+ * @parameter default-value="${project.build.directory}/installers"
+ */
+ private File outputDirectory;
+
+ /**
+ * The associated maven project.
+ *
+ * @parameter expression="${project}" default-value="${project}"
+ * @required
+ */
+ private MavenProject project;
+
+ /**
+ * The RPM installer targets.
+ *
+ * @parameter
+ */
+ private RpmTarget[] rpmTargets;
+
+ /**
+ * The Mac OS X installer targets.
+ *
+ * @parameter
+ */
+ private MacOsXPkgTarget[] macOsXPkgTargets;
+
+ /**
+ * The NSIS installer targets.
+ *
+ * @parameter
+ */
+ private NsisTarget[] nsisTargets;
+
+ /**
+ * The Debian installer targets.
+ *
+ * @parameter
+ */
+ private DebTarget[] debTargets;
+
+ /**
+ * The Binary installer targets.
+ *
+ * @parameter
+ */
+ private BinTarget[] binTargets;
+
+ /**
+ * The Archive installers targets.
+ *
+ * @parameter
+ */
+ private ArchiveTarget[] archiveTargets;
+
+ /**
+ * The exclusions.
+ *
+ * @parameter
+ */
+ private Set<String> excludes;
+
+ /**
+ * The dpkg utility executable.
+ *
+ * @parameter
+ * expression="${installers.dpkg}"
+ * default-value="/usr/bin/dpkg"
+ */
+ private File dpkgUtility;
+
+ /**
+ * The PackageMaker utility executable.
+ *
+ * @parameter
+ * expression="${installers.packageMaker}"
+ * default-value="/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker"
+ */
+ private File packageMakerUtility;
+
+ /**
+ * The makensis utility executable.
+ *
+ * @parameter
+ * expression="${installers.makensis}"
+ * default-value="/usr/bin/makensis"
+ */
+ private File makensisUtility;
+
+ /**
+ * The rpmbuild utility executable.
+ *
+ * @parameter
+ * expression="${installers.rpmbuild}"
+ * default-value="/usr/bin/rpmbuild"
+ */
+ private File rpmbuildUtility;
+
+ /** The list containing all the targets */
+ private List<Target> allTargets = new ArrayList<Target>();
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException
+ {
+ // Collecting all targets
+ collectAllTargets();
+
+ // Returning if there is no target to build
+ 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
+ for ( Target target : allTargets )
+ {
+ getLog().info( "Executing target '" + target.getId() + "'" );
+ getLog().info( "--------------------" );
+ getLog().info( "OS Name: " + target.getOsName() );
+ getLog().info( "OS Arch: " + target.getOsArch() );
+ getLog().info( "--------------------" );
+
+ // Archive target
+ if ( target instanceof ArchiveTarget )
+ {
+ ArchiveInstallerCommand archiveCmd = new ArchiveInstallerCommand( this, ( ArchiveTarget ) target );
+ archiveCmd.execute();
+ }
+
+ // Bin target
+ if ( target instanceof BinTarget )
+ {
+ BinInstallerCommand binCmd = new BinInstallerCommand( this, ( BinTarget ) target );
+ binCmd.execute();
+ }
+
+ // Deb target
+ if ( target instanceof DebTarget )
+ {
+ DebInstallerCommand debCmd = new DebInstallerCommand( this, ( DebTarget ) target );
+ debCmd.execute();
+ }
+
+ // Mac OS X PKG target
+ if ( target instanceof MacOsXPkgTarget )
+ {
+ MacOsXPkgInstallerCommand pkgCmd = new MacOsXPkgInstallerCommand( this, ( MacOsXPkgTarget ) target );
+ pkgCmd.execute();
+ }
+
+ // NSIS target
+ if ( target instanceof NsisTarget )
+ {
+ NsisInstallerCommand nsisCmd = new NsisInstallerCommand( this, ( NsisTarget ) target );
+ nsisCmd.execute();
+ }
+
+ // RPM target
+ if ( target instanceof RpmTarget )
+ {
+ RpmInstallerCommand rpmCmd = new RpmInstallerCommand( this, ( RpmTarget ) target );
+ rpmCmd.execute();
+ }
+
+ getLog().info( "-------------------------------------------------------" );
+ }
+ }
+
+
+ /**
+ * 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 :
+ * <pre>
+ * <nsisTargets>
+ * <nsisTarget>
+ * <id>apacheds-win32</id>
+ * <finalName>apacheds-${project.version}.exe</finalName>
+ * </nsisTarget>
+ * </nsisTargets>
+ * </pre>
+ * 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 ); // 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
+ */
+ private void addAllTargets( List<Target> list, Target[] array )
+ {
+ if ( ( list != null ) && ( array != null ) )
+ {
+ list.addAll( Arrays.asList( array ) );
+ }
+ }
+
+
+ /**
+ * Gets the output directory.
+ *
+ * @return the output directory
+ */
+ public File getOutputDirectory()
+ {
+ return outputDirectory;
+ }
+
+
+ /**
+ * Gets the associated Maven project.
+ *
+ * @return the associated Maven project
+ */
+ public MavenProject getProject()
+ {
+ return project;
+ }
+
+
+ /**
+ * Gets the excluded artifacts.
+ *
+ * @return the excluded artifacts
+ */
+ public Set<String> getExcludes()
+ {
+ return excludes;
+ }
+
+
+ /**
+ * Gets the dpkg utility.
+ *
+ * @return the dpkg utility
+ */
+ public File getDpkgUtility()
+ {
+ return dpkgUtility;
+ }
+
+
+ /**
+ * Gets the dpkg utility.
+ *
+ * @return the dpkg utility
+ */
+ public File getPackageMakerUtility()
+ {
+ return packageMakerUtility;
+ }
+
+
+ /**
+ * Gets the makensis utility.
+ *
+ * @return
+ * the dpkg utility
+ */
+ public File getMakensisUtility()
+ {
+ return makensisUtility;
+ }
+
+
+ public File getRpmbuildUtility()
+ {
+ return rpmbuildUtility;
+ }
+}
Modified: directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/LinuxInstallerCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/LinuxInstallerCommand.java?rev=1762982&r1=1762981&r2=1762982&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/LinuxInstallerCommand.java (original)
+++ directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/LinuxInstallerCommand.java Sat Oct 1 06:46:51 2016
@@ -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 <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class LinuxInstallerCommand<T extends Target> extends AbstractMojoCommand<T>
+{
+ /** 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/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/MojoHelperUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/MojoHelperUtils.java?rev=1762982&r1=1762981&r2=1762982&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/MojoHelperUtils.java (original)
+++ directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/MojoHelperUtils.java Sat Oct 1 06:46:51 2016
@@ -0,0 +1,242 @@
+/*
+ * 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.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.directory.server.InstallationLayout;
+import org.apache.directory.server.i18n.I18n;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.tools.ant.taskdefs.Execute;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.InterpolationFilterReader;
+
+
+/**
+ * Some helper/utility methods for this plugin.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public final class MojoHelperUtils
+{
+
+ private MojoHelperUtils()
+ {
+ }
+
+
+ public static void copyBinaryFile( GenerateMojo mojo, String fileName, InputStream from, File to )
+ throws IOException
+ {
+ mojo.getLog().info( "Copying " + fileName + " to " + to );
+
+ try ( FileOutputStream out = new FileOutputStream( to ) )
+ {
+ IOUtil.copy( from, out );
+ }
+ finally
+ {
+ IOUtil.close( from );
+ }
+ }
+
+
+ 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!
+ try ( Reader fileReader = new BufferedReader( new InputStreamReader( from ) );
+ Writer fileWriter = new OutputStreamWriter( new FileOutputStream( to ) ) )
+ {
+ Reader reader = null;
+ if ( filtering )
+ {
+ // support _${token}
+ reader = new InterpolationFilterReader( fileReader, filterProperties, "_${", "}" );
+ // support ${token}
+ reader = new InterpolationFilterReader( reader, filterProperties, "${", "}" );
+ // support @token@
+ reader = new InterpolationFilterReader( reader, filterProperties, "@", "@" );
+
+ boolean isPropertiesFile = false;
+ if ( to.isFile() && to.getName().endsWith( ".properties" ) )
+ {
+ isPropertiesFile = true;
+ }
+ reader = new InterpolationFilterReader( reader, new ReflectionProperties( mymojo.getProject(),
+ isPropertiesFile ), "${", "}" );
+ }
+ else
+ {
+ reader = fileReader;
+ }
+ IOUtil.copy( reader, fileWriter );
+ }
+ }
+
+
+ public static void copyAsciiFile( GenerateMojo mymojo, Properties filterProperties, File from, File to,
+ boolean filtering ) throws IOException
+ {
+ copyAsciiFile( mymojo, filterProperties, from.getAbsolutePath(), new FileInputStream( from ), to, filtering );
+ }
+
+
+ public static void copyDependencies( GenerateMojo mymojo, InstallationLayout layout )
+ throws MojoFailureException
+ {
+ copyDependencies( mymojo, layout, true );
+ }
+
+
+ public static void copyDependencies( GenerateMojo myMojo, InstallationLayout layout,
+ boolean includeWrapperDependencies )
+ throws MojoFailureException
+ {
+ // Creating the excludes set
+ Set<String> excludes = new HashSet<String>();
+
+ if ( myMojo.getExcludes() != null )
+ {
+ excludes.addAll( myMojo.getExcludes() );
+ }
+
+ // Adding the wrapper dependencies to the excludes set
+ if ( !includeWrapperDependencies )
+ {
+ excludes.add( "org.apache.directory.server:apacheds-wrapper" );
+ excludes.add( "tanukisoft:wrapper" );
+ }
+
+ // Filtering and copying dependencies
+ List<Artifact> artifacts = ( List<Artifact> ) ( myMojo.getProject().getRuntimeArtifacts() );
+
+ for ( Artifact artifact : artifacts )
+ {
+ 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 )
+ {
+ throw new MojoFailureException( "Failed to copy dependency artifact " + artifact
+ + " into position " + layout.getLibDirectory() );
+ }
+ }
+ }
+ }
+
+
+ public static void exec( String[] cmd, File workDir, boolean doSudo ) throws MojoFailureException
+ {
+ Execute task = new Execute();
+ task.setCommandline( cmd );
+ task.setWorkingDirectory( workDir );
+
+ if ( doSudo )
+ {
+ StringBuffer cmdString = new StringBuffer( " " );
+ for ( int ii = 0; ii < cmd.length; ii++ )
+ {
+ cmdString.append( cmd[ii] ).append( " " );
+ }
+
+ String[] temp = new String[2];
+ temp[0] = "sudo";
+ temp[1] = cmdString.toString();
+ cmd = temp;
+ }
+
+ StringBuffer cmdString = new StringBuffer( " " );
+ for ( int ii = 0; ii < cmd.length; ii++ )
+ {
+ cmdString.append( cmd[ii] ).append( " " );
+ }
+
+ try
+ {
+ task.execute();
+ }
+ catch ( IOException e )
+ {
+ throw new MojoFailureException( "Failed while trying to execute '" + cmdString + "': " + e.getMessage() );
+ }
+
+ if ( task.getExitValue() != 0 )
+ {
+ throw new MojoFailureException( "Execution of '" + cmdString + "' resulted in a non-zero exit value: "
+ + task.getExitValue() );
+ }
+ }
+
+
+ /**
+ * 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 static void copyFiles( File src, File dest ) throws IOException
+ {
+ if ( src.isDirectory() )
+ {
+ File[] files = src.listFiles();
+
+ if ( !dest.mkdirs() )
+ {
+ throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECORY, dest ) );
+ }
+
+ for ( File file : files )
+ {
+ copyFiles( file, new File( dest, file.getName() ) );
+ }
+ }
+ else
+ {
+ FileUtils.copyFile( src, dest );
+ }
+ }
+}
Modified: directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/ReflectionProperties.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/ReflectionProperties.java?rev=1762982&r1=1762981&r2=1762982&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/ReflectionProperties.java (original)
+++ directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/ReflectionProperties.java Sat Oct 1 06:46:51 2016
@@ -0,0 +1,77 @@
+/*
+ * 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 org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
+
+import java.util.Properties;
+
+
+/**
+ * Took this from the maven resource plugin in trunk or else I would have added it
+ * as a dep. This can be removed once the 2.2 release of the resource plugin comes
+ * out.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ReflectionProperties extends Properties
+{
+ private static final long serialVersionUID = -4748409484925117841L;
+ private MavenProject project;
+ boolean escapedBackslashesInFilePath;
+
+
+ public ReflectionProperties( MavenProject aProject, boolean escapedBackslashesInFilePath )
+ {
+ super();
+ project = aProject;
+ this.escapedBackslashesInFilePath = escapedBackslashesInFilePath;
+ }
+
+
+ public Object get( Object key )
+ {
+ Object value = null;
+ try
+ {
+ value = ReflectionValueExtractor.evaluate( "" + key, project );
+ if ( escapedBackslashesInFilePath && value != null
+ && "java.lang.String".equals( value.getClass().getName() ) )
+ {
+ String val = ( String ) value;
+
+ // Check if it's a windows path
+ if ( val.indexOf( ":\\" ) == 1 )
+ {
+ value = StringUtils.replace( ( String ) value, "\\", "\\\\" );
+ value = StringUtils.replace( ( String ) value, ":", "\\:" );
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+ //TODO: remove the try-catch block when ReflectionValueExtractor.evaluate() throws no more exceptions
+ }
+ return value;
+ }
+}
Modified: directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/Target.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/Target.java?rev=1762982&r1=1762981&r2=1762982&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/Target.java (original)
+++ directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/Target.java Sat Oct 1 06:46:51 2016
@@ -0,0 +1,236 @@
+/*
+ * 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;
+
+
+
+
+/**
+ * The superclass for all installer targets.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class Target
+{
+ /** The OS name for 'Any' */
+ public static final String OS_NAME_ANY = "Any";
+ /** The OS name for 'Linux' */
+ public static final String OS_NAME_LINUX = "Linux";
+ /** The OS name for 'Mac OS X' */
+ public static final String OS_NAME_MAC_OS_X = "Mac OS X";
+ /** The OS name for 'Solaris' */
+ public static final String OS_NAME_SOLARIS = "Solaris";
+ /** The OS name for 'Windows' */
+ public static final String OS_NAME_WINDOWS = "Windows";
+
+ /** The OS architecture for 'amd64' */
+ public static final String OS_ARCH_AMD64 = "amd64";
+ /** The OS architecture for 'Any' */
+ public static final String OS_ARCH_ANY = "Any";
+ /** The OS architecture for 'i386' */
+ public static final String OS_ARCH_I386 = "i386";
+ /** The OS architecture for 'sparc' */
+ public static final String OS_ARCH_SPARC = "sparc";
+ /** The OS architecture for 'x86' */
+ public static final String OS_ARCH_X86 = "x86";
+ /** The OS architecture for 'x86_64' */
+ public static final String OS_ARCH_X86_64 = "x86_64";
+
+ /** The id */
+ private String id;
+
+ /** The name of the operating system */
+ private String osName;
+
+ /** The architecture of the operating system */
+ private String osArch;
+
+ /** The final name of the installer file */
+ private String finalName;
+
+
+ /**
+ * Gets the final name.
+ *
+ * @return the final name
+ */
+ public String getFinalName()
+ {
+ return finalName;
+ }
+
+
+ /**
+ * Sets the final name.
+ *
+ * @param finalName the final name
+ */
+ public void setFinalName( String finalName )
+ {
+ this.finalName = finalName;
+ }
+
+
+ /**
+ * Gets the id.
+ *
+ * @return the id
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+
+ /**
+ * Sets the id.
+ *
+ * @param id the id
+ */
+ public void setId( String id )
+ {
+ this.id = id;
+ }
+
+
+ /**
+ * Gets the OS architecture.
+ *
+ * @return the OS architecture
+ */
+ public String getOsArch()
+ {
+ return osArch;
+ }
+
+
+ /**
+ * Sets the OS architecture.
+ *
+ * @param osArch the OS architecture
+ */
+ public void setOsArch( String osArch )
+ {
+ this.osArch = osArch;
+ }
+
+
+ /**
+ * Gets the OS name.
+ *
+ * @return the OS name
+ */
+ public String getOsName()
+ {
+ return osName;
+ }
+
+
+ /**
+ * Sets the OS name.
+ *
+ * @param osName the OS name
+ */
+ public void setOsName( String osName )
+ {
+ this.osName = osName;
+ }
+
+
+ /**
+ * Indicates if the OS name is 'Linux'.
+ */
+ public boolean isOsNameLinux()
+ {
+ return Target.OS_NAME_LINUX.equalsIgnoreCase( osName );
+ }
+
+
+ /**
+ * Indicates if the OS name is 'Mac OS X'.
+ */
+ public boolean isOsNameMacOSX()
+ {
+ return Target.OS_NAME_MAC_OS_X.equalsIgnoreCase( osName );
+ }
+
+
+ /**
+ * Indicates if the OS name is 'Solaris'.
+ */
+ public boolean isOsNameSolaris()
+ {
+ return Target.OS_NAME_SOLARIS.equalsIgnoreCase( osName );
+ }
+
+
+ /**
+ * Indicates if the OS name is 'Windows'.
+ */
+ public boolean isOsNameWindows()
+ {
+ return Target.OS_NAME_WINDOWS.equalsIgnoreCase( osName );
+ }
+
+
+ /**
+ * Indicates if the OS architecture is 'amd64'.
+ */
+ public boolean isOsArchAmd64()
+ {
+ return Target.OS_ARCH_AMD64.equalsIgnoreCase( osArch );
+ }
+
+
+ /**
+ * Indicates if the OS architecture is 'i386'.
+ */
+ public boolean isOsArchI386()
+ {
+ return Target.OS_ARCH_I386.equalsIgnoreCase( osArch );
+ }
+
+
+ /**
+ * Indicates if the OS architecture is 'Sparc'.
+ */
+ public boolean isOsArchSparc()
+ {
+ return Target.OS_ARCH_SPARC.equalsIgnoreCase( osArch );
+ }
+
+
+ /**
+ * Indicates if the OS architecture is 'x86'.
+ */
+ public boolean isOsArchx86()
+ {
+ return Target.OS_ARCH_X86.equalsIgnoreCase( osArch );
+ }
+
+
+ /**
+ * Indicates if the OS architecture is 'x86_64'.
+ */
+ public boolean isOsArchX86_64()
+ {
+ return Target.OS_ARCH_X86_64.equalsIgnoreCase( osArch );
+ }
+}
Modified: directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveInstallerCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveInstallerCommand.java?rev=1762982&r1=1762981&r2=1762982&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveInstallerCommand.java (original)
+++ directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveInstallerCommand.java Sat Oct 1 06:46:51 2016
@@ -0,0 +1,397 @@
+/*
+ * 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;
+
+
+import java.io.File;
+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.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;
+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.Tar.TarFileSet;
+import org.apache.tools.ant.taskdefs.Zip;
+import org.codehaus.plexus.util.FileUtils;
+
+
+/**
+ * Archive Installer command for any platform. We will create the following layout :
+ * <pre>
+ * 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
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ArchiveInstallerCommand extends LinuxInstallerCommand<ArchiveTarget>
+{
+ /** 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
+ */
+ public ArchiveInstallerCommand( GenerateMojo mojo, ArchiveTarget target )
+ {
+ super( mojo, target );
+ initializeFilterProperties();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void createInstanceLayout() throws IOException
+ {
+ // Getting the instance layout and creating directories
+ InstanceLayout instanceLayout = getInstanceLayout();
+ instanceLayout.mkdirs();
+
+ // Copying the log4j.properties file
+ 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, 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, INSTALLERS_PATH + CONFIG_LDIF_FILE,
+ getClass().getResourceAsStream( INSTALLERS_PATH + CONFIG_LDIF_FILE ),
+ new File( instanceLayout.getConfDirectory(), CONFIG_LDIF_FILE ), false );
+ }
+
+
+ /**
+ * Performs the following:
+ * <ol>
+ * <li>Bail if the archive type is unknown</li>
+ * <li>Creates the Archive Installer for ApacheDS</li>
+ * </ol>
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException
+ {
+ // Verifying the target
+ if ( !verifyTarget() )
+ {
+ return;
+ }
+
+ // Getting the archive type
+ String archiveType = target.getArchiveType();
+
+ log.info( " Creating " + archiveType + " archive..." );
+
+ // 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() ) );
+ log.error( e.getLocalizedMessage() );
+ throw new MojoFailureException( e.getMessage() );
+ }
+
+ log.info( " Copying archive files" );
+
+ try
+ {
+ // Creating the installation and instance layouts.
+ createLayouts( false );
+
+ // Copy bat and sh scripts to bin
+ 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_INSTANCE_CONF_FILE );
+
+ if ( !wrapperConf.delete() )
+ {
+ throw new IOException( I18n.err( I18n.ERR_113_COULD_NOT_DELETE_FILE_OR_DIRECTORY, wrapperConf ) );
+ }
+ }
+ catch ( Exception e )
+ {
+ log.error( e.getMessage() );
+ throw new MojoFailureException( "Failed to copy archive files." );
+ }
+
+ // Generating the archive
+ log.info( " Generating archive" );
+
+ // 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
+ Project project = new Project();
+ project.setBaseDir( mojo.getOutputDirectory() );
+
+ // ZIP Archive
+ ArchiveType type = ArchiveType.getType( archiveType );
+
+ switch ( type )
+ {
+ 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 "
+ + finalFile );
+ }
+
+
+ /**
+ * 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 );
+
+ TarFileSet nonExecutables = tarTask.createTarFileSet();
+ nonExecutables.setDir( getTargetDirectory() );
+ nonExecutables.setIncludes( getArchiveDirectory().getName() + ALL_FILES );
+ nonExecutables.setExcludes( getArchiveDirectory().getName() + "/**/*.sh" );
+
+ TarFileSet executables = tarTask.createTarFileSet();
+ executables.setDir( getTargetDirectory() );
+ executables.setIncludes( getArchiveDirectory().getName() + "/**/*.sh" );
+ executables.setFileMode( "755" );
+
+ tarTask.execute();
+ }
+
+
+ /**
+ * Verifies the target.
+ *
+ * @return
+ * <code>true</code> if the target is correct,
+ * <code>false</code> if not.
+ */
+ private boolean verifyTarget()
+ {
+ // 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 target" );
+ return false;
+ }
+
+ // Checking for a known archive type
+ 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;
+ }
+
+ return true;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void initializeFilterProperties()
+ {
+ super.initializeFilterProperties();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public File getInstallationDirectory()
+ {
+ return getArchiveDirectory();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public File getInstanceDirectory()
+ {
+ return new File( getArchiveDirectory(), INSTANCE_DEFAULT_DIR );
+ }
+
+
+ /**
+ * Gets the directory for the archive.
+ *
+ * @return the directory for the archive
+ */
+ private File getArchiveDirectory()
+ {
+ return new File( getTargetDirectory(), APACHEDS_DASH + mojo.getProject().getVersion() );
+ }
+}
Modified: directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveTarget.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveTarget.java?rev=1762982&r1=1762981&r2=1762982&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveTarget.java (original)
+++ directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveTarget.java Sat Oct 1 06:46:51 2016
@@ -0,0 +1,78 @@
+/*
+ * 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;
+
+
+import org.apache.directory.server.installers.Target;
+
+
+/**
+ * An archive installer for any platform. We generate
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ArchiveTarget extends Target
+{
+ /**
+ * The archive type.
+ * <p>
+ * Possible types are:
+ * <ul>
+ * <li>zip (default)</li>
+ * <li>tar</li>
+ * <li>tar.gz</li>
+ * <li>tar.bz2</li>
+ * </ul>
+ */
+ private String archiveType = "zip";
+
+
+ /**
+ * Creates a new instance of ArchiveTarget.
+ */
+ public ArchiveTarget()
+ {
+ setOsName( Target.OS_NAME_ANY );
+ setOsArch( Target.OS_ARCH_ANY );
+ }
+
+
+ /**
+ * 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;
+ }
+}
Modified: directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveType.java?rev=1762982&r1=1762981&r2=1762982&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveType.java (original)
+++ directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/java/org/apache/directory/server/installers/archive/ArchiveType.java Sat Oct 1 06:46:51 2016
@@ -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 <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+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;
+ }
+}