Merge branch '2.1.x'
This commit is contained in:
commit
342bced125
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -55,13 +55,15 @@ public class BootJar extends Jar implements BootArchive {
|
||||||
getMainSpec().with(this.bootInf);
|
getMainSpec().with(this.bootInf);
|
||||||
this.bootInf.into("classes", classpathFiles(File::isDirectory));
|
this.bootInf.into("classes", classpathFiles(File::isDirectory));
|
||||||
this.bootInf.into("lib", classpathFiles(File::isFile));
|
this.bootInf.into("lib", classpathFiles(File::isFile));
|
||||||
|
this.bootInf.filesMatching("module-info.class", (details) -> {
|
||||||
|
details.setRelativePath(details.getRelativeSourcePath());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Action<CopySpec> classpathFiles(Spec<File> filter) {
|
private Action<CopySpec> classpathFiles(Spec<File> filter) {
|
||||||
return (copySpec) -> copySpec
|
return (copySpec) -> copySpec
|
||||||
.from((Callable<Iterable<File>>) () -> (this.classpath != null)
|
.from((Callable<Iterable<File>>) () -> (this.classpath != null)
|
||||||
? this.classpath.filter(filter) : Collections.emptyList());
|
? this.classpath.filter(filter) : Collections.emptyList());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -54,6 +54,9 @@ public class BootWar extends War implements BootArchive {
|
||||||
(copySpec) -> copySpec.from(
|
(copySpec) -> copySpec.from(
|
||||||
(Callable<Iterable<File>>) () -> (this.providedClasspath != null)
|
(Callable<Iterable<File>>) () -> (this.providedClasspath != null)
|
||||||
? this.providedClasspath : Collections.emptyList()));
|
? this.providedClasspath : Collections.emptyList()));
|
||||||
|
getRootSpec().filesMatching("module-info.class", (details) -> {
|
||||||
|
details.setRelativePath(details.getRelativeSourcePath());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -133,6 +133,30 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void moduleInfoClassIsPackagedInTheRootOfTheArchive() throws IOException {
|
||||||
|
this.task.setMainClassName("com.example.Main");
|
||||||
|
File classpathFolder = this.temp.newFolder();
|
||||||
|
File moduleInfoClass = new File(classpathFolder, "module-info.class");
|
||||||
|
moduleInfoClass.getParentFile().mkdirs();
|
||||||
|
moduleInfoClass.createNewFile();
|
||||||
|
File applicationClass = new File(classpathFolder,
|
||||||
|
"com/example/Application.class");
|
||||||
|
applicationClass.getParentFile().mkdirs();
|
||||||
|
applicationClass.createNewFile();
|
||||||
|
this.task.classpath(classpathFolder);
|
||||||
|
this.task.execute();
|
||||||
|
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||||
|
assertThat(
|
||||||
|
jarFile.getEntry(this.classesPath + "/com/example/Application.class"))
|
||||||
|
.isNotNull();
|
||||||
|
assertThat(jarFile.getEntry("com/example/Application.class")).isNull();
|
||||||
|
assertThat(jarFile.getEntry("module-info.class")).isNotNull();
|
||||||
|
assertThat(jarFile.getEntry(this.classesPath + "/module-info.class"))
|
||||||
|
.isNull();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void classpathCanBeSetUsingAFileCollection() throws IOException {
|
public void classpathCanBeSetUsingAFileCollection() throws IOException {
|
||||||
this.task.setMainClassName("com.example.Main");
|
this.task.setMainClassName("com.example.Main");
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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/")
|
if ((entry.getName().startsWith("META-INF/")
|
||||||
&& !entry.getName().equals("META-INF/aop.xml"))
|
&& !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;
|
return entry;
|
||||||
}
|
}
|
||||||
JarArchiveEntry renamedEntry = new JarArchiveEntry(
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
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 {
|
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",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue