public static void copyBundles ( AbstractWisdomMojo mojo , DependencyGraphBuilder graph , boolean transitive , boolean deployTestDependencies , boolean disableDefaultExclusions , Libraries libraries ) throws IOException { File applicationDirectory = new File ( mojo . getWisdomRootDirectory ( ) , "application" ) ; File runtimeDirectory = new File ( mojo . getWisdomRootDirectory ( ) , "runtime" ) ; File coreDirectory = new File ( mojo . getWisdomRootDirectory ( ) , "core" ) ; Set < Artifact > artifacts = getArtifactsToConsider ( mojo , graph , transitive , null ) ; for ( Artifact artifact : artifacts ) { // Is it an excluded dependency if ( ! disableDefaultExclusions && BundleExclusions . isExcluded ( artifact ) ) { mojo . getLog ( ) . info ( "Dependency " + artifact + " not copied - the artifact is on the exclusion list" ) ; continue ; } // We still have to do this test, as when using the direct dependencies we may include test and provided // dependencies. if ( SCOPE_COMPILE . equalsIgnoreCase ( artifact . getScope ( ) ) || deployTestDependencies && SCOPE_TEST . equalsIgnoreCase ( artifact . getScope ( ) ) ) { File file = artifact . getFile ( ) ; // Check it's a 'jar file' if ( file == null || ! file . getName ( ) . endsWith ( ".jar" ) ) { mojo . getLog ( ) . info ( "Dependency " + artifact + " not copied - it does not look like a jar " + "file" ) ; continue ; } // Do we already have this file in core or runtime ? File test = new File ( coreDirectory , file . getName ( ) ) ; if ( test . exists ( ) ) { mojo . getLog ( ) . info ( "Dependency " + file . getName ( ) + " not copied - already existing in `core`" ) ; continue ; } test = new File ( runtimeDirectory , file . getName ( ) ) ; if ( test . exists ( ) ) { mojo . getLog ( ) . info ( "Dependency " + file . getName ( ) + " not copied - already existing in `runtime`" ) ; continue ; } if ( libraries != null && libraries . hasLibraries ( ) && libraries . isExcludeFromApplication ( ) ) { if ( ! libraries . getReverseFilter ( ) . include ( artifact ) ) { mojo . getLog ( ) . info ( "Dependency " + file . getName ( ) + " not copied - excluded from the " + "libraries settings" ) ; continue ; } } // Check that it's a bundle. if ( isBundle ( file ) ) { File destination = new File ( applicationDirectory , DefaultMaven2OsgiConverter . getBundleFileName ( artifact ) ) ; mojo . getLog ( ) . info ( "Dependency " + file . getName ( ) + " is a bundle, " + "artifact copied to " + destination . getAbsolutePath ( ) ) ; FileUtils . copyFile ( file , destination , true ) ; } else { mojo . getLog ( ) . debug ( "Dependency " + file . getName ( ) + " is not a bundle" ) ; } } } }
Copies dependencies that are bundles to the application directory . If the bundle is already in core or runtime the bundle is not copied .