Search in sources :

Example 1 with Library

use of org.springframework.boot.loader.tools.Library in project spring-boot by spring-projects.

the class ArtifactsLibraries method doWithLibraries.

@Override
public void doWithLibraries(LibraryCallback callback) throws IOException {
    Set<String> duplicates = getDuplicates(this.artifacts);
    for (Artifact artifact : this.artifacts) {
        LibraryScope scope = SCOPES.get(artifact.getScope());
        if (scope != null && artifact.getFile() != null) {
            String name = getFileName(artifact);
            if (duplicates.contains(name)) {
                this.log.debug("Duplicate found: " + name);
                name = artifact.getGroupId() + "-" + name;
                this.log.debug("Renamed to: " + name);
            }
            callback.library(new Library(name, artifact.getFile(), scope, isUnpackRequired(artifact)));
        }
    }
}
Also used : Library(org.springframework.boot.loader.tools.Library) LibraryScope(org.springframework.boot.loader.tools.LibraryScope) Artifact(org.apache.maven.artifact.Artifact)

Example 2 with Library

use of org.springframework.boot.loader.tools.Library in project spring-boot by spring-projects.

the class ArtifactsLibrariesTests method callbackForJars.

@Test
public void callbackForJars() throws Exception {
    given(this.artifact.getType()).willReturn("jar");
    given(this.artifact.getScope()).willReturn("compile");
    this.libs.doWithLibraries(this.callback);
    verify(this.callback).library(this.libraryCaptor.capture());
    Library library = this.libraryCaptor.getValue();
    assertThat(library.getFile()).isEqualTo(this.file);
    assertThat(library.getScope()).isEqualTo(LibraryScope.COMPILE);
    assertThat(library.isUnpackRequired()).isFalse();
}
Also used : Library(org.springframework.boot.loader.tools.Library) Test(org.junit.Test)

Aggregations

Library (org.springframework.boot.loader.tools.Library)2 Artifact (org.apache.maven.artifact.Artifact)1 Test (org.junit.Test)1 LibraryScope (org.springframework.boot.loader.tools.LibraryScope)1