Interface FileProject
- All Superinterfaces:
Project
- All Known Subinterfaces:
JavaProject,KotlinProject
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 Summary
Modifier and TypeMethodDescriptiondefault StringGets the root directory for the project's build artifacts.default StringGenerates the path of a build directory and creates the directory if it does not existdefault FilesetbuiltFiles(String pattern) Gets a fileset referencing built filesdefault voidclean()Deletes the build directory specified bybuildPath().default voidexec(ProcessBuilder pb, String... command) Executes an external process using a suppliedProcessBuilderdefault voidExecutes an external processdefault StringReads the contents of a text source filedefault voidDeletes a directory, which must be the build directory or one of its childrendefault FilesourceFile(String name) Gets a file with a specific path.default FilesetsourceFiles(String pattern) Gets source files matching a pattern.default StringGets the root directory for the project's source code.default FileCreates a file and writes content to it
-
Method Details
-
sourcePath
Gets the root directory for the project's source code. The default source code directory issrc; Override this method to specify a different location.- Returns:
- the path of the source code directory
-
buildPath
Gets the root directory for the project's build artifacts. The default build artifact directory isbuild; Override this method to specify a different location.- Returns:
- the path of the build directory
-
buildPath
Generates the path of a build directory and creates the directory if it does not exist- Parameters:
path- a path relative tobuildPath()- Returns:
- the directory path
-
clean
default void clean()Deletes the build directory specified bybuildPath(). Also: Thecleanbuild target. Empties the result cache and deletes the cache file, if it exists -
rmdir
Deletes a directory, which must be the build directory or one of its children- Parameters:
path- the directory path
-
sourceFiles
Gets source files matching a pattern.- Parameters:
pattern- a glob pattern to search files withinsourcePath()- Returns:
- a fileset of the matching files
-
sourceFile
Gets a file with a specific path.- Parameters:
name- a file path withinsourcePath()- Returns:
- a File object referencing the specified path
-
builtFiles
Gets a fileset referencing built files- Parameters:
pattern- a file glob pattern relative tobuildPath()- Returns:
- a fileset referencing the specified files
-
exec
Executes an external process- Parameters:
command- the command and arguments
-
exec
Executes an external process using a suppliedProcessBuilder- Parameters:
pb- the process buildercommand- the command and arguments
-
read
-
write
Creates a file and writes content to it- Parameters:
name- a file path withinbuildPath()content- the content to write into the file- Returns:
- a File object referencing the created file
-