More API cleanups

This commit is contained in:
Erik C. Thauvin 2024-08-30 15:54:01 -07:00
parent 1b08f43392
commit 61623728ff
Signed by: erik
GPG key ID: 776702A6A2DA330E
4 changed files with 504 additions and 52 deletions

View file

@ -27,7 +27,6 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
@ -66,6 +65,16 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
return s != null && !s.isBlank();
}
/**
* Provides the main build destination directory.
*
* @param directory the directory to use for the main build destination
* @return this operation instance
*/
public CompileKotlinOperation buildMainDirectory(Path directory) {
return buildMainDirectory(directory.toFile());
}
/**
* Provides the main build destination directory.
*
@ -77,6 +86,16 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
return this;
}
/**
* Provides the main build destination directory.
*
* @param directory the directory to use for the main build destination
* @return this operation instance
*/
public CompileKotlinOperation buildMainDirectory(String directory) {
return buildMainDirectory(new File(directory));
}
/**
* Retrieves the main build destination directory.
*
@ -97,6 +116,26 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
return this;
}
/**
* Provides the test build destination directory.
*
* @param directory the directory to use for the test build destination
* @return this operation instance
*/
public CompileKotlinOperation buildTestDirectory(Path directory) {
return buildTestDirectory(directory.toFile());
}
/**
* Provides the test build destination directory.
*
* @param directory the directory to use for the test build destination
* @return this operation instance
*/
public CompileKotlinOperation buildTestDirectory(String directory) {
return buildTestDirectory(new File(directory));
}
/**
* Retrieves the test build destination directory.
*
@ -111,10 +150,10 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
*
* @param classpath one or more classpath entries
* @return this operation instance
* @see #compileMainClasspath(Collection)
*/
public CompileKotlinOperation compileMainClasspath(String... classpath) {
compileMainClasspath_.addAll(List.of(classpath));
return this;
return compileMainClasspath(List.of(classpath));
}
/**
@ -164,8 +203,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
* @return this operation instance
*/
public CompileKotlinOperation compileTestClasspath(String... classpath) {
compileTestClasspath_.addAll(List.of(classpath));
return this;
return compileTestClasspath(List.of(classpath));
}
/**
@ -412,6 +450,16 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
return kotlinHome(new File(dir));
}
/**
* Provides the Kotlin home directory, if it differs from the default {@code KOTLIN_HOME}.
*
* @param dir the directory path
* @return this operation instance
*/
public CompileKotlinOperation kotlinHome(Path dir) {
return kotlinHome(dir.toFile());
}
/**
* Retrieves the Kotlin home directory.
*
@ -452,14 +500,13 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
}
/**
* Provides main source directories that should be compiled.
* Provides the path to the Kotlin compiler ({@code kotlinc}) executable, if not in {@link #kotlinHome()}.
*
* @param directories one or more main source directories
* @param executable the executable path
* @return this operation instance
*/
public CompileKotlinOperation mainSourceDirectories(File... directories) {
mainSourceDirectories_.addAll(List.of(directories));
return this;
public CompileKotlinOperation kotlinc(Path executable) {
return kotlinc(executable.toFile());
}
/**
@ -467,10 +514,32 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
*
* @param directories one or more main source directories
* @return this operation instance
* @see #mainSourceDirectories(Collection)
*/
public CompileKotlinOperation mainSourceDirectories(File... directories) {
return mainSourceDirectories(List.of(directories));
}
/**
* Provides main source directories that should be compiled.
*
* @param directories one or more main source directories
* @return this operation instance
* @see #mainSourceDirectoriesPaths(Collection)
*/
public CompileKotlinOperation mainSourceDirectories(Path... directories) {
return mainSourceDirectoriesPaths(List.of(directories));
}
/**
* Provides main source directories that should be compiled.
*
* @param directories one or more main source directories
* @return this operation instance
* @see #mainSourceDirectoriesStrings(Collection)
*/
public CompileKotlinOperation mainSourceDirectories(String... directories) {
mainSourceDirectories_.addAll(Arrays.stream(directories).map(File::new).toList());
return this;
return mainSourceDirectoriesStrings(List.of(directories));
}
/**
@ -478,6 +547,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
*
* @param directories the main source directories
* @return this operation instance
* @see #mainSourceDirectories(File...)
*/
public CompileKotlinOperation mainSourceDirectories(Collection<File> directories) {
mainSourceDirectories_.addAll(directories);
@ -494,14 +564,25 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
}
/**
* Provides main source files that should be compiled.
* Provides the main source directories that should be compiled.
*
* @param files one or more main source files
* @param directories the main source directories
* @return this operation instance
* @see #mainSourceDirectories(Path...)
*/
public CompileKotlinOperation mainSourceFiles(File... files) {
mainSourceFiles_.addAll(List.of(files));
return this;
public CompileKotlinOperation mainSourceDirectoriesPaths(Collection<Path> directories) {
return mainSourceDirectories(directories.stream().map(Path::toFile).toList());
}
/**
* Provides the main source directories that should be compiled.
*
* @param directories the main source directories
* @return this operation instance
* @see #mainSourceDirectories(String...)
*/
public CompileKotlinOperation mainSourceDirectoriesStrings(Collection<String> directories) {
return mainSourceDirectories(directories.stream().map(File::new).toList());
}
/**
@ -509,10 +590,32 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
*
* @param files one or more main source files
* @return this operation instance
* @see #mainSourceFiles(Collection)
*/
public CompileKotlinOperation mainSourceFiles(File... files) {
return mainSourceFiles(List.of(files));
}
/**
* Provides main source files that should be compiled.
*
* @param files one or more main source files
* @return this operation instance
* @see #mainSourceFilesStrings(Collection)
*/
public CompileKotlinOperation mainSourceFiles(String... files) {
mainSourceFiles_.addAll(Arrays.stream(files).map(File::new).toList());
return this;
return mainSourceFilesStrings(List.of(files));
}
/**
* Provides main source files that should be compiled.
*
* @param files one or more main source files
* @return this operation instance
* @see #mainSourceFilesPaths(Collection)
*/
public CompileKotlinOperation mainSourceFiles(Path... files) {
return mainSourceFilesPaths(List.of(files));
}
/**
@ -520,6 +623,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
*
* @param files the main source files
* @return this operation instance
* @see #mainSourceFiles(File...)
*/
public CompileKotlinOperation mainSourceFiles(Collection<File> files) {
mainSourceFiles_.addAll(files);
@ -535,6 +639,39 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
return mainSourceFiles_;
}
/**
* Provides the main source files that should be compiled.
*
* @param files the main source files
* @return this operation instance
* @see #mainSourceFiles(Path...)
*/
public CompileKotlinOperation mainSourceFilesPaths(Collection<Path> files) {
return mainSourceFiles(files.stream().map(Path::toFile).toList());
}
/**
* Provides the main source files that should be compiled.
*
* @param files the main source files
* @return this operation instance
* @see #mainSourceFiles(String...)
*/
public CompileKotlinOperation mainSourceFilesStrings(Collection<String> files) {
return mainSourceFiles(files.stream().map(File::new).toList());
}
/**
* Provides compiler plugins.
*
* @param directory the directory containing the plugin JARs
* @param plugins one or more plugins
* @return this class instance
*/
public CompileKotlinOperation plugins(String directory, CompilerPlugin... plugins) {
return plugins(new File(directory), plugins);
}
/**
* Provides compiler plugins.
*
@ -542,8 +679,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
* @return this class instance
*/
public CompileKotlinOperation plugins(String... plugins) {
plugins_.addAll(List.of(plugins));
return this;
return plugins(List.of(plugins));
}
/**
@ -580,6 +716,17 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
return this;
}
/**
* Provides compiler plugins.
*
* @param directory the directory containing the plugin JARs
* @param plugins one or more plugins
* @return this class instance
*/
public CompileKotlinOperation plugins(Path directory, CompilerPlugin... plugins) {
return plugins(directory.toFile(), plugins);
}
/**
* Provides compiler plugins located in the {@link #kotlinHome()} lib directory.
*
@ -613,10 +760,10 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
*
* @param directories one or more test source directories
* @return this operation instance
* @see #testSourceDirectories(Collection)
*/
public CompileKotlinOperation testSourceDirectories(File... directories) {
testSourceDirectories_.addAll(List.of(directories));
return this;
return testSourceDirectories(List.of(directories));
}
/**
@ -624,10 +771,21 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
*
* @param directories one or more test source directories
* @return this operation instance
* @see #testSourceDirectoriesPaths(Collection)
*/
public CompileKotlinOperation testSourceDirectories(Path... directories) {
return testSourceDirectoriesPaths(List.of(directories));
}
/**
* Provides test source directories that should be compiled.
*
* @param directories one or more test source directories
* @return this operation instance
* @see #testSourceDirectoriesStrings(Collection)
*/
public CompileKotlinOperation testSourceDirectories(String... directories) {
testSourceDirectories_.addAll(Arrays.stream(directories).map(File::new).toList());
return this;
return testSourceDirectoriesStrings(List.of(directories));
}
/**
@ -635,6 +793,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
*
* @param directories the test source directories
* @return this operation instance
* @see #testSourceDirectories(File...)
*/
public CompileKotlinOperation testSourceDirectories(Collection<File> directories) {
testSourceDirectories_.addAll(directories);
@ -650,15 +809,37 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
return testSourceDirectories_;
}
/**
* Provides the test source directories that should be compiled.
*
* @param directories the test source directories
* @return this operation instance
* @see #testSourceDirectories(Path...)
*/
public CompileKotlinOperation testSourceDirectoriesPaths(Collection<Path> directories) {
return testSourceDirectories(directories.stream().map(Path::toFile).toList());
}
/**
* Provides the test source directories that should be compiled.
*
* @param directories the test source directories
* @return this operation instance
* @see #testSourceDirectories(String...)
*/
public CompileKotlinOperation testSourceDirectoriesStrings(Collection<String> directories) {
return testSourceDirectories(directories.stream().map(File::new).toList());
}
/**
* Provides test source files that should be compiled.
*
* @param files one or more test source files
* @return this operation instance
* @see #testSourceFiles(Collection)
*/
public CompileKotlinOperation testSourceFiles(File... files) {
testSourceFiles_.addAll(List.of(files));
return this;
return testSourceFiles(List.of(files));
}
/**
@ -666,10 +847,21 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
*
* @param files one or more test source files
* @return this operation instance
* @see #testSourceFilesStrings(Collection)
*/
public CompileKotlinOperation testSourceFiles(String... files) {
testSourceFiles_.addAll(Arrays.stream(files).map(File::new).toList());
return this;
return testSourceFilesStrings(List.of(files));
}
/**
* Provides the test sources files that should be compiled.
*
* @param files one or more test source files
* @return this operation instance
* @see #testSourceFilesPaths(Collection)
*/
public CompileKotlinOperation testSourceFiles(Path... files) {
return testSourceFilesPaths(List.of(files));
}
/**
@ -677,6 +869,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
*
* @param files the test source files
* @return this operation instance
* @see #testSourceFiles(File...)
*/
public CompileKotlinOperation testSourceFiles(Collection<File> files) {
testSourceFiles_.addAll(files);
@ -692,6 +885,28 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
return testSourceFiles_;
}
/**
* Provides the test source files that should be compiled.
*
* @param files the test source files
* @return this operation instance
* @see #testSourceFiles(Path...)
*/
public CompileKotlinOperation testSourceFilesPaths(Collection<Path> files) {
return testSourceFiles(files.stream().map(Path::toFile).toList());
}
/**
* Provides the test source files that should be compiled.
*
* @param files the test source files
* @return this operation instance
* @see #testSourceFiles(String...)
*/
public CompileKotlinOperation testSourceFilesStrings(Collection<String> files) {
return testSourceFiles(files.stream().map(File::new).toList());
}
/**
* Retrieves the working directory.
*
@ -712,6 +927,16 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
return this;
}
/**
* Provides the working directory, if it differs from the project's directory.
*
* @param dir the directory
* @return this operation instance
*/
public CompileKotlinOperation workDir(Path dir) {
return workDir(dir.toFile());
}
/**
* Provides the working directory, if it differs from the project's directory.
*

View file

@ -68,8 +68,7 @@ public class CompileOptions {
* @return this operation instance
*/
public CompileOptions advancedOptions(String... options) {
advancedOptions_.addAll(List.of(options));
return this;
return advancedOptions(List.of(options));
}
/**
@ -120,8 +119,7 @@ public class CompileOptions {
* @return this operation instance
*/
public CompileOptions apiVersion(int version) {
apiVersion_ = String.valueOf(version);
return this;
return apiVersion(String.valueOf(version));
}
/**
@ -141,6 +139,7 @@ public class CompileOptions {
*
* @param files one or more files
* @return this operation instance
* @see #argFileStrings(Collection)
*/
public CompileOptions argFile(String... files) {
return argFileStrings(List.of(files));
@ -151,7 +150,7 @@ public class CompileOptions {
*
* @param files the compiler options files
* @return this operation instance
* @see #argFile(String...)
* @see #argFile(File...)
*/
public CompileOptions argFile(Collection<File> files) {
argFile_.addAll(files);
@ -175,6 +174,7 @@ public class CompileOptions {
*
* @param files one or more files
* @return this operation instance
* @see #argFile(Collection)
*/
public CompileOptions argFile(File... files) {
return argFile(List.of(files));
@ -197,6 +197,7 @@ public class CompileOptions {
*
* @param files one or more files
* @return this operation instance
* @see #argFilePaths(Collection)
*/
public CompileOptions argFile(Path... files) {
return argFilePaths(List.of(files));
@ -216,7 +217,7 @@ public class CompileOptions {
*
* @param files the compiler options files
* @return this operation instance
* @see #argFile(String...)
* @see #argFile(Path...)
*/
public CompileOptions argFilePaths(Collection<Path> files) {
return argFile(files.stream().map(Path::toFile).toList());
@ -393,6 +394,7 @@ public class CompileOptions {
*
* @param paths one pr more paths
* @return this operation instance
* @see #classpathStrings(Collection)
*/
public CompileOptions classpath(String... paths) {
return classpathStrings(List.of(paths));
@ -405,6 +407,7 @@ public class CompileOptions {
*
* @param paths one or more path
* @return this operation instance
* @see #classpath(Collection)
*/
public CompileOptions classpath(File... paths) {
return classpath(List.of(paths));
@ -417,6 +420,7 @@ public class CompileOptions {
*
* @param paths one or more path
* @return this operation instance
* @see #classpathPaths(Collection)
*/
public CompileOptions classpath(Path... paths) {
return classpathPaths(List.of(paths));
@ -429,6 +433,7 @@ public class CompileOptions {
*
* @param paths the search paths
* @return this operation instance
* @see #classpath(File...)
*/
public CompileOptions classpath(Collection<File> paths) {
classpath_.addAll(paths);
@ -451,6 +456,7 @@ public class CompileOptions {
*
* @param paths one pr more paths
* @return this operation instance
* @see #classpath(Path...)
*/
public CompileOptions classpathPaths(Collection<Path> paths) {
return classpath(paths.stream().map(Path::toFile).toList());
@ -463,6 +469,7 @@ public class CompileOptions {
*
* @param paths one pr more paths
* @return this operation instance
* @see #classpath(String...)
*/
public CompileOptions classpathStrings(Collection<String> paths) {
return classpath(paths.stream().map(File::new).toList());
@ -679,8 +686,7 @@ public class CompileOptions {
* @see #jdkRelease(String)
*/
public CompileOptions jdkRelease(int version) {
jdkRelease_ = String.valueOf(version);
return this;
return jdkRelease(String.valueOf(version));
}
/**
@ -721,8 +727,7 @@ public class CompileOptions {
* @see #jvmTarget(String)
*/
public CompileOptions jvmTarget(int target) {
jvmTarget_ = String.valueOf(target);
return this;
return jvmTarget(String.valueOf(target));
}
/**
@ -879,8 +884,7 @@ public class CompileOptions {
* @return this operation instance
*/
public CompileOptions optIn(String... annotations) {
optIn_.addAll(List.of(annotations));
return this;
return optIn(List.of(annotations));
}
/**
@ -910,8 +914,7 @@ public class CompileOptions {
* @return this operation instance
*/
public CompileOptions options(String... options) {
options_.addAll(List.of(options));
return this;
return options(List.of(options));
}
/**
@ -1022,8 +1025,7 @@ public class CompileOptions {
* @return this operation instance
*/
public CompileOptions scriptTemplates(String... classNames) {
scriptTemplates_.addAll(List.of(classNames));
return this;
return scriptTemplates(List.of(classNames));
}
/**