copyFiles( baseDirectory, binRootFolderServerDirectory );
}
catch ( IOException e )
{
log.error( e.getMessage() );
throw new MojoFailureException( "Failed to copy image (" + target.getLayout().getBaseDirectory()
+ ") to the Bin directory (" + binRootFolderDirectory + ")" );
}
// Create instance and sh directory
File binRootFolderInstanceDirectory = new File( binRootFolderDirectory, "instance" );
binRootFolderInstanceDirectory.mkdirs();
File binShDirectory = new File( binDirectory, "sh" );
binShDirectory.mkdirs();
// Copying the resources files
try
{
// Copying the apacheds.conf file to the server installation layout
MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "apacheds.conf" ),
new File( binRootFolderServerDirectory, "conf/apacheds.conf" ), false );
// Copying the default instance apacheds.conf file
MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream(
"apacheds-default.conf" ), new File( binRootFolderInstanceDirectory, "apacheds.conf" ), false );
// Copying the log4j.properties file for the default instance
MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, new File( binRootFolderServerDirectory,
"conf/log4j.properties" ), new File( binRootFolderInstanceDirectory, "log4j.properties" ), false );
// Copying the server.xml file for the default instance
MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, new File( binRootFolderServerDirectory,
"conf/server.xml" ), new File( binRootFolderInstanceDirectory, "server.xml" ), false );
// Copying the apacheds-init script file for the default instance
MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "apacheds-init" ),
new File( binRootFolderInstanceDirectory, "apacheds-init" ), true );
// Copying shell script utilities for the installer
MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "bootstrap.sh" ),
new File( binDirectory, "bootstrap.sh" ), true );
MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream(
"createInstaller.sh" ), new File( binDirectory, "createInstaller.sh" ), true );
MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "functions.sh" ),
new File( binShDirectory, "functions.sh" ), false );
MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "install.sh" ),
new File( binShDirectory, "install.sh" ), false );
MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "variables.sh" ),
new File( binShDirectory, "variables.sh" ), false );
// Removing the redundant server.xml file (see DIRSERVER-1112)
new File( binRootFolderServerDirectory, "conf/server.xml" ).delete();
}
catch ( IOException e )
{
log.error( e.getMessage() );
throw new MojoFailureException( "Failed to copy Bin resources files." );
}
// Generating the Bin
log.info( "Generating Bin Installer" );
Execute createBinTask = new Execute();
String[] cmd = new String[]
{ shUtility.getAbsolutePath(), "createInstaller.sh" };
createBinTask.setCommandline( cmd );
createBinTask.setSpawn( true );
createBinTask.setWorkingDirectory( binDirectory );
try
{
createBinTask.execute();
}
catch ( IOException e )
{
log.error( e.getMessage() );
throw new MojoFailureException( "Failed while trying to generate the Bin: " + e.getMessage() );
}
log.info( "Bin Installer generated at " + new File( imagesDirectory, finalName ) );
}