Commit 948bafa4 authored by Andy Wilkinson's avatar Andy Wilkinson

Repackage kotlin-module metadata beneath BOOT-INF/classes

Closes gh-15890
parent 3a6d15ac
...@@ -380,7 +380,8 @@ public class Repackager { ...@@ -380,7 +380,8 @@ public class Repackager {
return null; return null;
} }
if ((entry.getName().startsWith("META-INF/") if ((entry.getName().startsWith("META-INF/")
&& !entry.getName().equals("META-INF/aop.xml")) && !entry.getName().equals("META-INF/aop.xml")
&& !entry.getName().endsWith(".kotlin-module"))
|| entry.getName().startsWith("BOOT-INF/") || entry.getName().startsWith("BOOT-INF/")
|| entry.getName().equals("module-info.class")) { || entry.getName().equals("module-info.class")) {
return entry; return entry;
......
...@@ -675,6 +675,23 @@ public class RepackagerTests { ...@@ -675,6 +675,23 @@ public class RepackagerTests {
} }
} }
@Test
public void kotlinModuleMetadataMovesBeneathBootInfClassesWhenRepackaged()
throws Exception {
this.testJarFile.addClass("A.class", ClassWithMainMethod.class);
this.testJarFile.addFile("META-INF/test.kotlin-module",
this.temporaryFolder.newFile("test.kotlin-module"));
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("META-INF/test.kotlin-module")).isNull();
assertThat(jarFile.getEntry("BOOT-INF/classes/META-INF/test.kotlin-module"))
.isNotNull();
}
}
private File createLibrary() throws IOException { private File createLibrary() throws IOException {
TestJarFile library = new TestJarFile(this.temporaryFolder); TestJarFile library = new TestJarFile(this.temporaryFolder);
library.addClass("com/example/library/Library.class", library.addClass("com/example/library/Library.class",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment