Merge branch '2.7.x'
This commit is contained in:
@@ -179,19 +179,10 @@ class BootArchiveSupport {
|
||||
}
|
||||
|
||||
void moveModuleInfoToRoot(CopySpec spec) {
|
||||
spec.filesMatching("module-info.class", BootArchiveSupport::moveToRoot);
|
||||
spec.filesMatching("module-info.class", this::moveToRoot);
|
||||
}
|
||||
|
||||
void moveMetaInfToRoot(CopySpec spec) {
|
||||
spec.eachFile((file) -> {
|
||||
String path = file.getRelativeSourcePath().getPathString();
|
||||
if (path.startsWith("META-INF/") && !path.equals("META-INF/aop.xml") && !path.endsWith(".kotlin_module")) {
|
||||
moveToRoot(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void moveToRoot(FileCopyDetails details) {
|
||||
void moveToRoot(FileCopyDetails details) {
|
||||
details.setRelativePath(details.getRelativeSourcePath());
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class BootJar extends Jar implements BootArchive {
|
||||
bootInfSpec.into("classes", fromCallTo(this::classpathDirectories));
|
||||
bootInfSpec.into("lib", fromCallTo(this::classpathFiles)).eachFile(this.support::excludeNonZipFiles);
|
||||
this.support.moveModuleInfoToRoot(bootInfSpec);
|
||||
this.support.moveMetaInfToRoot(bootInfSpec);
|
||||
moveMetaInfToRoot(bootInfSpec);
|
||||
}
|
||||
|
||||
private Iterable<File> classpathDirectories() {
|
||||
@@ -110,6 +110,15 @@ public class BootJar extends Jar implements BootArchive {
|
||||
return (this.classpath != null) ? this.classpath.filter(filter) : Collections.emptyList();
|
||||
}
|
||||
|
||||
private void moveMetaInfToRoot(CopySpec spec) {
|
||||
spec.eachFile((file) -> {
|
||||
String path = file.getRelativeSourcePath().getPathString();
|
||||
if (path.startsWith("META-INF/") && !path.equals("META-INF/aop.xml") && !path.endsWith(".kotlin_module")) {
|
||||
this.support.moveToRoot(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy() {
|
||||
this.support.configureManifest(getManifest(), getMainClass().get(), CLASSES_DIRECTORY, LIB_DIRECTORY,
|
||||
|
||||
@@ -80,7 +80,6 @@ public class BootWar extends War implements BootArchive {
|
||||
this.layered = project.getObjects().newInstance(LayeredSpec.class);
|
||||
getWebInf().into("lib-provided", fromCallTo(this::getProvidedLibFiles));
|
||||
this.support.moveModuleInfoToRoot(getRootSpec());
|
||||
this.support.moveMetaInfToRoot(getRootSpec());
|
||||
getRootSpec().eachFile(this.support::excludeNonZipLibraryFiles);
|
||||
project.getConfigurations().all((configuration) -> {
|
||||
ResolvableDependencies incoming = configuration.getIncoming();
|
||||
|
||||
@@ -185,66 +185,6 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void metaInfEntryIsPackagedInTheRootOfTheArchive() throws IOException {
|
||||
this.task.getMainClass().set("com.example.Main");
|
||||
File classpathDirectory = new File(this.temp, "classes");
|
||||
File metaInfEntry = new File(classpathDirectory, "META-INF/test");
|
||||
metaInfEntry.getParentFile().mkdirs();
|
||||
metaInfEntry.createNewFile();
|
||||
File applicationClass = new File(classpathDirectory, "com/example/Application.class");
|
||||
applicationClass.getParentFile().mkdirs();
|
||||
applicationClass.createNewFile();
|
||||
this.task.classpath(classpathDirectory);
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry(this.classesPath + "com/example/Application.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("com/example/Application.class")).isNull();
|
||||
assertThat(jarFile.getEntry(this.classesPath + "META-INF/test")).isNull();
|
||||
assertThat(jarFile.getEntry("META-INF/test")).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aopXmlIsPackagedBeneathClassesDirectory() throws IOException {
|
||||
this.task.getMainClass().set("com.example.Main");
|
||||
File classpathDirectory = new File(this.temp, "classes");
|
||||
File aopXml = new File(classpathDirectory, "META-INF/aop.xml");
|
||||
aopXml.getParentFile().mkdirs();
|
||||
aopXml.createNewFile();
|
||||
File applicationClass = new File(classpathDirectory, "com/example/Application.class");
|
||||
applicationClass.getParentFile().mkdirs();
|
||||
applicationClass.createNewFile();
|
||||
this.task.classpath(classpathDirectory);
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry(this.classesPath + "com/example/Application.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("com/example/Application.class")).isNull();
|
||||
assertThat(jarFile.getEntry(this.classesPath + "META-INF/aop.xml")).isNotNull();
|
||||
assertThat(jarFile.getEntry("META-INF/aop.xml")).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void kotlinModuleIsPackagedBeneathClassesDirectory() throws IOException {
|
||||
this.task.getMainClass().set("com.example.Main");
|
||||
File classpathDirectory = new File(this.temp, "classes");
|
||||
File kotlinModule = new File(classpathDirectory, "META-INF/example.kotlin_module");
|
||||
kotlinModule.getParentFile().mkdirs();
|
||||
kotlinModule.createNewFile();
|
||||
File applicationClass = new File(classpathDirectory, "com/example/Application.class");
|
||||
applicationClass.getParentFile().mkdirs();
|
||||
applicationClass.createNewFile();
|
||||
this.task.classpath(classpathDirectory);
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry(this.classesPath + "com/example/Application.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("com/example/Application.class")).isNull();
|
||||
assertThat(jarFile.getEntry(this.classesPath + "META-INF/example.kotlin_module")).isNotNull();
|
||||
assertThat(jarFile.getEntry("META-INF/example.kotlin_module")).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void classpathCanBeSetUsingAFileCollection() throws IOException {
|
||||
this.task.getMainClass().set("com.example.Main");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -103,6 +103,66 @@ class BootJarTests extends AbstractBootArchiveTests<BootJar> {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void metaInfEntryIsPackagedInTheRootOfTheArchive() throws IOException {
|
||||
getTask().getMainClass().set("com.example.Main");
|
||||
File classpathDirectory = new File(this.temp, "classes");
|
||||
File metaInfEntry = new File(classpathDirectory, "META-INF/test");
|
||||
metaInfEntry.getParentFile().mkdirs();
|
||||
metaInfEntry.createNewFile();
|
||||
File applicationClass = new File(classpathDirectory, "com/example/Application.class");
|
||||
applicationClass.getParentFile().mkdirs();
|
||||
applicationClass.createNewFile();
|
||||
getTask().classpath(classpathDirectory);
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry("BOOT-INF/classes/com/example/Application.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("com/example/Application.class")).isNull();
|
||||
assertThat(jarFile.getEntry("BOOT-INF/classes/META-INF/test")).isNull();
|
||||
assertThat(jarFile.getEntry("META-INF/test")).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aopXmlIsPackagedBeneathClassesDirectory() throws IOException {
|
||||
getTask().getMainClass().set("com.example.Main");
|
||||
File classpathDirectory = new File(this.temp, "classes");
|
||||
File aopXml = new File(classpathDirectory, "META-INF/aop.xml");
|
||||
aopXml.getParentFile().mkdirs();
|
||||
aopXml.createNewFile();
|
||||
File applicationClass = new File(classpathDirectory, "com/example/Application.class");
|
||||
applicationClass.getParentFile().mkdirs();
|
||||
applicationClass.createNewFile();
|
||||
getTask().classpath(classpathDirectory);
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry("BOOT-INF/classes/com/example/Application.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("com/example/Application.class")).isNull();
|
||||
assertThat(jarFile.getEntry("BOOT-INF/classes/META-INF/aop.xml")).isNotNull();
|
||||
assertThat(jarFile.getEntry("META-INF/aop.xml")).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void kotlinModuleIsPackagedBeneathClassesDirectory() throws IOException {
|
||||
getTask().getMainClass().set("com.example.Main");
|
||||
File classpathDirectory = new File(this.temp, "classes");
|
||||
File kotlinModule = new File(classpathDirectory, "META-INF/example.kotlin_module");
|
||||
kotlinModule.getParentFile().mkdirs();
|
||||
kotlinModule.createNewFile();
|
||||
File applicationClass = new File(classpathDirectory, "com/example/Application.class");
|
||||
applicationClass.getParentFile().mkdirs();
|
||||
applicationClass.createNewFile();
|
||||
getTask().classpath(classpathDirectory);
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry("BOOT-INF/classes/com/example/Application.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("com/example/Application.class")).isNull();
|
||||
assertThat(jarFile.getEntry("BOOT-INF/classes/META-INF/example.kotlin_module")).isNotNull();
|
||||
assertThat(jarFile.getEntry("META-INF/example.kotlin_module")).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void applyLayered(Action<LayeredSpec> action) {
|
||||
getTask().layered(action);
|
||||
|
||||
Reference in New Issue
Block a user