private static List < MavenCoordinates > getFeatureCompileDependencies ( File inputDir , LibertyFeature feature ) throws MavenRepoGeneratorException { List < MavenCoordinates > compileDependencies = new ArrayList < MavenCoordinates > ( ) ; File esa = new File ( inputDir , feature . getSymbolicName ( ) + Constants . ArtifactType . ESA . getLibertyFileExtension ( ) ) ; if ( ! esa . exists ( ) ) { throw new MavenRepoGeneratorException ( "ESA " + esa + " does not exist for feature " + feature . getSymbolicName ( ) ) ; } ZipFile zipFile = null ; try { zipFile = new ZipFile ( esa ) ; Enumeration < ? extends ZipEntry > entries = zipFile . entries ( ) ; while ( entries . hasMoreElements ( ) ) { ZipEntry zipEntry = entries . nextElement ( ) ; // find API dependencies in zip MavenCoordinates c = findCompileDependency ( zipEntry . getName ( ) , Constants . API_DEPENDENCIES_GROUP_ID ) ; if ( c != null ) { compileDependencies . add ( c ) ; continue ; } // find SPI dependencies in zip c = findCompileDependency ( zipEntry . getName ( ) , Constants . SPI_DEPENDENCIES_GROUP_ID ) ; if ( c != null ) { compileDependencies . add ( c ) ; continue ; } } // find Java spec dependencies from manifest ZipEntry manifest = zipFile . getEntry ( Constants . MANIFEST_ZIP_ENTRY ) ; if ( manifest != null ) { compileDependencies . addAll ( findCompileDependenciesFromManifest ( zipFile , manifest ) ) ; } else { throw new MavenRepoGeneratorException ( "Could not find manifest file " + Constants . MANIFEST_ZIP_ENTRY + " within the ESA file " + esa ) ; } } catch ( IOException e ) { throw new MavenRepoGeneratorException ( "ESA " + esa + " could not be read as a zip file." ) ; } finally { if ( zipFile != null ) { try { zipFile . close ( ) ; } catch ( IOException e ) { // nothing to do } } } return compileDependencies ; }
Get list of compile dependencies for each feature by looking in its ESA file .