Exclude Devtools by default and provide an option to include it

This commit is contained in:
Andy Wilkinson
2017-03-21 17:50:42 +00:00
parent d015714cba
commit 6e7e42459b
7 changed files with 130 additions and 10 deletions

View File

@@ -262,6 +262,31 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
assertThat(textFiles).containsExactly("alpha.txt", "bravo.txt", "charlie.txt");
}
@Test
public void devtoolsJarIsExcludedByDefault() throws IOException {
this.task.setMainClass("com.example.Main");
this.task.classpath(this.temp.newFile("spring-boot-devtools-0.1.2.jar"));
this.task.execute();
assertThat(this.task.getArchivePath().exists());
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
assertThat(jarFile.getEntry(this.libPath + "/spring-boot-devtools-0.1.2.jar"))
.isNull();
}
}
@Test
public void devtoolsJarCanBeIncluded() throws IOException {
this.task.setMainClass("com.example.Main");
this.task.classpath(this.temp.newFile("spring-boot-devtools-0.1.2.jar"));
this.task.setExcludeDevtools(false);
this.task.execute();
assertThat(this.task.getArchivePath().exists());
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
assertThat(jarFile.getEntry(this.libPath + "/spring-boot-devtools-0.1.2.jar"))
.isNotNull();
}
}
private T configure(T task) throws IOException {
AbstractArchiveTask archiveTask = task;
archiveTask.setBaseName("test");

View File

@@ -47,4 +47,33 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
}
}
@Test
public void devtoolsJarIsExcludedByDefaultWhenItsOnTheProvidedClasspath()
throws IOException {
getTask().setMainClass("com.example.Main");
getTask().providedClasspath(this.temp.newFile("spring-boot-devtools-0.1.2.jar"));
getTask().execute();
assertThat(getTask().getArchivePath().exists());
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
assertThat(jarFile
.getEntry("WEB-INF/lib-provided/spring-boot-devtools-0.1.2.jar"))
.isNull();
}
}
@Test
public void devtoolsJarCanBeIncludedWhenItsOnTheProvidedClasspath()
throws IOException {
getTask().setMainClass("com.example.Main");
getTask().providedClasspath(this.temp.newFile("spring-boot-devtools-0.1.2.jar"));
getTask().setExcludeDevtools(false);
getTask().execute();
assertThat(getTask().getArchivePath().exists());
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
assertThat(jarFile
.getEntry("WEB-INF/lib-provided/spring-boot-devtools-0.1.2.jar"))
.isNotNull();
}
}
}