Interface FileProject

All Superinterfaces:
Project
All Known Subinterfaces:
JavaProject, KotlinProject

public interface FileProject extends Project
Extends Project with common functionality for creating build artifacts derived from source files. All source files should be located inside the directory specified by the sourcePath() build target, and build artifacts are written to the directory specified by buildPath().

To ensure that dependencies on source files are correctly tracked, get references to source files using sourceFile(String) and sourceFiles(String).

  • Method Details

    • sourcePath

      default String sourcePath()
      Gets the root directory for the project's source code. The default source code directory is src; Override this method to specify a different location.
      Returns:
      the path of the source code directory
    • buildPath

      default String buildPath()
      Gets the root directory for the project's build artifacts. The default build artifact directory is build; Override this method to specify a different location.
      Returns:
      the path of the build directory
    • buildPath

      default String buildPath(String path)
      Generates the path of a build directory and creates the directory if it does not exist
      Parameters:
      path - a path relative to buildPath()
      Returns:
      the directory path
    • clean

      default void clean()
      Deletes the build directory specified by buildPath(). Also: The clean build target. Empties the result cache and deletes the cache file, if it exists
      Specified by:
      clean in interface Project
    • rmdir

      default void rmdir(String path)
      Deletes a directory, which must be the build directory or one of its children
      Parameters:
      path - the directory path
    • sourceFiles

      default Fileset sourceFiles(String pattern)
      Gets source files matching a pattern.
      Parameters:
      pattern - a glob pattern to search files within sourcePath()
      Returns:
      a fileset of the matching files
    • sourceFile

      default File sourceFile(String name)
      Gets a file with a specific path.
      Parameters:
      name - a file path within sourcePath()
      Returns:
      a File object referencing the specified path
    • builtFiles

      default Fileset builtFiles(String pattern)
      Gets a fileset referencing built files
      Parameters:
      pattern - a file glob pattern relative to buildPath()
      Returns:
      a fileset referencing the specified files
    • exec

      default void exec(String... command)
      Executes an external process
      Parameters:
      command - the command and arguments
    • exec

      default void exec(ProcessBuilder pb, String... command)
      Executes an external process using a supplied ProcessBuilder
      Parameters:
      pb - the process builder
      command - the command and arguments
    • read

      default String read(String name)
      Reads the contents of a text source file
      Parameters:
      name - the name of the source file
      Returns:
      the file's contents as a String
    • write

      default File write(String name, String content)
      Creates a file and writes content to it
      Parameters:
      name - a file path within buildPath()
      content - the content to write into the file
      Returns:
      a File object referencing the created file