Coverage Report - org.apache.maven.plugin.assembly.archive.phase.ModuleSetAssemblyPhase
 
Classes in this File Line Coverage Branch Coverage Complexity
ModuleSetAssemblyPhase
85%
175/205
63%
71/112
0
 
 1  
 package org.apache.maven.plugin.assembly.archive.phase;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.maven.artifact.Artifact;
 23  
 import org.apache.maven.artifact.ArtifactUtils;
 24  
 import org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
 25  
 import org.apache.maven.plugin.assembly.AssemblyContext;
 26  
 import org.apache.maven.plugin.assembly.InvalidAssemblerConfigurationException;
 27  
 import org.apache.maven.plugin.assembly.archive.ArchiveCreationException;
 28  
 import org.apache.maven.plugin.assembly.archive.task.AddArtifactTask;
 29  
 import org.apache.maven.plugin.assembly.archive.task.AddDependencySetsTask;
 30  
 import org.apache.maven.plugin.assembly.archive.task.AddFileSetsTask;
 31  
 import org.apache.maven.plugin.assembly.format.AssemblyFormattingException;
 32  
 import org.apache.maven.plugin.assembly.model.Assembly;
 33  
 import org.apache.maven.plugin.assembly.model.DependencySet;
 34  
 import org.apache.maven.plugin.assembly.model.FileSet;
 35  
 import org.apache.maven.plugin.assembly.model.ModuleBinaries;
 36  
 import org.apache.maven.plugin.assembly.model.ModuleSet;
 37  
 import org.apache.maven.plugin.assembly.model.ModuleSources;
 38  
 import org.apache.maven.plugin.assembly.utils.AssemblyFormatUtils;
 39  
 import org.apache.maven.plugin.assembly.utils.FilterUtils;
 40  
 import org.apache.maven.plugin.assembly.utils.ProjectUtils;
 41  
 import org.apache.maven.plugin.assembly.utils.TypeConversionUtils;
 42  
 import org.apache.maven.project.MavenProject;
 43  
 import org.apache.maven.project.MavenProjectBuilder;
 44  
 import org.codehaus.plexus.archiver.Archiver;
 45  
 import org.codehaus.plexus.archiver.manager.ArchiverManager;
 46  
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 47  
 import org.codehaus.plexus.logging.Logger;
 48  
 
 49  
 import java.io.File;
 50  
 import java.io.IOException;
 51  
 import java.util.ArrayList;
 52  
 import java.util.Collections;
 53  
 import java.util.HashMap;
 54  
 import java.util.Iterator;
 55  
 import java.util.LinkedHashSet;
 56  
 import java.util.List;
 57  
 import java.util.Map;
 58  
 import java.util.Set;
 59  
 
 60  
 /**
 61  
  * Handles the <moduleSets/> top-level section of the assembly descriptor.
 62  
  * 
 63  
  * @version $Id: ModuleSetAssemblyPhase.java 1002307 2010-09-28 18:13:44Z jdcasey $
 64  
  * @plexus.component role="org.apache.maven.plugin.assembly.archive.phase.AssemblyArchiverPhase" role-hint="module-sets"
 65  
  */
 66  
 public class ModuleSetAssemblyPhase
 67  
     extends AbstractLogEnabled
 68  
     implements AssemblyArchiverPhase
 69  
 {
 70  
 
 71  
     /**
 72  
      * @plexus.requirement
 73  
      */
 74  
     private MavenProjectBuilder projectBuilder;
 75  
 
 76  
     /**
 77  
      * @plexus.requirement
 78  
      */
 79  
     private ArchiverManager archiverManager;
 80  
 
 81  
     public ModuleSetAssemblyPhase()
 82  0
     {
 83  
         // needed for plexus
 84  0
     }
 85  
 
 86  
     public ModuleSetAssemblyPhase( final MavenProjectBuilder projectBuilder, final Logger logger )
 87  21
     {
 88  21
         this.projectBuilder = projectBuilder;
 89  21
         enableLogging( logger );
 90  21
     }
 91  
 
 92  
     /**
 93  
      * {@inheritDoc}
 94  
      */
 95  
     public void execute( final Assembly assembly, final Archiver archiver,
 96  
                          final AssemblerConfigurationSource configSource, final AssemblyContext context )
 97  
         throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException
 98  
     {
 99  2
         final List<ModuleSet> moduleSets = assembly.getModuleSets();
 100  
 
 101  2
         for ( final Iterator<ModuleSet> i = moduleSets.iterator(); i.hasNext(); )
 102  
         {
 103  1
             final ModuleSet moduleSet = i.next();
 104  
 
 105  1
             validate( moduleSet, configSource );
 106  
 
 107  1
             final Set<MavenProject> moduleProjects = getModuleProjects( moduleSet, configSource, getLogger() );
 108  
 
 109  1
             final ModuleSources sources = moduleSet.getSources();
 110  1
             addModuleSourceFileSets( sources, moduleProjects, archiver, configSource );
 111  
 
 112  1
             final ModuleBinaries binaries = moduleSet.getBinaries();
 113  1
             addModuleBinaries( binaries, moduleProjects, archiver, configSource, context );
 114  1
         }
 115  2
     }
 116  
 
 117  
     private void validate( final ModuleSet moduleSet, final AssemblerConfigurationSource configSource )
 118  
     {
 119  1
         if ( ( moduleSet.getSources() == null ) && ( moduleSet.getBinaries() == null ) )
 120  
         {
 121  0
             getLogger().warn( "Encountered ModuleSet with no sources or binaries specified. Skipping." );
 122  
         }
 123  
 
 124  1
         if ( moduleSet.isUseAllReactorProjects() && !moduleSet.isIncludeSubModules() )
 125  
         {
 126  0
             getLogger().warn( "includeSubModules == false is incompatible with useAllReactorProjects. Ignoring."
 127  
                                               + "\n\nTo refactor, remove the <includeSubModules/> flag, and use the <includes/> "
 128  
                                               + "and <excludes/> sections to fine-tune the modules included." );
 129  
         }
 130  
 
 131  1
         final List<MavenProject> projects = configSource.getReactorProjects();
 132  1
         if ( projects != null && projects.size() > 1 && projects.indexOf( configSource.getProject() ) == 0
 133  
                         && moduleSet.getBinaries() != null )
 134  
         {
 135  0
             getLogger().warn( "[DEPRECATION] moduleSet/binaries section detected in root-project assembly."
 136  
                                               + "\n\nMODULE BINARIES MAY NOT BE AVAILABLE FOR THIS ASSEMBLY!"
 137  
                                               + "\n\n To refactor, move this assembly into a child project and use the flag "
 138  
                                               + "<useAllReactorProjects>true</useAllReactorProjects> in each moduleSet." );
 139  
         }
 140  
 
 141  1
         if ( moduleSet.getSources() != null )
 142  
         {
 143  0
             final ModuleSources sources = moduleSet.getSources();
 144  0
             if ( isDeprecatedModuleSourcesConfigPresent( sources ) )
 145  
             {
 146  0
                 getLogger().warn( "[DEPRECATION] Use of <moduleSources/> as a file-set is deprecated. "
 147  
                                                   + "Please use the <fileSets/> sub-element of <moduleSources/> instead." );
 148  
             }
 149  0
             else if ( !sources.isUseDefaultExcludes() )
 150  
             {
 151  0
                 getLogger().warn( "[DEPRECATION] Use of directoryMode, fileMode, or useDefaultExcludes "
 152  
                                                   + "elements directly within <moduleSources/> are all deprecated. "
 153  
                                                   + "Please use the <fileSets/> sub-element of <moduleSources/> instead." );
 154  
             }
 155  
         }
 156  1
     }
 157  
 
 158  
     protected void addModuleBinaries( final ModuleBinaries binaries, final Set<MavenProject> projects,
 159  
                                       final Archiver archiver, final AssemblerConfigurationSource configSource,
 160  
                                       final AssemblyContext context )
 161  
         throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException
 162  
     {
 163  8
         if ( binaries == null )
 164  
         {
 165  1
             return;
 166  
         }
 167  
 
 168  7
         final Set<MavenProject> moduleProjects = new LinkedHashSet<MavenProject>( projects );
 169  
 
 170  7
         for ( final Iterator<MavenProject> it = moduleProjects.iterator(); it.hasNext(); )
 171  
         {
 172  7
             final MavenProject project = it.next();
 173  
 
 174  7
             if ( "pom".equals( project.getPackaging() ) )
 175  
             {
 176  1
                 final String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
 177  
 
 178  1
                 getLogger().debug( "Excluding POM-packaging module: " + projectId );
 179  
 
 180  1
                 it.remove();
 181  
             }
 182  7
         }
 183  
 
 184  7
         final String classifier = binaries.getAttachmentClassifier();
 185  
 
 186  7
         final Map<MavenProject, Artifact> chosenModuleArtifacts = new HashMap<MavenProject, Artifact>();
 187  
 
 188  7
         for ( final Iterator<MavenProject> j = moduleProjects.iterator(); j.hasNext(); )
 189  
         {
 190  6
             final MavenProject project = j.next();
 191  
 
 192  6
             Artifact artifact = null;
 193  
 
 194  6
             if ( classifier == null )
 195  
             {
 196  4
                 getLogger().debug( "Processing binary artifact for module project: " + project.getId() );
 197  
 
 198  4
                 artifact = project.getArtifact();
 199  
             }
 200  
             else
 201  
             {
 202  2
                 getLogger().debug( "Processing binary attachment: " + classifier + " for module project: "
 203  
                                                    + project.getId() );
 204  
 
 205  
                 @SuppressWarnings( "unchecked" )
 206  2
                 final List<Artifact> attachments = project.getAttachedArtifacts();
 207  2
                 if ( ( attachments != null ) && !attachments.isEmpty() )
 208  
                 {
 209  1
                     for ( final Iterator<Artifact> attachmentIterator = attachments.iterator(); attachmentIterator.hasNext(); )
 210  
                     {
 211  1
                         final Artifact attachment = attachmentIterator.next();
 212  
 
 213  1
                         if ( classifier.equals( attachment.getClassifier() ) )
 214  
                         {
 215  1
                             artifact = attachment;
 216  1
                             break;
 217  
                         }
 218  0
                     }
 219  
                 }
 220  
 
 221  2
                 if ( artifact == null )
 222  
                 {
 223  1
                     throw new InvalidAssemblerConfigurationException( "Cannot find attachment with classifier: "
 224  
                                     + classifier + " in module project: " + project.getId()
 225  
                                     + ". Please exclude this module from the module-set." );
 226  
                 }
 227  
             }
 228  
 
 229  5
             chosenModuleArtifacts.put( project, artifact );
 230  5
             addModuleArtifact( artifact, project, archiver, configSource, binaries );
 231  5
         }
 232  
 
 233  6
         final List<DependencySet> depSets = getDependencySets( binaries );
 234  
 
 235  6
         if ( depSets != null )
 236  
         {
 237  6
             for ( final Iterator<DependencySet> it = depSets.iterator(); it.hasNext(); )
 238  
             {
 239  3
                 final DependencySet ds = it.next();
 240  
 
 241  
                 // NOTE: Disabling useProjectArtifact flag, since module artifact has already been handled!
 242  3
                 ds.setUseProjectArtifact( false );
 243  3
             }
 244  
 
 245  
             // FIXME: This will produce unpredictable results when module dependencies have a version conflict.
 246  6
             getLogger().warn( "NOTE: Currently, inclusion of module dependencies may produce unpredictable "
 247  
                                               + "results if a version conflict occurs." );
 248  
 
 249  6
             for ( final Iterator<MavenProject> it = moduleProjects.iterator(); it.hasNext(); )
 250  
             {
 251  5
                 final MavenProject moduleProject = it.next();
 252  
 
 253  5
                 getLogger().debug( "Processing binary dependencies for module project: " + moduleProject.getId() );
 254  
 
 255  5
                 final AddDependencySetsTask task =
 256  
                     new AddDependencySetsTask( depSets, context.getResolvedArtifacts(), moduleProject, projectBuilder,
 257  
                                                archiverManager, getLogger() );
 258  
 
 259  5
                 task.setModuleProject( moduleProject );
 260  5
                 task.setModuleArtifact( chosenModuleArtifacts.get( moduleProject ) );
 261  5
                 task.setDefaultOutputDirectory( binaries.getOutputDirectory() );
 262  5
                 task.setDefaultOutputFileNameMapping( binaries.getOutputFileNameMapping() );
 263  
 
 264  5
                 task.execute( archiver, configSource );
 265  5
             }
 266  
         }
 267  6
     }
 268  
 
 269  
     public static List<DependencySet> getDependencySets( final ModuleBinaries binaries )
 270  
     {
 271  8
         List<DependencySet> depSets = binaries.getDependencySets();
 272  
 
 273  8
         if ( ( ( depSets == null ) || depSets.isEmpty() ) && binaries.isIncludeDependencies() )
 274  
         {
 275  2
             final DependencySet impliedDependencySet = new DependencySet();
 276  
 
 277  2
             impliedDependencySet.setOutputDirectory( binaries.getOutputDirectory() );
 278  2
             impliedDependencySet.setOutputFileNameMapping( binaries.getOutputFileNameMapping() );
 279  2
             impliedDependencySet.setFileMode( binaries.getFileMode() );
 280  2
             impliedDependencySet.setDirectoryMode( binaries.getDirectoryMode() );
 281  2
             impliedDependencySet.setExcludes( binaries.getExcludes() );
 282  2
             impliedDependencySet.setIncludes( binaries.getIncludes() );
 283  2
             impliedDependencySet.setUnpack( binaries.isUnpack() );
 284  
             // unpackOptions is handled in the first stage of dependency-set handling, below.
 285  
 
 286  2
             depSets = Collections.singletonList( impliedDependencySet );
 287  
         }
 288  
 
 289  8
         return depSets;
 290  
     }
 291  
 
 292  
     // protected List<String> collectExcludesFromQueuedArtifacts( final Set visitedArtifacts, final List binaryExcludes
 293  
     // )
 294  
     // {
 295  
     // List excludes = binaryExcludes;
 296  
     //
 297  
     // if ( excludes == null )
 298  
     // {
 299  
     // excludes = new ArrayList();
 300  
     // }
 301  
     // else
 302  
     // {
 303  
     // excludes = new ArrayList( excludes );
 304  
     // }
 305  
     //
 306  
     // for ( final Iterator it = visitedArtifacts.iterator(); it.hasNext(); )
 307  
     // {
 308  
     // excludes.add( it.next() );
 309  
     // }
 310  
     //
 311  
     // return excludes;
 312  
     // }
 313  
 
 314  
     protected void addModuleArtifact( final Artifact artifact, final MavenProject project, final Archiver archiver,
 315  
                                       final AssemblerConfigurationSource configSource, final ModuleBinaries binaries )
 316  
         throws ArchiveCreationException, AssemblyFormattingException
 317  
     {
 318  7
         if ( artifact.getFile() == null )
 319  
         {
 320  1
             throw new ArchiveCreationException( "Artifact: " + artifact.getId()
 321  
                             + " (included by module) does not have an artifact with a file. "
 322  
                             + "Please ensure the package phase is run before the assembly is generated." );
 323  
         }
 324  
 
 325  6
         final AddArtifactTask task = new AddArtifactTask( artifact, getLogger() );
 326  
 
 327  6
         task.setFileNameMapping( binaries.getOutputFileNameMapping() );
 328  6
         task.setOutputDirectory( binaries.getOutputDirectory() );
 329  6
         task.setProject( project );
 330  6
         task.setModuleProject( project );
 331  6
         task.setModuleArtifact( artifact );
 332  
 
 333  6
         final int dirMode = TypeConversionUtils.modeToInt( binaries.getDirectoryMode(), getLogger() );
 334  6
         if ( dirMode != -1 )
 335  
         {
 336  0
             task.setDirectoryMode( dirMode );
 337  
         }
 338  
 
 339  6
         final int fileMode = TypeConversionUtils.modeToInt( binaries.getFileMode(), getLogger() );
 340  6
         if ( fileMode != -1 )
 341  
         {
 342  6
             task.setFileMode( fileMode );
 343  
         }
 344  
 
 345  6
         task.setUnpack( binaries.isUnpack() );
 346  
 
 347  6
         if ( binaries.isUnpack() && binaries.getUnpackOptions() != null )
 348  
         {
 349  0
             task.setIncludes( binaries.getUnpackOptions()
 350  
                                       .getIncludes() );
 351  0
             task.setExcludes( binaries.getUnpackOptions()
 352  
                                       .getExcludes() );
 353  
         }
 354  
 
 355  6
         task.execute( archiver, configSource );
 356  6
     }
 357  
 
 358  
     protected void addModuleSourceFileSets( final ModuleSources sources, final Set<MavenProject> moduleProjects,
 359  
                                             final Archiver archiver, final AssemblerConfigurationSource configSource )
 360  
         throws ArchiveCreationException, AssemblyFormattingException
 361  
     {
 362  3
         if ( sources == null )
 363  
         {
 364  2
             return;
 365  
         }
 366  
 
 367  1
         final List<FileSet> fileSets = new ArrayList<FileSet>();
 368  
 
 369  1
         if ( isDeprecatedModuleSourcesConfigPresent( sources ) )
 370  
         {
 371  0
             final FileSet fs = new FileSet();
 372  0
             fs.setOutputDirectory( sources.getOutputDirectory() );
 373  0
             fs.setIncludes( sources.getIncludes() );
 374  0
             fs.setExcludes( sources.getExcludes() );
 375  0
             fs.setUseDefaultExcludes( sources.isUseDefaultExcludes() );
 376  
 
 377  0
             fileSets.add( fs );
 378  
         }
 379  
 
 380  1
         List<FileSet> subFileSets = sources.getFileSets();
 381  
 
 382  1
         if ( ( subFileSets == null ) || subFileSets.isEmpty() )
 383  
         {
 384  0
             final FileSet fs = new FileSet();
 385  0
             fs.setDirectory( "src" );
 386  
 
 387  0
             subFileSets = Collections.singletonList( fs );
 388  
         }
 389  
 
 390  1
         fileSets.addAll( subFileSets );
 391  
 
 392  1
         for ( final Iterator<MavenProject> j = moduleProjects.iterator(); j.hasNext(); )
 393  
         {
 394  1
             final MavenProject moduleProject = j.next();
 395  
 
 396  1
             getLogger().info( "Processing sources for module project: " + moduleProject.getId() );
 397  
 
 398  1
             final List<FileSet> moduleFileSets = new ArrayList<FileSet>();
 399  
 
 400  1
             for ( final Iterator<FileSet> fsIterator = fileSets.iterator(); fsIterator.hasNext(); )
 401  
             {
 402  1
                 final FileSet fileSet = fsIterator.next();
 403  
 
 404  1
                 moduleFileSets.add( createFileSet( fileSet, sources, moduleProject, configSource ) );
 405  1
             }
 406  
 
 407  1
             final AddFileSetsTask task = new AddFileSetsTask( moduleFileSets );
 408  
 
 409  1
             task.setProject( moduleProject );
 410  1
             task.setModuleProject( moduleProject );
 411  1
             task.setLogger( getLogger() );
 412  
 
 413  1
             task.execute( archiver, configSource );
 414  1
         }
 415  1
     }
 416  
 
 417  
     /**
 418  
      * Determine whether the deprecated file-set configuration directly within the ModuleSources object is present.
 419  
      */
 420  
     protected boolean isDeprecatedModuleSourcesConfigPresent( final ModuleSources sources )
 421  
     {
 422  6
         boolean result = false;
 423  
 
 424  6
         if ( sources.getOutputDirectory() != null )
 425  
         {
 426  1
             result = true;
 427  
         }
 428  5
         else if ( ( sources.getIncludes() != null ) && !sources.getIncludes()
 429  
                                                                .isEmpty() )
 430  
         {
 431  1
             result = true;
 432  
         }
 433  4
         else if ( ( sources.getExcludes() != null ) && !sources.getExcludes()
 434  
                                                                .isEmpty() )
 435  
         {
 436  1
             result = true;
 437  
         }
 438  
 
 439  6
         return result;
 440  
     }
 441  
 
 442  
     protected FileSet createFileSet( final FileSet fileSet, final ModuleSources sources,
 443  
                                      final MavenProject moduleProject, final AssemblerConfigurationSource configSource )
 444  
         throws AssemblyFormattingException
 445  
     {
 446  4
         final FileSet fs = new FileSet();
 447  
 
 448  4
         String sourcePath = fileSet.getDirectory();
 449  
 
 450  4
         final File moduleBasedir = moduleProject.getBasedir();
 451  
 
 452  4
         if ( sourcePath != null )
 453  
         {
 454  1
             final File sourceDir = new File( sourcePath );
 455  
 
 456  1
             if ( !sourceDir.isAbsolute() )
 457  
             {
 458  0
                 sourcePath = new File( moduleBasedir, sourcePath ).getAbsolutePath();
 459  
             }
 460  1
         }
 461  
         else
 462  
         {
 463  3
             sourcePath = moduleBasedir.getAbsolutePath();
 464  
         }
 465  
 
 466  4
         fs.setDirectory( sourcePath );
 467  4
         fs.setDirectoryMode( fileSet.getDirectoryMode() );
 468  
 
 469  4
         final List<String> excludes = new ArrayList<String>();
 470  
 
 471  4
         final List<String> originalExcludes = fileSet.getExcludes();
 472  4
         if ( ( originalExcludes != null ) && !originalExcludes.isEmpty() )
 473  
         {
 474  0
             excludes.addAll( originalExcludes );
 475  
         }
 476  
 
 477  4
         if ( sources.isExcludeSubModuleDirectories() )
 478  
         {
 479  
             @SuppressWarnings( "unchecked" )
 480  4
             final List<String> modules = moduleProject.getModules();
 481  4
             for ( final Iterator<String> moduleIterator = modules.iterator(); moduleIterator.hasNext(); )
 482  
             {
 483  1
                 final String moduleSubPath = moduleIterator.next();
 484  
 
 485  1
                 excludes.add( moduleSubPath + "/**" );
 486  1
             }
 487  
         }
 488  
 
 489  4
         fs.setExcludes( excludes );
 490  4
         fs.setFiltered( fileSet.isFiltered() );
 491  4
         fs.setFileMode( fileSet.getFileMode() );
 492  4
         fs.setIncludes( fileSet.getIncludes() );
 493  4
         fs.setLineEnding( fileSet.getLineEnding() );
 494  
 
 495  4
         String destPathPrefix = "";
 496  4
         if ( sources.isIncludeModuleDirectory() )
 497  
         {
 498  4
             destPathPrefix =
 499  
                 AssemblyFormatUtils.evaluateFileNameMapping( sources.getOutputDirectoryMapping(),
 500  
                                                              moduleProject.getArtifact(), configSource.getProject(),
 501  
                                                              moduleProject, moduleProject.getArtifact(), moduleProject,
 502  
                                                              configSource );
 503  
 
 504  4
             if ( !destPathPrefix.endsWith( "/" ) )
 505  
             {
 506  4
                 destPathPrefix += "/";
 507  
             }
 508  
         }
 509  
 
 510  4
         String destPath = fileSet.getOutputDirectory();
 511  
 
 512  4
         if ( destPath == null )
 513  
         {
 514  3
             destPath = destPathPrefix;
 515  
         }
 516  
         else
 517  
         {
 518  1
             destPath = destPathPrefix + destPath;
 519  
         }
 520  
 
 521  4
         destPath =
 522  
             AssemblyFormatUtils.getOutputDirectory( destPath, configSource.getProject(), moduleProject, moduleProject,
 523  
                                                     configSource.getFinalName(), configSource );
 524  
 
 525  4
         fs.setOutputDirectory( destPath );
 526  
 
 527  4
         getLogger().debug( "module source directory is: " + sourcePath );
 528  4
         getLogger().debug( "module dest directory is: " + destPath + " (assembly basedir may be prepended)" );
 529  
 
 530  4
         return fs;
 531  
     }
 532  
 
 533  
     public static Set<MavenProject> getModuleProjects( final ModuleSet moduleSet,
 534  
                                                        final AssemblerConfigurationSource configSource,
 535  
                                                        final Logger logger )
 536  
         throws ArchiveCreationException
 537  
     {
 538  8
         MavenProject project = configSource.getProject();
 539  8
         Set<MavenProject> moduleProjects = null;
 540  
 
 541  8
         if ( moduleSet.isUseAllReactorProjects() )
 542  
         {
 543  0
             if ( !moduleSet.isIncludeSubModules() )
 544  
             {
 545  0
                 moduleProjects = new LinkedHashSet<MavenProject>( configSource.getReactorProjects() );
 546  
             }
 547  
 
 548  0
             project = configSource.getReactorProjects()
 549  
                                   .get( 0 );
 550  
         }
 551  
 
 552  8
         if ( moduleProjects == null )
 553  
         {
 554  
             try
 555  
             {
 556  8
                 moduleProjects =
 557  
                     ProjectUtils.getProjectModules( project, configSource.getReactorProjects(),
 558  
                                                     moduleSet.isIncludeSubModules(), logger );
 559  
             }
 560  0
             catch ( final IOException e )
 561  
             {
 562  0
                 throw new ArchiveCreationException( "Error retrieving module-set for project: " + project.getId()
 563  
                                 + ": " + e.getMessage(), e );
 564  8
             }
 565  
         }
 566  
 
 567  8
         FilterUtils.filterProjects( moduleProjects, moduleSet.getIncludes(), moduleSet.getExcludes(), true, logger );
 568  8
         return moduleProjects;
 569  
     }
 570  
 
 571  
 }