Package rife.bld.extension
Class CompileKotlinOperation
java.lang.Object
rife.bld.operations.AbstractOperation<CompileKotlinOperation>
rife.bld.extension.CompileKotlinOperation
Compiles main and test Kotlin sources in the relevant build directories.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the main build destination directory.buildMainDirectory(File directory) Provides the main build destination directory.buildMainDirectory(String directory) Provides the main build destination directory.buildMainDirectory(Path directory) Provides the main build destination directory.Retrieves the test build destination directory.buildTestDirectory(File directory) Provides the test build destination directory.buildTestDirectory(String directory) Provides the test build destination directory.buildTestDirectory(Path directory) Provides the test build destination directory.Retrieves the entries for the main compilation classpath.compileMainClasspath(String... classpath) Provides entries for the main compilation classpath.final CompileKotlinOperationcompileMainClasspath(Collection<String> classpath) Provides the entries for the main compilation classpath.Retrieves the compilation options for the compiler.compileOptions(CompileOptions options) Provides the compilation options to pass to the Kotlin compiler.Retrieves the entries for the test compilation classpath.compileTestClasspath(String... classpath) Provides entries for the test compilation classpath.final CompileKotlinOperationcompileTestClasspath(Collection<String> classpath) Provides the entries for the test compilation classpath.voidexecute()Performs the compile operation.protected voidPart of theexecuteoperation, builds the main sources.protected voidexecuteBuildSources(Collection<String> classpath, Collection<File> sources, File destination, File friendPaths) Part of theexecuteoperation, build sources to a given destination.protected voidPart of theexecuteoperation, builds the test sources.protected voidPart of theexecuteoperation, creates the build directories.static StringLocates the Kotlin compiler (kotlinc) executable.protected static StringfindKotlincPath(boolean isSilent) Locates the Kotlin compiler (kotlinc) executable.fromProject(BaseProject project) Configures a compile operation from aBaseProject.Retrieves the Java Virtual Machine options.jvmOptions(JvmOptions options) Provides the Java Virtual Machine options.kotlinc()Retrieves the path to the Kotlin compiler (kotlinc) executable, if not inkotlinHome().Provides the path to the Kotlin compiler (kotlinc) executable, if not inkotlinHome().Provides the path to the Kotlin compiler (kotlinc) executable, if not inkotlinHome().Provides the path to the Kotlin compiler (kotlinc) executable, if not inkotlinHome().Retrieves the Kotlin home directory.kotlinHome(File dir) Provides the Kotlin home directory, if it differs from the defaultKOTLIN_HOME.kotlinHome(String dir) Provides the Kotlin home directory, if it differs from the defaultKOTLIN_HOME.kotlinHome(Path dir) Provides the Kotlin home directory, if it differs from the defaultKOTLIN_HOME.Retrieves the main source directories that should be compiled.mainSourceDirectories(File... directories) Provides main source directories that should be compiled.mainSourceDirectories(String... directories) Provides main source directories that should be compiled.mainSourceDirectories(Path... directories) Provides main source directories that should be compiled.final CompileKotlinOperationmainSourceDirectories(Collection<File> directories) Provides the main source directories that should be compiled.final CompileKotlinOperationmainSourceDirectoriesPaths(Collection<Path> directories) Provides the main source directories that should be compiled.final CompileKotlinOperationmainSourceDirectoriesStrings(Collection<String> directories) Provides the main source directories that should be compiled.Retrieves the main files that should be compiled.mainSourceFiles(File... files) Provides main source files that should be compiled.mainSourceFiles(String... files) Provides main source files that should be compiled.mainSourceFiles(Path... files) Provides main source files that should be compiled.mainSourceFiles(Collection<File> files) Provides the main source files that should be compiled.final CompileKotlinOperationmainSourceFilesPaths(Collection<Path> files) Provides the main source files that should be compiled.final CompileKotlinOperationmainSourceFilesStrings(Collection<String> files) Provides the main source files that should be compiled.plugins()Retrieves the compiler plugins.plugins(File directory, CompilerPlugin... plugins) Provides compiler plugins.Provides compiler plugins.plugins(String directory, CompilerPlugin... plugins) Provides compiler plugins.plugins(Path directory, CompilerPlugin... plugins) Provides compiler plugins.final CompileKotlinOperationplugins(Collection<String> plugins) Provides compiler plugins.plugins(CompilerPlugin... plugins) Provides compiler plugins located in thekotlinHome()lib directory.Retrieves the test source directories that should be compiled.testSourceDirectories(File... directories) Provides test source directories that should be compiled.testSourceDirectories(String... directories) Provides test source directories that should be compiled.testSourceDirectories(Path... directories) Provides test source directories that should be compiled.final CompileKotlinOperationtestSourceDirectories(Collection<File> directories) Provides the test source directories that should be compiled.final CompileKotlinOperationtestSourceDirectoriesPaths(Collection<Path> directories) Provides the test source directories that should be compiled.final CompileKotlinOperationtestSourceDirectoriesStrings(Collection<String> directories) Provides the test source directories that should be compiled.Retrieves the test files that should be compiled.testSourceFiles(File... files) Provides test source files that should be compiled.testSourceFiles(String... files) Provides the test sources files that should be compiled.testSourceFiles(Path... files) Provides the test sources files that should be compiled.final CompileKotlinOperationtestSourceFiles(Collection<File> files) Provides the test source files that should be compiled.final CompileKotlinOperationtestSourceFilesPaths(Collection<Path> files) Provides the test source files that should be compiled.final CompileKotlinOperationtestSourceFilesStrings(Collection<String> files) Provides the test source files that should be compiled.workDir()Retrieves the working directory.Provides the working directory if it differs from the project's directory.Provides the working directory if it differs from the project's directory.Provides the working directory if it differs from the project's directory.Methods inherited from class rife.bld.operations.AbstractOperation
executeOnce, executeOnce, silent, silent
-
Constructor Details
-
CompileKotlinOperation
public CompileKotlinOperation()
-
-
Method Details
-
execute
Performs the compile operation.- Specified by:
executein classAbstractOperation<CompileKotlinOperation>- Throws:
NullPointerException- ifprojectorworkDirisnullException- when an exception occurs during the execution
-
findKotlincPath
Locates the Kotlin compiler (kotlinc) executable.- Returns:
- The path to the kotlinc executable, or
kotlinc/kotlinc.batif not found. - Since:
- 1.1.0
-
findKotlincPath
Locates the Kotlin compiler (kotlinc) executable.- Parameters:
isSilent- do not log the path to the kotlinc executable, iftrue- Returns:
- The path to the kotlinc executable, or
kotlinc/kotlinc.batif not found. - Since:
- 1.1.0
-
buildMainDirectory
Provides the main build destination directory.- Parameters:
directory- the directory to use for the main build destination- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoryisnull
-
buildMainDirectory
Provides the main build destination directory.- Parameters:
directory- the directory to use for the main build destination- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoryisnull
-
buildMainDirectory
Provides the main build destination directory.- Parameters:
directory- the directory to use for the main build destination- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoryisnullIllegalArgumentException- ifdirectoryis empty
-
buildMainDirectory
Retrieves the main build destination directory.- Returns:
- the main build directory
-
buildTestDirectory
Provides the test build destination directory.- Parameters:
directory- the directory to use for the test build destination- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoryisnull
-
buildTestDirectory
Provides the test build destination directory.- Parameters:
directory- the directory to use for the test build destination- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoryisnull
-
buildTestDirectory
Provides the test build destination directory.- Parameters:
directory- the directory to use for the test build destination- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoryisnullIllegalArgumentException- ifdirectoryis empty
-
buildTestDirectory
Retrieves the test build destination directory.- Returns:
- the test build directory
-
compileMainClasspath
Provides entries for the main compilation classpath.- Parameters:
classpath- one or more classpath entries- Returns:
- this operation instance
- Throws:
NullPointerException- ifclasspathisnullIllegalArgumentException- ifclasspathis empty, or containsnullor empty elements- See Also:
-
compileMainClasspath
Provides the entries for the main compilation classpath.- Parameters:
classpath- the classpath entries- Returns:
- this operation instance
- Throws:
NullPointerException- ifclasspathisnullIllegalArgumentException- ifclasspathis empty, or containsnullor empty elements
-
compileMainClasspath
Retrieves the entries for the main compilation classpath.- Returns:
- the classpath entries
-
compileOptions
Retrieves the compilation options for the compiler.- Returns:
- the compilation options
-
compileOptions
Provides the compilation options to pass to the Kotlin compiler.- Parameters:
options- the compiler options- Returns:
- this operation instance
- Throws:
NullPointerException- ifoptionsisnull
-
compileTestClasspath
Provides entries for the test compilation classpath.- Parameters:
classpath- one or more classpath entries- Returns:
- this operation instance
- Throws:
NullPointerException- ifclasspathisnullIllegalArgumentException- ifclasspathis empty, or containsnullor empty elements
-
compileTestClasspath
Provides the entries for the test compilation classpath.- Parameters:
classpath- the classpath entries- Returns:
- this operation instance
- Throws:
NullPointerException- ifclasspathisnullIllegalArgumentException- ifclasspathis empty, or containsnullor empty elements
-
compileTestClasspath
Retrieves the entries for the test compilation classpath.- Returns:
- the classpath entries
-
fromProject
Configures a compile operation from aBaseProject.Sets the following from the project:
-
workDirto the project's directory, if not already set. -
buildMainDirectory, if not already set. -
buildTestDirectory, if not already set. -
compileMainClasspath, if not already set. -
compilesTestClasspath, if not already set. -
mainSourceDirectoriesto thekotlindirectory insrcMainDirectory, if present and not already set. -
testSourceDirectoriesto thekotlindirectory insrcTestDirectory, if present and not already set. -
jdkReleasetojavaRelease, if not already set. -
jvmTargettojavaRelease, if not already set. noStdLibtotrue
- Parameters:
project- the project to configure the compile operation from- Returns:
- this operation instance
- Throws:
NullPointerException- ifprojectisnull
-
-
jvmOptions
Retrieves the Java Virtual Machine options.- Returns:
- the JVM options
-
jvmOptions
Provides the Java Virtual Machine options.- Parameters:
options- the JVM options- Returns:
- this operation instance
- Throws:
NullPointerException- ifoptionsisnull- Since:
- 1.2
-
kotlinHome
Provides the Kotlin home directory, if it differs from the defaultKOTLIN_HOME.- Parameters:
dir- the directory path- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirisnullIllegalArgumentException- ifdiris empty
-
kotlinHome
Provides the Kotlin home directory, if it differs from the defaultKOTLIN_HOME.- Parameters:
dir- the directory- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirisnull
-
kotlinHome
Provides the Kotlin home directory, if it differs from the defaultKOTLIN_HOME.- Parameters:
dir- the directory path- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirisnull
-
kotlinHome
Retrieves the Kotlin home directory.- Returns:
- the directory
-
kotlinc
Provides the path to the Kotlin compiler (kotlinc) executable, if not inkotlinHome().- Parameters:
executable- the executable path- Returns:
- this operation instance
- Throws:
NullPointerException- ifexecutableisnullIllegalArgumentException- ifexecutableis empty
-
kotlinc
Retrieves the path to the Kotlin compiler (kotlinc) executable, if not inkotlinHome().- Returns:
- the executable path
-
kotlinc
Provides the path to the Kotlin compiler (kotlinc) executable, if not inkotlinHome().- Parameters:
executable- the executable path- Returns:
- this operation instance
- Throws:
NullPointerException- ifexecutableisnull
-
kotlinc
Provides the path to the Kotlin compiler (kotlinc) executable, if not inkotlinHome().- Parameters:
executable- the executable path- Returns:
- this operation instance
- Throws:
NullPointerException- ifexecutableisnull
-
mainSourceDirectories
Retrieves the main source directories that should be compiled.- Returns:
- the main source directories
-
mainSourceDirectories
Provides main source directories that should be compiled.- Parameters:
directories- one or more main source directories- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoriesisnull- See Also:
-
mainSourceDirectories
Provides main source directories that should be compiled.- Parameters:
directories- one or more main source directories- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoriesisnull- See Also:
-
mainSourceDirectories
Provides main source directories that should be compiled.- Parameters:
directories- one or more main source directories- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoriesisnullIllegalArgumentException- ifdirectoriesis empty, or containsnullor empty elements- See Also:
-
mainSourceDirectories
Provides the main source directories that should be compiled.- Parameters:
directories- the main source directories- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoriesisnull- See Also:
-
mainSourceDirectoriesPaths
public final CompileKotlinOperation mainSourceDirectoriesPaths(@NonNull Collection<Path> directories) Provides the main source directories that should be compiled.- Parameters:
directories- the main source directories- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoriesisnullIllegalArgumentException- ifdirectoriesis empty, or containsnullelements- See Also:
-
mainSourceDirectoriesStrings
public final CompileKotlinOperation mainSourceDirectoriesStrings(@NonNull Collection<String> directories) Provides the main source directories that should be compiled.- Parameters:
directories- the main source directories- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoriesisnullIllegalArgumentException- ifdirectoriesis empty, or containsnullor empty elements- See Also:
-
mainSourceFiles
Retrieves the main files that should be compiled.- Returns:
- the files
-
mainSourceFiles
Provides main source files that should be compiled.- Parameters:
files- one or more main source files- Returns:
- this operation instance
- Throws:
NullPointerException- iffilesisnull- See Also:
-
mainSourceFiles
Provides main source files that should be compiled.- Parameters:
files- one or more main source files- Returns:
- this operation instance
- Throws:
NullPointerException- iffilesisnullIllegalArgumentException- iffilesis empty, or containsnullor empty elements- See Also:
-
mainSourceFiles
Provides main source files that should be compiled.- Parameters:
files- one or more main source files- Returns:
- this operation instance
- Throws:
NullPointerException- iffilesisnull- See Also:
-
mainSourceFiles
Provides the main source files that should be compiled.- Parameters:
files- the main source files- Returns:
- this operation instance
- Throws:
NullPointerException- iffilesisnull- See Also:
-
mainSourceFilesPaths
Provides the main source files that should be compiled.- Parameters:
files- the main source files- Returns:
- this operation instance
- Throws:
NullPointerException- iffilesisnullIllegalArgumentException- iffilesis empty, or containsnullelements- See Also:
-
mainSourceFilesStrings
Provides the main source files that should be compiled.- Parameters:
files- the main source files- Returns:
- this operation instance
- Throws:
NullPointerException- iffilesisnullIllegalArgumentException- iffilesis empty, or containsnullor empty elements- See Also:
-
plugins
public CompileKotlinOperation plugins(@NonNull String directory, @NonNull CompilerPlugin... plugins) Provides compiler plugins.- Parameters:
directory- the directory containing the plugin JARsplugins- one or more plugins- Returns:
- this class instance
- Throws:
NullPointerException- ifdirectoryorpluginsisnullIllegalArgumentException- ifdirectoryis empty
-
plugins
Provides compiler plugins.- Parameters:
directory- the directory containing the plugin JARsplugins- one or more plugins- Returns:
- this class instance
- Throws:
NullPointerException- ifdirectoryorpluginsisnull
-
plugins
Retrieves the compiler plugins.- Returns:
- the compiler plugins
-
plugins
Provides compiler plugins.- Parameters:
plugins- one or more plugins- Returns:
- this class instance
- Throws:
NullPointerException- ifpluginsisnullIllegalArgumentException- ifpluginsis empty, or containsnullor empty elements
-
plugins
Provides compiler plugins.- Parameters:
plugins- the compiler plugins- Returns:
- this class instance
- Throws:
NullPointerException- ifpluginsisnullIllegalArgumentException- ifpluginsis empty, or containsnullor empty elements
-
plugins
Provides compiler plugins.- Parameters:
directory- the directory containing the plugin JARsplugins- one or more plugins- Returns:
- this class instance
- Throws:
NullPointerException- ifdirectoryorpluginsisnull
-
plugins
Provides compiler plugins located in thekotlinHome()lib directory.- Parameters:
plugins- one or more plugins- Returns:
- this class instance
- Throws:
NullPointerException- ifpluginsisnullIllegalArgumentException- ifpluginsis empty, or containsnullelements- See Also:
-
testSourceDirectories
Retrieves the test source directories that should be compiled.- Returns:
- the test source directories
-
testSourceDirectories
Provides test source directories that should be compiled.- Parameters:
directories- one or more test source directories- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoriesisnull- See Also:
-
testSourceDirectories
Provides test source directories that should be compiled.- Parameters:
directories- one or more test source directories- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoriesisnull- See Also:
-
testSourceDirectories
Provides test source directories that should be compiled.- Parameters:
directories- one or more test source directories- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoriesisnullIllegalArgumentException- ifdirectoriesis empty, or containsnullor empty elements- See Also:
-
testSourceDirectories
Provides the test source directories that should be compiled.- Parameters:
directories- the test source directories- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoriesisnull- See Also:
-
testSourceDirectoriesPaths
public final CompileKotlinOperation testSourceDirectoriesPaths(@NonNull Collection<Path> directories) Provides the test source directories that should be compiled.- Parameters:
directories- the test source directories- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoriesisnullIllegalArgumentException- ifdirectoriesis empty, or containsnullelements- See Also:
-
testSourceDirectoriesStrings
public final CompileKotlinOperation testSourceDirectoriesStrings(@NonNull Collection<String> directories) Provides the test source directories that should be compiled.- Parameters:
directories- the test source directories- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirectoriesisnullIllegalArgumentException- ifdirectoriesis empty, or containsnullor empty elements- See Also:
-
testSourceFiles
Retrieves the test files that should be compiled.- Returns:
- the test files
-
testSourceFiles
Provides test source files that should be compiled.- Parameters:
files- one or more test source files- Returns:
- this operation instance
- Throws:
NullPointerException- iffilesisnull- See Also:
-
testSourceFiles
Provides the test sources files that should be compiled.- Parameters:
files- one or more test source files- Returns:
- this operation instance
- Throws:
NullPointerException- iffilesisnullIllegalArgumentException- iffilesis empty, or containsnullor empty elements- See Also:
-
testSourceFiles
Provides the test sources files that should be compiled.- Parameters:
files- one or more test source files- Returns:
- this operation instance
- Throws:
NullPointerException- iffilesisnull- See Also:
-
testSourceFiles
Provides the test source files that should be compiled.- Parameters:
files- the test source files- Returns:
- this operation instance
- Throws:
NullPointerException- iffilesisnull- See Also:
-
testSourceFilesPaths
Provides the test source files that should be compiled.- Parameters:
files- the test source files- Returns:
- this operation instance
- Throws:
NullPointerException- iffilesisnullIllegalArgumentException- iffilesis empty, or containsnullelements- See Also:
-
testSourceFilesStrings
Provides the test source files that should be compiled.- Parameters:
files- the test source files- Returns:
- this operation instance
- Throws:
NullPointerException- iffilesisnullIllegalArgumentException- iffilesis empty, or containsnullor empty elements- See Also:
-
workDir
Provides the working directory if it differs from the project's directory.- Parameters:
dir- the directory- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirisnull
-
workDir
Provides the working directory if it differs from the project's directory.- Parameters:
dir- the directory- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirisnull
-
workDir
Provides the working directory if it differs from the project's directory.- Parameters:
dir- the directory path- Returns:
- this operation instance
- Throws:
NullPointerException- ifdirisnullIllegalArgumentException- ifdiris empty
-
workDir
Retrieves the working directory.- Returns:
- the directory
-
executeBuildMainSources
Part of theexecuteoperation, builds the main sources.Copies the configured classpath and sources to prevent mutation of operation state across multiple
execute()invocations.- Throws:
ExitStatusException- if an error occurs
-
executeBuildSources
protected void executeBuildSources(Collection<String> classpath, Collection<File> sources, File destination, File friendPaths) throws ExitStatusException Part of theexecuteoperation, build sources to a given destination.- Parameters:
classpath- the classpath list used for the compilationsources- the source files to compiledestination- the destination directoryfriendPaths- the output directory for friendly modules- Throws:
ExitStatusException- if an error occurs
-
executeBuildTestSources
Part of theexecuteoperation, builds the test sources.Copies the configured classpath and sources to prevent mutation of operation state across multiple
execute()invocations. Test compilation uses the main build directory as a friend path for module visibility.- Throws:
ExitStatusException- if an error occurs
-
executeCreateBuildDirectories
Part of theexecuteoperation, creates the build directories.- Throws:
IOException- if an error occurs
-