Example usage for org.springframework.boot.loader.tools Layout getLibraryDestination

List of usage examples for org.springframework.boot.loader.tools Layout getLibraryDestination

Introduction

In this page you can find the example usage for org.springframework.boot.loader.tools Layout getLibraryDestination.

Prototype

String getLibraryDestination(String libraryName, LibraryScope scope);

Source Link

Document

Returns the destination path for a given library.

Usage

From source file:org.springframework.boot.loader.tools.RepackagerTests.java

@Test
public void customLayout() throws Exception {
    TestJarFile libJar = new TestJarFile(this.temporaryFolder);
    libJar.addClass("a/b/C.class", ClassWithoutMainMethod.class);
    File libJarFile = libJar.getFile();
    this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
    File file = this.testJarFile.getFile();
    Repackager repackager = new Repackager(file);
    Layout layout = mock(Layout.class);
    LibraryScope scope = mock(LibraryScope.class);
    given(layout.getLauncherClassName()).willReturn("testLauncher");
    given(layout.getLibraryDestination(anyString(), eq(scope))).willReturn("test/");
    given(layout.getLibraryDestination(anyString(), eq(LibraryScope.COMPILE))).willReturn("test-lib/");
    repackager.setLayout(layout);/* w w  w.j  ava 2  s. c om*/
    repackager.repackage((callback) -> callback.library(new Library(libJarFile, scope)));
    assertThat(hasEntry(file, "test/" + libJarFile.getName())).isTrue();
    assertThat(getManifest(file).getMainAttributes().getValue("Spring-Boot-Lib")).isEqualTo("test-lib/");
    assertThat(getManifest(file).getMainAttributes().getValue("Main-Class")).isEqualTo("testLauncher");
}