diff --git a/core/src/main/java/org/jboss/migration/core/jboss/ManifestProductInfo.java b/core/src/main/java/org/jboss/migration/core/jboss/ManifestProductInfo.java index 8354c2594..9e904b7af 100644 --- a/core/src/main/java/org/jboss/migration/core/jboss/ManifestProductInfo.java +++ b/core/src/main/java/org/jboss/migration/core/jboss/ManifestProductInfo.java @@ -34,18 +34,12 @@ private ManifestProductInfo(String name, String version) { } /** - * Retrieves the product info from the specified's manifest inputstream. - * @param inputStream the inputstream to read the manifest file - * @return the product info from the specified's manifest inputstream + * Retrieves the product info from the specified manifest. + * @param manifest the manifest file + * @return the product info from the specified manifest inputstream * @throws ServerMigrationFailureException if there is an error reading the manifest input stream */ - public static ManifestProductInfo from(InputStream inputStream) throws ServerMigrationFailureException { - final Manifest manifest; - try { - manifest = new Manifest(inputStream); - } catch (IOException e) { - throw new ServerMigrationFailureException("MANIFEST load failure.", e); - } + public static ManifestProductInfo from(Manifest manifest) throws ServerMigrationFailureException { final String productName = manifest.getMainAttributes().getValue("JBoss-Product-Release-Name"); if (productName == null) { throw new IllegalArgumentException(); @@ -57,6 +51,20 @@ public static ManifestProductInfo from(InputStream inputStream) throws ServerMig return new ManifestProductInfo(productName.trim(), productVersion.trim()); } + /** + * Retrieves the product info from the specified's manifest inputstream. + * @param inputStream the inputstream to read the manifest file + * @return the product info from the specified's manifest inputstream + * @throws ServerMigrationFailureException if there is an error reading the manifest input stream + */ + public static ManifestProductInfo from(InputStream inputStream) throws ServerMigrationFailureException { + try { + return from(new Manifest(inputStream)); + } catch (IOException e) { + throw new ServerMigrationFailureException("MANIFEST stream load failure.", e); + } + } + /** * Retrieves the product info from the specified's manifest file path. * @param path the path pointing to the manifest file diff --git a/servers/eap8.0/src/main/java/org/jboss/migration/eap/EAPServerProvider8_0.java b/servers/eap8.0/src/main/java/org/jboss/migration/eap/EAPServerProvider8_0.java index efcbbf0e7..0f59e6bda 100644 --- a/servers/eap8.0/src/main/java/org/jboss/migration/eap/EAPServerProvider8_0.java +++ b/servers/eap8.0/src/main/java/org/jboss/migration/eap/EAPServerProvider8_0.java @@ -22,8 +22,10 @@ import org.jboss.migration.core.jboss.JBossServer; import org.jboss.migration.core.jboss.ManifestProductInfo; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.jar.JarInputStream; /** * The JBoss EAP 8.0 {@link org.jboss.migration.core.ServerProvider}. @@ -37,9 +39,18 @@ protected ProductInfo getProductInfo(Path baseDir, MigrationEnvironment migratio if (module == null) { return null; } - final Path manifestPath = module.getModuleDir().resolve("dir").resolve("META-INF").resolve("MANIFEST.MF"); - final ManifestProductInfo productInfo = ManifestProductInfo.from(manifestPath); - return productInfo; + // Starting with EAP 8.0 GA, manifest is inside the module's jar + try { + Path moduleJar = Files.list(module.getModuleDir()).filter(path -> path.toString().endsWith(".jar")).findFirst().get(); + if (moduleJar == null || !Files.isRegularFile(moduleJar)) { + return null; + } + try (JarInputStream jarStream = new JarInputStream(Files.newInputStream(moduleJar))) { + return ManifestProductInfo.from(jarStream.getManifest()); + } + } catch (IOException e) { + throw new ServerMigrationFailureException(e); + } } @Override