- java.lang.Object
-
- com.gluonhq.substrate.model.ClassPath
-
public class ClassPath extends java.lang.ObjectRepresents the classpath Consolidates all classpath manipulations
-
-
Constructor Summary
Constructors Constructor Description ClassPath(java.lang.String classPath)Creates the class path
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(java.util.function.Predicate<java.lang.String> predicate)Returns whether any elements of this classpath match the provided predicate.java.util.List<java.lang.String>filter(java.util.function.Predicate<java.lang.String> predicate)Returns a list of strings consisting of the elements of this classpath that match the given predicate.java.util.List<java.io.File>getJars(boolean includeClasses)Returns a list with all the jar files that are found in the classpath.<T> java.util.List<T>mapToList(java.util.function.Function<java.lang.String,T> mapper)Returns a List consisting of the results of applying the given function to the elements of this classpath.java.lang.StringmapToString(java.util.function.Function<java.lang.String,java.lang.String> mapper)Returns a String classpath consisting of the results of applying the given function to the elements of this classpath.java.lang.StringmapWithLibs(java.nio.file.Path libsPath, java.lang.String... libNames)Returns a String classpath consisting of existing classes.java.lang.StringmapWithLibs(java.nio.file.Path libsPath, java.util.function.Function<java.lang.String,java.lang.String> libMap, java.util.function.Predicate<java.nio.file.Path> pathPredicate, java.lang.String... libNames)Returns a String classpath consisting of existing classes.
-
-
-
Method Detail
-
contains
public boolean contains(java.util.function.Predicate<java.lang.String> predicate)
Returns whether any elements of this classpath match the provided predicate.- Parameters:
predicate- predicate to apply to elements of this classpath. Should not be null.- Returns:
trueif any elements of the stream match the provided predicate, otherwisefalse
-
filter
public java.util.List<java.lang.String> filter(java.util.function.Predicate<java.lang.String> predicate)
Returns a list of strings consisting of the elements of this classpath that match the given predicate.- Parameters:
predicate- predicate to apply to elements of this classpath. Should not be null.- Returns:
- filtered list of elements of this classpath
-
mapToList
public <T> java.util.List<T> mapToList(java.util.function.Function<java.lang.String,T> mapper)
Returns a List consisting of the results of applying the given function to the elements of this classpath.- Type Parameters:
T- The element type of the resulting List- Parameters:
mapper- function to apply to each element. Should not be null.- Returns:
- the list
-
mapToString
public java.lang.String mapToString(java.util.function.Function<java.lang.String,java.lang.String> mapper)
Returns a String classpath consisting of the results of applying the given function to the elements of this classpath.- Parameters:
mapper- function to apply to each element. Should not be null.- Returns:
- the string classpath
-
mapWithLibs
public java.lang.String mapWithLibs(java.nio.file.Path libsPath, java.lang.String... libNames)Returns a String classpath consisting of existing classes. Tries to find libraries by name and replace them with full path to this library within the given library path- Parameters:
libsPath- library pathlibNames- library names to look for- Returns:
- the string classpath
-
mapWithLibs
public java.lang.String mapWithLibs(java.nio.file.Path libsPath, java.util.function.Function<java.lang.String,java.lang.String> libMap, java.util.function.Predicate<java.nio.file.Path> pathPredicate, java.lang.String... libNames)Returns a String classpath consisting of existing classes. Tries to find libraries by name and replace them with full path to this library within the given library path. A function can be used to map the library names, if the files in the library path follow a different pattern than those on the classpath A predicate can be used to verify certain conditions to the found libraries, for instance checking that the files actually exist. If the test fails, the original string will be returned unmapped- Parameters:
libsPath- library pathlibMap- a function that maps the library name, can be nullpathPredicate- test to apply to the replaced libraries, can be nulllibNames- library names to look for- Returns:
- the string classpath
-
getJars
public java.util.List<java.io.File> getJars(boolean includeClasses) throws java.io.IOException, java.lang.InterruptedExceptionReturns a list with all the jar files that are found in the classpath.- Parameters:
includeClasses- if true, a jar will be created and added to the list, containing the compiled classes and resources of the current project- Returns:
- a list of jar files
- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
-