@CompileStatic @org.gradle.api.tasks.CacheableTask abstract class GroovyPageForkCompileTask extends AbstractCompile
Abstract Gradle task for compiling templates, using GroovyPageForkedCompiler This Task is a Forked Java Task that is configurable with fork options provided by ViewCompileOptions
Cacheable. What a page compiles to depends on the Groovy that compiles it, the Java it is
compiled for and the classes it is compiled against, and each of them is part of the key. The
compiler runs from getClasspath(), which AbstractCompile declares a classpath
input, fingerprinted by content, so a build that resolves another Groovy is not handed this one's
pages; getJavaLauncher() and the target compatibility say which Java. The Grails
environment whose configuration the pages are compiled with, getGrailsEnvironment(), is
part of the key too. The pages are fingerprinted by their path under the source, so a checkout in
another directory reuses what this one compiled.
Compiles every page, from an empty destination, each time it runs; see ViewCompileDestination. The compiler's own economy, of leaving a page alone whose class is newer than its source, would otherwise carry pages of another environment, classpath or configuration, or pages that no longer exist, into the archive and the build cache.
| Type | Name and description |
|---|---|
ViewCompileOptions |
compileOptions |
Property<java.lang.Boolean> |
compileStaticWhether the pages this task compiles are compiled statically. |
Property<java.lang.Boolean> |
compileStaticStrictWhether the pages this task compiles are held to the names they declare. |
DirectoryProperty |
destinationDirectoryWhere the pages are compiled to. |
ConfigurableFileCollection |
generatedViewsDirectories of pages the build generated, compiled in the same compilation as the source, each page named by its path under the directory holding it, as though it were in the source, where a page at the same path takes precedence. |
ConfigurableFileCollection |
grailsConfigurationPaths |
Property<java.lang.String> |
grailsEnvironmentThe Grails environment the pages are compiled for, by name. |
ConfigurableFileCollection |
optionalPagesFiles that each name, one per line, pages of the source that are optional, as paths relative to it. |
Property<java.lang.String> |
packageName |
Property<java.lang.String> |
serverpath |
FileTree |
source |
DirectoryProperty |
srcDirThe directory of the pages, which the compiler names them under. |
java.lang.String |
tmpDirPath |
| Constructor and description |
|---|
GroovyPageForkCompileTask(ExecOperations execOperations, ObjectFactory objectFactory) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
protected void |
compile() |
|
void |
execute() |
|
FileTree |
getAllPages()Every page beneath getSrcDir(), as the compiler reads them: it finds the pages by the directory and compiles them all, so a page the task's own filters leave out of getSource() is compiled all the same, and is an input all the same. |
|
protected java.lang.String |
getCompilerName() |
|
java.lang.String |
getFileExtension() |
|
protected FileSystemOperations |
getFileSystemOperations()Gradle's file operations, which empty the destination; Gradle supplies them to the task it generates. |
|
abstract Property<JavaLauncher> |
getJavaLauncher()The Java runtime the pages are compiled by. |
|
FileTree |
getSource() |
|
java.lang.String |
getStatedEnvironment()The environment stated to the forked compiler, as the grails.env system property in
place of any the fork options name, so that nothing the compiler inherits decides:
getGrailsEnvironment() by the environment's full name, which is what the pages are
compiled for and so what the cache key holds. |
|
void |
prepareArguments(java.util.List<java.lang.String> arguments) |
|
void |
setSource(java.lang.Object source) |
Whether the pages this task compiles are compiled statically.
Stated to the forked compiler as the grails.views.gsp.compileStatic system property,
which is the same setting grails-app/conf/application.yml carries and the same one the
running application reads, so that a page compiled here compiles the same way there.
Whether the pages this task compiles are held to the names they declare. See compileStatic.
Where the pages are compiled to. Emptied before each compilation, so a directory of the task's own, within the build directory; see ViewCompileDestination.
Directories of pages the build generated, compiled in the same compilation as the source, each
page named by its path under the directory holding it, as though it were in the source, where a
page at the same path takes precedence. Part of getSource(), so a project whose only
pages are generated compiles them. One compilation rather than two, because each would write a
gsp/views.properties and an archive keeps only the first.
The Grails environment the pages are compiled for, by name.
A page is compiled against the configuration of one environment: the forked compiler merges
that environment's block of application.yml and application.groovy over the rest
before it reads the codecs and the other settings a page carries once compiled. The environment
is therefore part of what the pages are, and part of the cache key, so pages compiled for one
environment are not restored into a build for another.
Defaults as ViewCompileEnvironment#defaultFor#defaultFor says: to an environment the fork
options of getCompileOptions() already name, else to the one the build runs with, else
to development. Read as getStatedEnvironment(), which is the input.
Files that each name, one per line, pages of the source that are optional, as paths relative to it. An optional page that does not compile is left out with a warning rather than failing the build: a page generated from a template a dependency supplies is an optimisation, and without it the page is produced when it is first rendered.
The directory of the pages, which the compiler names them under. Internal rather than an input directory: its pages are fingerprinted as part of getSource(), and it need not exist - a project whose only pages are generated, a plugin that scaffolds controllers and has no views of its own, has none, and an input directory that does not exist fails validation. The pages beneath it are an input all the same, as getAllPages(), since the compiler finds them by the directory.
Every page beneath getSrcDir(), as the compiler reads them: it finds the pages by the directory and compiles them all, so a page the task's own filters leave out of getSource() is compiled all the same, and is an input all the same. Fingerprinted by path under the directory, so a checkout elsewhere reuses what this one compiled.
Gradle's file operations, which empty the destination; Gradle supplies them to the task it generates.
The Java runtime the pages are compiled by.
Compilation is forked, and a forked process runs whatever JVM it is given rather than the
one the project asked for. Left to itself it inherits the JVM running Gradle, so a project
declaring a toolchain gets its pages compiled by a different Java than everything else it
builds -- which shows up as an UnsupportedClassVersionError at the moment a page is
first rendered, long after the build called itself successful.
Nested rather than internal because the Java that did the compiling is part of what the result is: pages built by one are not left standing when the build asks for another.
The environment stated to the forked compiler, as the grails.env system property in
place of any the fork options name, so that nothing the compiler inherits decides:
getGrailsEnvironment() by the environment's full name, which is what the pages are
compiled for and so what the cache key holds. A blank grailsEnvironment fails the build
here, before anything is compiled or removed.