Cleaned up API to match bld operations and options APIs
This commit is contained in:
parent
7b6e75d44c
commit
f340aed106
5 changed files with 284 additions and 41 deletions
|
@ -29,7 +29,10 @@ import java.io.StringWriter;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -89,6 +92,17 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
|||
return destinationDirectory(new File(directory));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the destination directory in which the archive will be created.
|
||||
*
|
||||
* @param directory the destination directory
|
||||
* @return this operation instance
|
||||
* @throws IOException if an error occurs
|
||||
*/
|
||||
public T destinationDirectory(Path directory) throws IOException {
|
||||
return destinationDirectory(directory.toFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the file name that will be used for the archive creation.
|
||||
*
|
||||
|
@ -275,9 +289,17 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
|||
* @return this operation instance
|
||||
*/
|
||||
public T infLibs(File... jars) {
|
||||
infLibs_.addAll(List.of(jars));
|
||||
//noinspection unchecked
|
||||
return (T) this;
|
||||
return infLibs(List.of(jars));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the libraries that will be stored in {@code BOOT-INF} or {@code WEB-INF}.
|
||||
*
|
||||
* @param jars one or more Java archive files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public T infLibs(Path... jars) {
|
||||
return infLibsPaths(List.of(jars));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,9 +309,7 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
|||
* @return this operation instance
|
||||
*/
|
||||
public T infLibs(String... jars) {
|
||||
infLibs_.addAll(Arrays.stream(jars).map(File::new).toList());
|
||||
//noinspection unchecked
|
||||
return (T) this;
|
||||
return infLibsStrings(List.of(jars));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -301,6 +321,26 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
|||
return infLibs_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the libraries that will be stored in {@code BOOT-INF} or {@code WEB-INF}.
|
||||
*
|
||||
* @param jars one or more Java archive files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public T infLibsPaths(Collection<Path> jars) {
|
||||
return infLibs(jars.stream().map(Path::toFile).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the libraries that will be stored in {@code BOOT-INF} or {@code WEB-INF}.
|
||||
*
|
||||
* @param jars one or more Java archive files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public T infLibsStrings(Collection<String> jars) {
|
||||
return infLibs(jars.stream().map(File::new).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the Spring Boot loader launcher fully-qualified class name.
|
||||
* <p>
|
||||
|
@ -367,17 +407,8 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
|||
* @return this operation instance
|
||||
* @throws IOException if a JAR could not be found
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public T launcherLibs(File... jars) throws IOException {
|
||||
for (var j : jars) {
|
||||
if (j.exists()) {
|
||||
launcherLibs_.add(j);
|
||||
} else {
|
||||
throw new IOException("Spring Boot loader launcher library not found: " + j);
|
||||
}
|
||||
}
|
||||
//noinspection unchecked
|
||||
return (T) this;
|
||||
return launcherLibs(List.of(jars));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -387,18 +418,41 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
|||
* @return this operation instance
|
||||
* @throws IOException if a JAR could not be found
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public T launcherLibs(String... jars) throws IOException {
|
||||
for (var j : jars) {
|
||||
var p = Path.of(j);
|
||||
if (Files.exists(p)) {
|
||||
launcherLibs_.add(p.toFile());
|
||||
} else {
|
||||
throw new IOException("Spring Boot loader launcher library not found: " + j);
|
||||
}
|
||||
}
|
||||
//noinspection unchecked
|
||||
return (T) this;
|
||||
return launcherLibsStrings(List.of(jars));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the libraries for the Spring Boot loader launcher.
|
||||
*
|
||||
* @param jars one or more Java archives
|
||||
* @return this operation instance
|
||||
* @throws IOException if a JAR could not be found
|
||||
*/
|
||||
public T launcherLibs(Path... jars) throws IOException {
|
||||
return launcherLibsPaths(List.of(jars));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the libraries for the Spring Boot loader launcher.
|
||||
*
|
||||
* @param jars one or more Java archives
|
||||
* @return this operation instance
|
||||
* @throws IOException if a JAR could not be found
|
||||
*/
|
||||
public T launcherLibsPaths(Collection<Path> jars) throws IOException {
|
||||
return launcherLibs(jars.stream().map(Path::toFile).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the libraries for the Spring Boot loader launcher.
|
||||
*
|
||||
* @param jars one or more Java archives
|
||||
* @return this operation instance
|
||||
* @throws IOException if a JAR could not be found
|
||||
*/
|
||||
public T launcherLibsStrings(Collection<String> jars) throws IOException {
|
||||
return launcherLibs(jars.stream().map(File::new).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -463,12 +517,22 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
|||
* @param directories one or more source directories
|
||||
* @return this operation instance
|
||||
*/
|
||||
public T sourceDirectories(File... directories) {
|
||||
sourceDirectories_.addAll(List.of(directories));
|
||||
public T sourceDirectories(Collection<File> directories) {
|
||||
sourceDirectories_.addAll(directories);
|
||||
//noinspection unchecked
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides source directories that will be used for the archive creation.
|
||||
*
|
||||
* @param directories one or more source directories
|
||||
* @return this operation instance
|
||||
*/
|
||||
public T sourceDirectories(File... directories) {
|
||||
return sourceDirectories(List.of(directories));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides source directories that will be used for the archive creation.
|
||||
*
|
||||
|
@ -476,9 +540,17 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
|||
* @return this operation instance
|
||||
*/
|
||||
public T sourceDirectories(String... directories) {
|
||||
sourceDirectories_.addAll(Arrays.stream(directories).map(File::new).toList());
|
||||
//noinspection unchecked
|
||||
return (T) this;
|
||||
return sourceDirectoriesStrings(List.of(directories));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides source directories that will be used for the archive creation.
|
||||
*
|
||||
* @param directories one or more source directories
|
||||
* @return this operation instance
|
||||
*/
|
||||
public T sourceDirectories(Path... directories) {
|
||||
return sourceDirectoriesPaths(List.of(directories));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -490,6 +562,26 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
|||
return sourceDirectories_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides source directories that will be used for the archive creation.
|
||||
*
|
||||
* @param directories one or more source directories
|
||||
* @return this operation instance
|
||||
*/
|
||||
public T sourceDirectoriesPaths(Collection<Path> directories) {
|
||||
return sourceDirectories(directories.stream().map(Path::toFile).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides source directories that will be used for the archive creation.
|
||||
*
|
||||
* @param directories one or more source directories
|
||||
* @return this operation instance
|
||||
*/
|
||||
public T sourceDirectoriesStrings(Collection<String> directories) {
|
||||
return sourceDirectories(directories.stream().map(File::new).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that all the elements ({@link #mainClass() mainClass}, {@link #launcherClass() launcherClass} and
|
||||
* {@link #launcherLibs() launcherLibs}) required to create the archive have been provided, throws an
|
||||
|
|
|
@ -22,6 +22,7 @@ import rife.tools.FileUtils;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -151,6 +152,16 @@ public class BootWarOperation extends AbstractBootOperation<BootWarOperation> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the libraries that will be used for the WAR creation in {@code /WEB-INF/lib-provided}.
|
||||
*
|
||||
* @param jars one or more Java archive files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public BootWarOperation providedLibs(String... jars) {
|
||||
return providedLibsStrings(List.of(jars));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the libraries that will be used for the WAR creation in {@code /WEB-INF/lib-provided}.
|
||||
*
|
||||
|
@ -158,7 +169,47 @@ public class BootWarOperation extends AbstractBootOperation<BootWarOperation> {
|
|||
* @return this operation instance
|
||||
*/
|
||||
public BootWarOperation providedLibs(File... jars) {
|
||||
providedLibs_.addAll(List.of(jars));
|
||||
return providedLibs(List.of(jars));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the libraries that will be used for the WAR creation in {@code /WEB-INF/lib-provided}.
|
||||
*
|
||||
* @param jars one or more Java archive files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public BootWarOperation providedLibs(Path... jars) {
|
||||
return providedLibsPaths(List.of(jars));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the libraries that will be used for the WAR creation in {@code /WEB-INF/lib-provided}.
|
||||
*
|
||||
* @return the list of Java archive files.
|
||||
*/
|
||||
public List<File> providedLibs() {
|
||||
return providedLibs_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the libraries that will be used for the WAR creation in {@code /WEB-INF/lib-provided}.
|
||||
*
|
||||
* @param jars one or more Java archive files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public BootWarOperation providedLibsPaths(Collection<Path> jars) {
|
||||
providedLibs_.addAll(jars.stream().map(Path::toFile).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the libraries that will be used for the WAR creation in {@code /WEB-INF/lib-provided}.
|
||||
*
|
||||
* @param jars one or more Java archive files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public BootWarOperation providedLibsStrings(Collection<String> jars) {
|
||||
providedLibs_.addAll(jars.stream().map(File::new).toList());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue