Class CompileKotlinOperation


public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOperation>
Compiles main and test Kotlin sources in the relevant build directories.
Since:
1.0
Author:
Erik C. Thauvin
  • Field Details

    • KOTLIN_FILE_PATTERN

      public static final Pattern KOTLIN_FILE_PATTERN
      The Kotlin file (.kt) pattern.
  • Constructor Details

    • CompileKotlinOperation

      public CompileKotlinOperation()
  • Method Details

    • getJarList

      public static List<String> getJarList(File directory, String regex)
      Returns the list of JARs contained in a given directory.
      Parameters:
      directory - the directory
      regex - the regular expression to match
      Returns:
      the list of JARs
    • getKotlinFileList

      public static Collection<File> getKotlinFileList(File directory)
      Returns the list of Kotlin source file {.kt} contained in a given directory.
      Parameters:
      directory - the directory
      Returns:
      the list of Kotlin files
    • isNotBlank

      public static boolean isNotBlank(String s)
      Determines if the given string is not blank.
      Parameters:
      s - the string
      Returns:
      true if not blank, false otherwise.
    • buildMainDirectory

      public CompileKotlinOperation buildMainDirectory(File directory)
      Provides the main build destination directory.
      Parameters:
      directory - the directory to use for the main build destination
      Returns:
      this operation instance
    • buildMainDirectory

      public File buildMainDirectory()
      Retrieves the main build destination directory.
      Returns:
      the main build destination
    • buildTestDirectory

      public CompileKotlinOperation buildTestDirectory(File directory)
      Provides the test build destination directory.
      Parameters:
      directory - the directory to use for the test build destination
      Returns:
      this operation instance
    • buildTestDirectory

      public File buildTestDirectory()
      Retrieves the test build destination directory.
      Returns:
      the test build destination
    • compileMainClasspath

      public CompileKotlinOperation compileMainClasspath(String... classpath)
      Provides entries for the main compilation classpath.
      Parameters:
      classpath - one or more classpath entries
      Returns:
      this operation instance
    • compileMainClasspath

      public CompileKotlinOperation compileMainClasspath(Collection<String> classpath)
      Provides a list of entries for the main compilation classpath.
      Parameters:
      classpath - a list of classpath entries
      Returns:
      this operation instance
    • compileMainClasspath

      public Collection<String> compileMainClasspath()
      Retrieves the list of entries for the main compilation classpath.
      Returns:
      the main compilation classpath list
    • compileOptions

      public CompileKotlinOptions compileOptions()
      Retrieves the list of compilation options for the compiler.
      Returns:
      the compile kotlin options
    • compileOptions

      public CompileKotlinOperation compileOptions(CompileKotlinOptions options)
      Provides a list of compilation options to pass to the Kotlin compiler.
      Parameters:
      options - the compiler options
      Returns:
      this operation instance
    • compileTestClasspath

      public CompileKotlinOperation compileTestClasspath(String... classpath)
      Provides entries for the test compilation classpath.
      Parameters:
      classpath - one or more classpath entries
      Returns:
      this operation instance
    • compileTestClasspath

      public CompileKotlinOperation compileTestClasspath(Collection<String> classpath)
      Provides a list of entries for the test compilation classpath.
      Parameters:
      classpath - a list of classpath entries
      Returns:
      this operation instance
    • compileTestClasspath

      public Collection<String> compileTestClasspath()
      Retrieves the list of entries for the test compilation classpath.
      Returns:
      the test compilation classpath list
    • execute

      public void execute() throws IOException
      Performs the compile operation.
      Specified by:
      execute in class AbstractOperation<CompileKotlinOperation>
      Throws:
      IOException
    • executeBuildMainSources

      protected void executeBuildMainSources() throws IOException
      Part of the execute operation, builds the main sources.
      Throws:
      IOException - if an error occurs
    • executeBuildSources

      protected void executeBuildSources(Collection<String> classpath, Collection<File> sources, File destination, File friendPaths) throws IOException
      Part of the execute operation, build sources to a given destination.
      Parameters:
      classpath - the classpath list used for the compilation
      sources - the source files to compile
      destination - the destination directory
      friendPaths - the output directory for friendly modules
      Throws:
      IOException - if an error occurs
    • executeBuildTestSources

      protected void executeBuildTestSources() throws IOException
      Part of the execute operation, builds the test sources.
      Throws:
      IOException - if an error occurs
    • executeCreateBuildDirectories

      protected void executeCreateBuildDirectories() throws IOException
      Part of the execute operation, creates the build directories.
      Throws:
      IOException - if an error occurs
    • fromProject

      public CompileKotlinOperation fromProject(BaseProject project)
      Configures a compile operation from a BaseProject.

      Sets the following from the project:

      Parameters:
      project - the project to configure the compile operation from
      Returns:
      this operation instance
    • mainSourceDirectories

      public CompileKotlinOperation mainSourceDirectories(File... directories)
      Provides main source directories that should be compiled.
      Parameters:
      directories - one or more main source directories
      Returns:
      this operation instance
    • mainSourceDirectories

      public CompileKotlinOperation mainSourceDirectories(Collection<File> directories)
      Provides a list of main source directories that should be compiled.
      Parameters:
      directories - a list of main source directories
      Returns:
      this operation instance
    • mainSourceDirectories

      public Collection<File> mainSourceDirectories()
      Retrieves the list of main source directories that should be compiled.
      Returns:
      the list of main source directories to compile
    • mainSourceFiles

      public CompileKotlinOperation mainSourceFiles(File... files)
      Provides main files that should be compiled.
      Parameters:
      files - one or more main files
      Returns:
      this operation instance
    • mainSourceFiles

      public CompileKotlinOperation mainSourceFiles(Collection<File> files)
      Provides a list of main files that should be compiled.
      Parameters:
      files - a list of main files
      Returns:
      this operation instance
    • mainSourceFiles

      public Collection<File> mainSourceFiles()
      Retrieves the list of main files that should be compiled.
      Returns:
      the list of main files to compile
    • plugins

      public CompileKotlinOperation plugins(String... plugins)
      Provides compiler plugins.
      Parameters:
      plugins - one or more plugins
      Returns:
      this class instance
    • plugins

      public CompileKotlinOperation plugins(Collection<String> plugins)
      Provides compiler plugins.
      Parameters:
      plugins - a list of plugins
      Returns:
      this class instance
    • plugins

      public CompileKotlinOperation plugins(File directory, CompileKotlinPlugin... plugins)
      Provides compiler plugins.
      Parameters:
      directory - the directory containing the plugin JARs
      plugins - one or more plugins
      Returns:
      this class instance
    • plugins

      public CompileKotlinOperation plugins(Collection<File> jars, CompileKotlinPlugin... plugins)
      Provides compiler plugins.
      Parameters:
      jars - the list of plugin JARs
      plugins - one or more plugins
      Returns:
      this class instance
    • testSourceDirectories

      public CompileKotlinOperation testSourceDirectories(File... directories)
      Provides test source directories that should be compiled.
      Parameters:
      directories - one or more test source directories
      Returns:
      this operation instance
    • testSourceDirectories

      public CompileKotlinOperation testSourceDirectories(Collection<File> directories)
      Provides a list of test source directories that should be compiled.
      Parameters:
      directories - a list of test source directories
      Returns:
      this operation instance
    • testSourceDirectories

      public Collection<File> testSourceDirectories()
      Retrieves the list of test source directories that should be compiled.
      Returns:
      the list of test source directories to compile
    • testSourceFiles

      public CompileKotlinOperation testSourceFiles(File... files)
      Provides test files that should be compiled.
      Parameters:
      files - one or more test files
      Returns:
      this operation instance
    • testSourceFiles

      public CompileKotlinOperation testSourceFiles(Collection<File> files)
      Provides a list of test files that should be compiled.
      Parameters:
      files - a list of test files
      Returns:
      this operation instance
    • testSourceFiles

      public Collection<File> testSourceFiles()
      Retrieves the list of test files that should be compiled.
      Returns:
      the list of test files to compile