directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r378619 - in /directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers: CreateImageCommand.java MojoCommand.java ServiceInstallersMojo.java Target.java
Date Fri, 17 Feb 2006 20:28:39 GMT
Author: akarasulu
Date: Fri Feb 17 12:28:37 2006
New Revision: 378619

URL: http://svn.apache.org/viewcvs?rev=378619&view=rev
Log:
making the packagedFile tags work right for artifacts to be expanded

Modified:
    directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/CreateImageCommand.java
    directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/MojoCommand.java
    directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java
    directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/Target.java

Modified: directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/CreateImageCommand.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/CreateImageCommand.java?rev=378619&r1=378618&r2=378619&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/CreateImageCommand.java
(original)
+++ directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/CreateImageCommand.java
Fri Feb 17 12:28:37 2006
@@ -78,6 +78,7 @@
     public void execute() throws MojoExecutionException, MojoFailureException
     {
         // make the layout directories
+        log.info( "Creating image ... " );
         File dir = new File( mymojo.getOutputDirectory(), target.getId() );
         layout = new InstallationLayout( dir );
         target.setLayout( layout );

Modified: directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/MojoCommand.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/MojoCommand.java?rev=378619&r1=378618&r2=378619&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/MojoCommand.java
(original)
+++ directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/MojoCommand.java
Fri Feb 17 12:28:37 2006
@@ -62,6 +62,18 @@
     }
     
     
+    public void reportProcessing( PackagedFile packagedFile )
+    {
+        if ( ! log.isInfoEnabled() )
+        {
+            return;
+        }
+        
+        log.info( "\t\tProcessing packagedFile with source " + packagedFile.getSource() +
" for destination " 
+            + packagedFile.getDestinationPath() ); 
+    }
+    
+    
     public void processPackagedFiles( Target target, PackagedFile[] packagedFiles ) throws
MojoFailureException
     {
         if ( packagedFiles == null )
@@ -69,89 +81,109 @@
             return;
         }
         
+        if ( log.isInfoEnabled() )
+        {
+            log.info( "\tProcessing " + packagedFiles.length + " packagedFiles: " );
+        }
+        
         for ( int ii = 0; ii < packagedFiles.length; ii++ )
         {
             File source = null;
+            reportProcessing( packagedFiles[ii ] );
 
-            if ( packagedFiles[ii].isDependency() )
-            {
-                Artifact artifact = ( Artifact ) dependencyMap.get( packagedFiles[ii].getSource()
);
-                source = artifact.getFile().getAbsoluteFile();
-            }
-            else
-            {
-                source = new File( packagedFiles[ii].getSource() );
-            }
-            
-            if ( ! source.isAbsolute() )
+            try
             {
-                File sourceDirectoryRelative = new File( mymojo.getSourceDirectory(), packagedFiles[ii].getSource()
);
-                File baseRelative = new File( mymojo.getProject().getBasedir(), packagedFiles[ii].getSource()
);
-                if ( sourceDirectoryRelative.exists() )
+                if ( packagedFiles[ii].isDependency() )
                 {
-                    source = sourceDirectoryRelative;
+                    Artifact artifact = ( Artifact ) dependencyMap.get( packagedFiles[ii].getSource()
);
+                    source = artifact.getFile().getAbsoluteFile();
                 }
-                else if ( baseRelative.exists() )
+                else
                 {
-                    source = baseRelative;
+                    source = new File( packagedFiles[ii].getSource() );
                 }
-                else if ( ! source.exists() )
+                
+                if ( ! source.isAbsolute() )
                 {
-                    throw new MojoFailureException( "Failed to copy packagedFile. Cannot
locate source: " + source );
+                    File sourceDirectoryRelative = new File( mymojo.getSourceDirectory(),
packagedFiles[ii].getSource() );
+                    File baseRelative = new File( mymojo.getProject().getBasedir(), packagedFiles[ii].getSource()
);
+                    if ( sourceDirectoryRelative.exists() )
+                    {
+                        source = sourceDirectoryRelative;
+                    }
+                    else if ( baseRelative.exists() )
+                    {
+                        source = baseRelative;
+                    }
+                    else if ( ! source.exists() )
+                    {
+                        throw new MojoFailureException( "Failed to copy packagedFile. Cannot
locate source: " + source );
+                    }
+                    
+                    source = source.getAbsoluteFile();
+                }
+                
+                if ( packagedFiles[ii].isExpandable() )
+                {
+                    File dest = new File( target.getLayout().getBaseDirectory(), packagedFiles[ii].getDestinationPath()
);
+                    if ( ! dest.exists() )
+                    {
+                        dest.mkdirs();
+                    }
+                    
+                    String fileExtension = source.getName().substring( source.getName().lastIndexOf(
'.' ) );
+                    if ( fileExtension.equalsIgnoreCase( ".jar" ) || fileExtension.equalsIgnoreCase(
".zip" ) 
+                        || fileExtension.equalsIgnoreCase( ".war" ) || fileExtension.equalsIgnoreCase(
".sar" ) )
+                    {
+                        log.info( "\t\t\t ... expanding " + source  + "\n\t\t\t => to
" + dest );
+                        Expand expand = new Expand();
+                        expand.setSrc( source );
+                        expand.setOverwrite( true );
+                        expand.setDest( dest );
+                        try
+                        {
+                            expand.execute();
+                            continue;
+                        }
+                        catch ( Exception e )
+                        {
+                            throw new MojoFailureException( "Failed to expaned packagedFile
" + source + ": " + e.getMessage() );
+                        }
+                    }
+                    
+                    throw new MojoFailureException( "Failed to expand packagedFile: " + source

+                        + ". It does not have a jar, war or zip extension" );
                 }
                 
-                source = source.getAbsoluteFile();
-            }
-            
-            if ( packagedFiles[ii].isExpandable() )
-            {
                 File dest = new File( target.getLayout().getBaseDirectory(), packagedFiles[ii].getDestinationPath()
);
-                String fileExtension = source.getName().substring( source.getName().lastIndexOf(
'.' ) );
-                if ( fileExtension.equalsIgnoreCase( ".jar" ) || fileExtension.equalsIgnoreCase(
".zip" ) )
+                if ( packagedFiles[ii].isFiltered() )
                 {
-                    Expand expand = new Expand();
-                    expand.setSrc( source );
-                    expand.setOverwrite( true );
-                    expand.setDest( dest );
                     try
                     {
-                        expand.execute();
-                        return;
+                        MojoHelperUtils.copyAsciiFile( mymojo, getFilterProperties(), source,
dest, true );
                     }
-                    catch ( Exception e )
+                    catch ( IOException e )
                     {
-                        throw new MojoFailureException( "Failed to expaned packagedFile "
+ source + ": " + e.getMessage() );
+                        throw new MojoFailureException( "Failed to copy packagedFile from
source " + source +
+                            " to destination " + dest );
                     }
+                    
+                    return;
                 }
                 
-                throw new MojoFailureException( "Failed to expand packagedFile: " + source

-                    + ". It does not have a jar or zip extension" );
-            }
-            
-            File dest = new File( target.getLayout().getBaseDirectory(), packagedFiles[ii].getDestinationPath()
);
-            if ( packagedFiles[ii].isFiltered() )
-            {
                 try
                 {
-                    MojoHelperUtils.copyAsciiFile( mymojo, getFilterProperties(), source,
dest, true );
+                    FileUtils.copyFile( source, dest );
                 }
                 catch ( IOException e )
                 {
                     throw new MojoFailureException( "Failed to copy packagedFile from source
" + source +
                         " to destination " + dest );
                 }
-                
-                return;
-            }
-            
-            try
-            {
-                FileUtils.copyFile( source, dest );
             }
-            catch ( IOException e )
+            catch ( Exception e ) 
             {
-                throw new MojoFailureException( "Failed to copy packagedFile from source
" + source +
-                    " to destination " + dest );
+                log.error( "Failed while processing " + source, e );
             }
         }
     }

Modified: directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java?rev=378619&r1=378618&r2=378619&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java
(original)
+++ directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java
Fri Feb 17 12:28:37 2006
@@ -54,7 +54,7 @@
  * @version $Rev$
  */
 public class ServiceInstallersMojo extends AbstractMojo
-{
+{ 
     static final String BOOTSTRAPPER_ARTIFACT_ID = "daemon-bootstrappers";
     static final String BOOTSTRAPPER_GROUP_ID = "org.apache.directory.daemon";
     static final String LOGGER_ARTIFACT_ID = "nlog4j";

Modified: directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/Target.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/Target.java?rev=378619&r1=378618&r2=378619&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/Target.java
(original)
+++ directory/sandbox/akarasulu/rc1/daemon/plugin/src/main/java/org/apache/directory/daemon/installers/Target.java
Fri Feb 17 12:28:37 2006
@@ -78,7 +78,8 @@
     private List libArtifacts;
 
     private Application application;
-    private PackagedFile[] packagedFiles;
+    
+    protected PackagedFile[] packagedFiles;
     
 
     public void setApplication( Application application )



Mime
View raw message