private static List < MavenCoordinates > findCompileDependenciesFromManifest ( ZipFile zipFile , ZipEntry zipEntry ) throws MavenRepoGeneratorException { List < MavenCoordinates > result = new ArrayList < MavenCoordinates > ( ) ; InputStream inputStream = null ; try { inputStream = zipFile . getInputStream ( zipEntry ) ; Manifest manifest = new Manifest ( inputStream ) ; Attributes mainAttributes = manifest . getMainAttributes ( ) ; String subsystemContent = mainAttributes . getValue ( Constants . SUBSYSTEM_CONTENT ) ; List < String > lines = ManifestProcessor . split ( subsystemContent , "," ) ; for ( String line : lines ) { if ( line . contains ( Constants . SUBSYSTEM_MAVEN_COORDINATES ) ) { List < String > components = ManifestProcessor . split ( line , ";" ) ; String requiredFeature = components . get ( 0 ) ; String mavenCoordinates = null ; for ( String component : components ) { if ( component . startsWith ( Constants . SUBSYSTEM_MAVEN_COORDINATES ) ) { mavenCoordinates = component . substring ( Constants . SUBSYSTEM_MAVEN_COORDINATES . length ( ) + 1 , component . length ( ) ) ; if ( mavenCoordinates . startsWith ( "\"" ) && mavenCoordinates . endsWith ( "\"" ) ) { mavenCoordinates = mavenCoordinates . substring ( 1 , mavenCoordinates . length ( ) - 1 ) ; } break ; } } if ( mavenCoordinates != null ) { try { result . add ( new MavenCoordinates ( mavenCoordinates ) ) ; System . out . println ( "Found compile dependency for subsystem content " + requiredFeature + ": " + mavenCoordinates ) ; } catch ( IllegalArgumentException e ) { throw new MavenRepoGeneratorException ( "Invalid Maven coordinates defined in subsystem content " + requiredFeature + " in the manifest for ESA file " + zipFile . getName ( ) , e ) ; } } else { throw new MavenRepoGeneratorException ( "For ESA " + zipFile . getName ( ) + ", found " + Constants . SUBSYSTEM_MAVEN_COORDINATES + " key in manifest but failed to parse it from the string: " + line ) ; } } } } catch ( IOException e ) { throw new MavenRepoGeneratorException ( "Could not read manifest file " + zipEntry . getName ( ) + " from ESA file " + zipFile . getName ( ) , e ) ; } finally { if ( inputStream != null ) { try { inputStream . close ( ) ; } catch ( IOException e ) { } } } return result ; }
Find compile dependencies from the manifest file in the ESA