Skip to content

Commit

Permalink
Inject MANIFEST.MF also for source jar files
Browse files Browse the repository at this point in the history
For Quarkus productization source jars are expected to have
META-INF/MANIFEST.MF files in them. Inject them when they're
not already there like we do for the actual jar artefact.
  • Loading branch information
jerboaa committed Mar 20, 2024
1 parent 77d917b commit 52303ab
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions build.java
Original file line number Diff line number Diff line change
Expand Up @@ -657,24 +657,29 @@ private BiConsumer<String, Path[]> amendOrCreateManifest(Options options, Tasks.
{
return (artifact, paths) ->
{
final Path jarPath = PathFinder.getFirstExisting(fs.mandrelRepo().resolve(paths[0]).toString(), artifact);
try (java.nio.file.FileSystem jarfs = FileSystems.newFileSystem(jarPath, this.getClass().getClassLoader()))
final String jarF = PathFinder.getFirstExisting(fs.mandrelRepo().resolve(paths[0]).toString(), artifact).toString();
final Path jarPath = Path.of(jarF);
final Path sourceJarPath = Path.of(jarF.replace(".jar", ".src.zip"));
for (Path jar: List.of( jarPath, sourceJarPath ))
{
Path metaInfPath = jarfs.getPath("/META-INF");
Path manifestPath = metaInfPath.resolve("MANIFEST.MF");
if (!Files.exists(manifestPath))
try (java.nio.file.FileSystem jarfs = FileSystems.newFileSystem(jar, this.getClass().getClassLoader()))
{
if (!Files.exists(metaInfPath))
Path metaInfPath = jarfs.getPath("/META-INF");
Path manifestPath = metaInfPath.resolve("MANIFEST.MF");
if (!Files.exists(manifestPath))
{
Files.createDirectory(metaInfPath);
if (!Files.exists(metaInfPath))
{
Files.createDirectory(metaInfPath);
}
Files.createFile(manifestPath);
}
Files.createFile(manifestPath);
Tasks.FileReplace.replace(new Tasks.FileReplace(manifestPath, amendManifest(options)), replace);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
Tasks.FileReplace.replace(new Tasks.FileReplace(manifestPath, amendManifest(options)), replace);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
};
}
Expand Down

0 comments on commit 52303ab

Please sign in to comment.