private void addLibsJarsToClassPath ( UnpackedLibHelper helper , MavenProject project , Artifact artifact ) throws MavenExecutionException { try { final File unpackLibFolder = helper . getUnpackedLibFolder ( artifact ) ; final File artifactFile = helper . getArtifactToFile ( artifact ) ; ZipFile zipFile = new ZipFile ( artifactFile ) ; Enumeration enumeration = zipFile . entries ( ) ; while ( enumeration . hasMoreElements ( ) ) { ZipEntry entry = ( ZipEntry ) enumeration . nextElement ( ) ; String entryName = entry . getName ( ) ; // Only jar files under 'libs' directory to be processed. if ( Pattern . matches ( "^libs/.+\\.jar$" , entryName ) ) { final File libsJarFile = new File ( unpackLibFolder , entryName ) ; log . warn ( "Adding jar from libs folder to classpath: " + libsJarFile ) ; // In order to satisfy the LifecycleDependencyResolver on execution up to a phase that // has a Mojo requiring dependency resolution I need to create a dummy classesJar here. if ( ! libsJarFile . getParentFile ( ) . exists ( ) ) { libsJarFile . getParentFile ( ) . mkdirs ( ) ; } libsJarFile . createNewFile ( ) ; // Add the jar to the classpath. final Dependency dependency = createSystemScopeDependency ( artifact , libsJarFile , libsJarFile . getName ( ) ) ; project . getModel ( ) . addDependency ( dependency ) ; addedJarFromLibs = true ; } } } catch ( MojoExecutionException e ) { log . debug ( "Error extract jars" ) ; } catch ( ZipException e ) { log . debug ( "Error" ) ; } catch ( IOException e ) { log . debug ( "Error" ) ; } }
Add jar files in libs into the project classpath .