You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/01/24 05:05:32 UTC
svn commit: r371796 - in
/directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers:
CreateImage.java DebTarget.java InnoTarget.java IzPackTarget.java
PkgTarget.java RpmTarget.java Target.java
Author: akarasulu
Date: Mon Jan 23 20:05:28 2006
New Revision: 371796
URL: http://svn.apache.org/viewcvs?rev=371796&view=rev
Log:
restructuring plugin
Added:
directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/DebTarget.java
directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/InnoTarget.java
directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/IzPackTarget.java
directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/PkgTarget.java
directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/RpmTarget.java
Modified:
directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/CreateImage.java
directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/Target.java
Modified: directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/CreateImage.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/CreateImage.java?rev=371796&r1=371795&r2=371796&view=diff
==============================================================================
--- directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/CreateImage.java (original)
+++ directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/CreateImage.java Mon Jan 23 20:05:28 2006
@@ -11,7 +11,10 @@
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Properties;
import java.util.Set;
@@ -68,7 +71,27 @@
/**
* @parameter
*/
- private Target[] targets;
+ private IzPackTarget[] izPackTargets;
+
+ /**
+ * @parameter
+ */
+ private RpmTarget[] rpmTargets;
+
+ /**
+ * @parameter
+ */
+ private PkgTarget[] pkgTargets;
+
+ /**
+ * @parameter
+ */
+ private InnoTarget[] innoTargets;
+
+ /**
+ * @parameter
+ */
+ private DebTarget[] debTargets;
/**
* @parameter
@@ -106,15 +129,24 @@
private Properties filterProperties;
+ private Artifact bootstrapper;
+
+ private List allTargets;
+
public void execute() throws MojoExecutionException, MojoFailureException
{
+ // collect all targets
+ initializeAllTargets();
+
// initialize filters
initializeFiltering();
- // makes sure global values and report targets if have any
+ // makes sure defaulted values are set to globals
setDefaults();
- if ( targets == null )
+
+ // bail if there is nothing to do
+ if ( izPackTargets == null )
{
getLog().info( "===================================================================" );
getLog().info( "[installers:create]" );
@@ -122,13 +154,90 @@
getLog().info( "===================================================================" );
return;
}
+
+ // report what we have to build
reportSetup();
- Artifact bootstrapper = getBootstrapperArtifact();
- for ( int ii = 0; ii < targets.length; ii++ )
+ // search for and find the bootstrapper artifact
+ setBootstrapperArtifact();
+
+ // creates installation images for all targets
+ createImages();
+ }
+
+
+ private void initializeAllTargets()
+ {
+ allTargets = new ArrayList();
+
+ if ( izPackTargets != null )
+ {
+ Collections.addAll( allTargets, izPackTargets );
+ }
+
+ if ( innoTargets != null )
+ {
+ Collections.addAll( allTargets, innoTargets );
+ }
+
+ if ( rpmTargets != null )
+ {
+ Collections.addAll( allTargets, rpmTargets );
+ }
+
+ if ( debTargets != null )
+ {
+ Collections.addAll( allTargets, debTargets );
+ }
+
+ if ( pkgTargets != null )
+ {
+ Collections.addAll( allTargets, pkgTargets );
+ }
+ }
+
+
+ private void copyDependencies( InstallationLayout layout ) throws MojoFailureException
+ {
+ Artifact artifact = null;
+ Iterator artifacts = project.getRuntimeArtifacts().iterator();
+ while ( artifacts.hasNext() )
+ {
+ artifact = ( Artifact ) artifacts.next();
+ if ( artifact.getArtifactId().equals( BOOTSTRAPPER_ARTIFACT_ID ) || artifact.getGroupId().equals( BOOTSTRAPPER_GROUP_ID ) )
+ {
+ getLog().info( "Not copying bootstrapper " + artifact );
+ }
+ else
+ {
+ String key = artifact.getGroupId() + ":" + artifact.getArtifactId();
+ if ( excludes.contains( key ) )
+ {
+ getLog().info( "<<<=== excluded <<<=== " + key );
+ continue;
+ }
+
+ try
+ {
+ FileUtils.copyFileToDirectory( artifact.getFile(), layout.getLibDirectory() );
+ getLog().info( "===>>> included ===>>> " + key );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoFailureException( "Failed to copy dependency artifact "
+ + artifact + " into position " + layout.getLibDirectory() );
+ }
+ }
+ }
+ }
+
+
+ private void createImages() throws MojoFailureException
+ {
+ for ( int ii = 0; ii < allTargets.size(); ii++ )
{
// make the layout directories
- File dir = new File( outputDirectory, targets[ii].getId() );
+ File dir = new File( outputDirectory, ( ( Target ) allTargets.get( ii ) ).getId() );
InstallationLayout layout = new InstallationLayout( dir );
layout.mkdirs();
@@ -146,47 +255,50 @@
// copy over the REQUIRED bootstrapper configuration file
try
{
- FileUtils.copyFile( targets[ii].getBootstrapperConfiguraitonFile(), layout.getBootstrapperConfigurationFile() );
+ FileUtils.copyFile( ( ( Target ) allTargets.get( ii ) ).getBootstrapperConfiguraitonFile(),
+ layout.getBootstrapperConfigurationFile() );
}
catch ( IOException e )
{
throw new MojoFailureException( "Failed to copy bootstrapper configuration file "
- + targets[ii].getBootstrapperConfiguraitonFile()
+ + ( ( Target ) allTargets.get( ii ) ).getBootstrapperConfiguraitonFile()
+ " into position " + layout.getBootstrapperConfigurationFile() );
}
// copy over the optional logging configuration file
- if ( targets[ii].getLoggerConfigurationFile().exists() )
+ if ( ( ( Target ) allTargets.get( ii ) ).getLoggerConfigurationFile().exists() )
{
try
{
- FileUtils.copyFile( targets[ii].getLoggerConfigurationFile(), layout.getLoggerConfigurationFile() );
+ FileUtils.copyFile( ( ( Target ) allTargets.get( ii ) ).getLoggerConfigurationFile(),
+ layout.getLoggerConfigurationFile() );
}
catch ( IOException e )
{
getLog().error( "Failed to copy logger configuration file "
- + targets[ii].getLoggerConfigurationFile()
+ + ( ( Target ) allTargets.get( ii ) ).getLoggerConfigurationFile()
+ " into position " + layout.getLoggerConfigurationFile(), e );
}
}
// copy over the optional server configuration file
- if ( targets[ii].getServerConfigurationFile().exists() )
+ if ( ( ( Target ) allTargets.get( ii ) ).getServerConfigurationFile().exists() )
{
try
{
- FileUtils.copyFile( targets[ii].getServerConfigurationFile(), layout.getConfigurationFile() );
+ FileUtils.copyFile( ( ( Target ) allTargets.get( ii ) ).getServerConfigurationFile(),
+ layout.getConfigurationFile() );
}
catch ( IOException e )
{
getLog().error( "Failed to copy server configuration file "
- + targets[ii].getServerConfigurationFile()
+ + ( ( Target ) allTargets.get( ii ) ).getServerConfigurationFile()
+ " into position " + layout.getConfigurationFile(), e );
}
}
// copy over the init script template
- if ( targets[ii].getOsFamily().equals( "unix" ) )
+ if ( ( ( Target ) allTargets.get( ii ) ).getOsFamily().equals( "unix" ) )
{
try
{
@@ -195,13 +307,14 @@
catch ( IOException e )
{
getLog().error( "Failed to copy server configuration file "
- + targets[ii].getServerConfigurationFile()
+ + ( ( Target ) allTargets.get( ii ) ).getServerConfigurationFile()
+ " into position " + layout.getInitScript(), e );
}
}
// now copy over the jsvc executable renaming it to the applicationName
- if ( targets[ii].getOsName().equals( "linux" ) && targets[ii].getOsArch().equals( "i386" ) )
+ if ( ( ( Target ) allTargets.get( ii ) ).getOsName().equals( "linux" ) &&
+ ( ( Target ) allTargets.get( ii ) ).getOsArch().equals( "i386" ) )
{
File executable = new File ( layout.getBinDirectory(), applicationName );
try
@@ -217,7 +330,8 @@
}
// now copy over the jsvc executable renaming it to the applicationName
- if ( targets[ii].getOsName().equals( "sunos" ) && targets[ii].getOsArch().equals( "sparc" ) )
+ if ( ( ( Target ) allTargets.get( ii ) ).getOsName().equals( "sunos" ) &&
+ ( ( Target ) allTargets.get( ii ) ).getOsArch().equals( "sparc" ) )
{
File executable = new File ( layout.getBinDirectory(), applicationName );
try
@@ -233,7 +347,8 @@
}
// now copy over the jsvc executable renaming it to the applicationName
- if ( targets[ii].getOsName().equals( "macosx" ) && targets[ii].getOsArch().equals( "ppc" ) )
+ if ( ( ( Target ) allTargets.get( ii ) ).getOsName().equals( "macosx" ) &&
+ ( ( Target ) allTargets.get( ii ) ).getOsArch().equals( "ppc" ) )
{
File executable = new File ( layout.getBinDirectory(), applicationName );
try
@@ -249,7 +364,8 @@
}
// now copy over the Prunsrv and Prunmgr executables renaming them to the applicationName + w for mgr
- if ( targets[ii].getOsFamily().equals( "windows" ) && targets[ii].getOsArch().equals( "x86" ) )
+ if ( ( ( Target ) allTargets.get( ii ) ).getOsFamily().equals( "windows" ) &&
+ ( ( Target ) allTargets.get( ii ) ).getOsArch().equals( "x86" ) )
{
File executable = new File ( layout.getBinDirectory(), applicationName + ".exe" );
try
@@ -280,52 +396,16 @@
}
}
-
- private void copyDependencies( InstallationLayout layout ) throws MojoFailureException
- {
- Artifact artifact = null;
- Iterator artifacts = project.getRuntimeArtifacts().iterator();
- while ( artifacts.hasNext() )
- {
- artifact = ( Artifact ) artifacts.next();
- if ( artifact.getArtifactId().equals( BOOTSTRAPPER_ARTIFACT_ID ) || artifact.getGroupId().equals( BOOTSTRAPPER_GROUP_ID ) )
- {
- getLog().info( "Not copying bootstrapper " + artifact );
- }
- else
- {
- String key = artifact.getGroupId() + ":" + artifact.getArtifactId();
- if ( excludes.contains( key ) )
- {
- getLog().info( "<<<=== excluded <<<=== " + key );
- continue;
- }
-
- try
- {
- FileUtils.copyFileToDirectory( artifact.getFile(), layout.getLibDirectory() );
- getLog().info( "===>>> included ===>>> " + key );
- }
- catch ( IOException e )
- {
- throw new MojoFailureException( "Failed to copy dependency artifact "
- + artifact + " into position " + layout.getLibDirectory() );
- }
- }
- }
- }
-
-
private void setDefaults()
{
- if ( targets == null )
+ if ( allTargets == null )
{
return;
}
- for ( int ii = 0; ii < targets.length; ii++ )
+ for ( int ii = 0; ii < allTargets.size(); ii++ )
{
- Target target = targets[ii];
+ Target target = ( Target ) allTargets.get( ii );
if ( target.getLoggerConfigurationFile() == null )
{
@@ -347,7 +427,7 @@
}
- private Artifact getBootstrapperArtifact() throws MojoFailureException
+ private void setBootstrapperArtifact() throws MojoFailureException
{
Artifact artifact = null;
Iterator artifacts = project.getDependencyArtifacts().iterator();
@@ -357,7 +437,7 @@
if ( artifact.getArtifactId().equals( BOOTSTRAPPER_ARTIFACT_ID ) || artifact.getGroupId().equals( BOOTSTRAPPER_GROUP_ID ) )
{
getLog().info( "Found bootstrapper dependency with version: " + artifact.getVersion() );
- return artifact;
+ bootstrapper = artifact;
}
}
@@ -373,35 +453,37 @@
getLog().info( "applicationName = " + applicationName );
getLog().info( "sourceDirectory = " + sourceDirectory );
getLog().info( "outputDirectory = " + outputDirectory );
- getLog().info( "----------------------------- targets -----------------------------" );
+ getLog().info( "----------------------------- allTargets -----------------------------" );
- if ( targets != null )
+ if ( allTargets != null )
{
- for ( int ii = 0; ii < targets.length; ii++ )
+ for ( int ii = 0; ii < allTargets.size(); ii++ )
{
- getLog().info( "id: " + targets[ii].getId() );
+ getLog().info( "id: " + ( ( Target ) allTargets.get( ii ) ).getId() );
-// if ( targets[ii].getDependencies() != null )
+// if ( ( Target ) allTargets.get( ii ).getDependencies() != null )
// {
// StringBuffer buf = new StringBuffer();
-// for ( int jj = 0; jj < targets[ii].getDependencies().length; jj++ )
+// for ( int jj = 0; jj < ( Target ) allTargets.get( ii ).getDependencies().length; jj++ )
// {
-// buf.append( targets[ii].getDependencies()[jj] );
+// buf.append( ( Target ) allTargets.get( ii ).getDependencies()[jj] );
// buf.append( " " );
// }
// getLog().info( "DEPENDENCIES: " + buf.toString() );
// }
- getLog().info( "osName: " + targets[ii].getOsName() );
- getLog().info( "osArch: " + targets[ii].getOsArch() );
- getLog().info( "osVersion: " + targets[ii].getOsVersion() );
- getLog().info( "installer: " + targets[ii].getInstaller() );
- getLog().info( "daemonFramework: " + targets[ii].getDaemonFramework() );
- getLog().info( "loggerConfigurationFile: " + targets[ii].getLoggerConfigurationFile() );
- getLog().info( "bootstrapperConfiguraitonFiles: " + targets[ii].getBootstrapperConfiguraitonFile() );
- getLog().info( "serverConfigurationFil: " + targets[ii].getServerConfigurationFile() );
+ getLog().info( "osName: " + ( ( Target ) allTargets.get( ii ) ).getOsName() );
+ getLog().info( "osArch: " + ( ( Target ) allTargets.get( ii ) ).getOsArch() );
+ getLog().info( "osVersion: " + ( ( Target ) allTargets.get( ii ) ).getOsVersion() );
+ getLog().info( "daemonFramework: " + ( ( Target ) allTargets.get( ii ) ).getDaemonFramework() );
+ getLog().info( "loggerConfigurationFile: " +
+ ( ( Target ) allTargets.get( ii ) ).getLoggerConfigurationFile() );
+ getLog().info( "bootstrapperConfiguraitonFiles: " +
+ ( ( Target ) allTargets.get( ii ) ).getBootstrapperConfiguraitonFile() );
+ getLog().info( "serverConfigurationFil: " +
+ ( ( Target ) allTargets.get( ii ) ).getServerConfigurationFile() );
- if ( ii + 1 < targets.length )
+ if ( ii + 1 < allTargets.size() )
{
getLog().info( "" );
}
Added: directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/DebTarget.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/DebTarget.java?rev=371796&view=auto
==============================================================================
--- directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/DebTarget.java (added)
+++ directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/DebTarget.java Mon Jan 23 20:05:28 2006
@@ -0,0 +1,7 @@
+package org.apache.directory.server.standalone.installers;
+
+
+public class DebTarget extends Target
+{
+
+}
Added: directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/InnoTarget.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/InnoTarget.java?rev=371796&view=auto
==============================================================================
--- directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/InnoTarget.java (added)
+++ directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/InnoTarget.java Mon Jan 23 20:05:28 2006
@@ -0,0 +1,6 @@
+package org.apache.directory.server.standalone.installers;
+
+public class InnoTarget extends Target
+{
+
+}
Added: directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/IzPackTarget.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/IzPackTarget.java?rev=371796&view=auto
==============================================================================
--- directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/IzPackTarget.java (added)
+++ directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/IzPackTarget.java Mon Jan 23 20:05:28 2006
@@ -0,0 +1,7 @@
+package org.apache.directory.server.standalone.installers;
+
+
+public class IzPackTarget extends Target
+{
+
+}
Added: directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/PkgTarget.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/PkgTarget.java?rev=371796&view=auto
==============================================================================
--- directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/PkgTarget.java (added)
+++ directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/PkgTarget.java Mon Jan 23 20:05:28 2006
@@ -0,0 +1,7 @@
+package org.apache.directory.server.standalone.installers;
+
+
+public class PkgTarget extends Target
+{
+
+}
Added: directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/RpmTarget.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/RpmTarget.java?rev=371796&view=auto
==============================================================================
--- directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/RpmTarget.java (added)
+++ directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/RpmTarget.java Mon Jan 23 20:05:28 2006
@@ -0,0 +1,6 @@
+package org.apache.directory.server.standalone.installers;
+
+public class RpmTarget extends Target
+{
+
+}
Modified: directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/Target.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/Target.java?rev=371796&r1=371795&r2=371796&view=diff
==============================================================================
--- directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/Target.java (original)
+++ directory/trunks/apacheds/standalone/installers/plugin/src/main/java/org/apache/directory/server/standalone/installers/Target.java Mon Jan 23 20:05:28 2006
@@ -27,7 +27,6 @@
public final static String[] OPERATING_SYSTEMS = new String[] { "Linux", "SunOS", "Windows", "Mac OS X" };
public final static String[] ARCHITECTURES = new String[] { "intel", "sparc", "ppc" };
public final static String[] DAEMON_FRAMEWORKS = new String[] { "jsvc", "procrun" };
- public final static String[] INSTALLERS = new String[] { "izpack", "inno", "rpm", "deb", "pkg" };
// required stuff
private String id;
@@ -35,7 +34,6 @@
private String osArch;
private String osFamily;
private String daemonFramework;
- private String installer;
// optional stuff
private String minVersion;
@@ -79,18 +77,6 @@
public String getDaemonFramework()
{
return daemonFramework;
- }
-
-
- public void setInstaller(String installer)
- {
- this.installer = installer.toLowerCase( Locale.US );
- }
-
-
- public String getInstaller()
- {
- return installer;
}