Leave module-info.class in root of archive when repackaging
Closes gh-15810
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -381,7 +381,8 @@ public class Repackager {
|
||||
}
|
||||
if ((entry.getName().startsWith("META-INF/")
|
||||
&& !entry.getName().equals("META-INF/aop.xml"))
|
||||
|| entry.getName().startsWith("BOOT-INF/")) {
|
||||
|| entry.getName().startsWith("BOOT-INF/")
|
||||
|| entry.getName().equals("module-info.class")) {
|
||||
return entry;
|
||||
}
|
||||
JarArchiveEntry renamedEntry = new JarArchiveEntry(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -661,6 +661,20 @@ public class RepackagerTests {
|
||||
repackager.repackage(dest, NO_LIBRARIES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void moduleInfoClassRemainsInRootOfJarWhenRepackaged() throws Exception {
|
||||
this.testJarFile.addClass("A.class", ClassWithMainMethod.class);
|
||||
this.testJarFile.addClass("module-info.class", ClassWithoutMainMethod.class);
|
||||
File source = this.testJarFile.getFile();
|
||||
File dest = this.temporaryFolder.newFile("dest.jar");
|
||||
Repackager repackager = new Repackager(source);
|
||||
repackager.repackage(dest, NO_LIBRARIES);
|
||||
try (JarFile jarFile = new JarFile(dest)) {
|
||||
assertThat(jarFile.getEntry("module-info.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("BOOT-INF/classes/module-info.class")).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
private File createLibrary() throws IOException {
|
||||
TestJarFile library = new TestJarFile(this.temporaryFolder);
|
||||
library.addClass("com/example/library/Library.class",
|
||||
|
||||
Reference in New Issue
Block a user