diff --git a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPageCompileTask.groovy b/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPageCompileTask.groovy deleted file mode 100644 index f66786df..00000000 --- a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPageCompileTask.groovy +++ /dev/null @@ -1,78 +0,0 @@ -package org.grails.gradle.plugin.web.gsp - -import groovy.transform.CompileDynamic -import groovy.transform.CompileStatic -import org.gradle.api.Project -import org.gradle.api.internal.project.IsolatedAntBuilder -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputDirectory -import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.TaskAction -import org.gradle.api.tasks.compile.AbstractCompile - -/** - * A task for compiling GSPs - * - * @author Graeme Rocher - * @since 3.0 - */ -@CompileStatic -class GroovyPageCompileTask extends AbstractCompile { - - @Input - @Optional - String packagename - - @Input - @Optional - String serverpath - - @InputDirectory - File srcDir - - @Override - void setSource(Object source) { - try { - srcDir = project.file(source) - if(srcDir.exists() && !srcDir.isDirectory()) { - throw new IllegalArgumentException("The source for GSP compilation must be a single directory, but was $source") - } - super.setSource(source) - } catch (e) { - throw new IllegalArgumentException("The source for GSP compilation must be a single directory, but was $source") - } - } - - @TaskAction - @CompileDynamic - protected void execute() { - - def compileTask = this - Project gradleProject = project - def antBuilder = gradleProject.services.get(IsolatedAntBuilder) - String packagename = packagename ?: project.name - String serverpath = serverpath ?: "/" - - antBuilder.withClasspath(classpath).execute { - taskdef(name: 'gspc', classname: 'org.grails.web.pages.GroovyPageCompilerTask') - def dest = compileTask.destinationDir - def tmpdir = new File(gradleProject.buildDir, "gsptmp") - dest.mkdirs() - - gspc(destdir: dest, - srcdir: compileTask.srcDir, - packagename: packagename, - serverpath: serverpath, - tmpdir: tmpdir) { - delegate.configs { - pathelement(path: gradleProject.file('grails-app/conf/application.yml').absolutePath) - pathelement(path: gradleProject.file('grails-app/conf/application.groovy').absolutePath) - } - delegate.classpath { - pathelement(path: dest.absolutePath) - pathelement(path: compileTask.classpath.asPath) - } - } - } - } -} diff --git a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPageForkCompileTask.groovy b/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPageForkCompileTask.groovy index 043520f1..6d8cdc43 100644 --- a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPageForkCompileTask.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPageForkCompileTask.groovy @@ -4,11 +4,13 @@ import groovy.transform.CompileDynamic import groovy.transform.CompileStatic import org.gradle.api.Action import org.gradle.api.file.FileTree +import org.gradle.api.model.ObjectFactory import org.gradle.api.tasks.* import org.gradle.api.tasks.compile.AbstractCompile import org.gradle.process.ExecResult import org.gradle.process.JavaExecSpec +import javax.inject.Inject import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths @@ -22,7 +24,7 @@ import java.nio.file.Paths * @since 4.0 */ @CompileStatic -class GroovyPageForkCompileTask extends AbstractCompile { +abstract class GroovyPageForkCompileTask extends AbstractCompile { @Input @Optional @@ -46,8 +48,13 @@ class GroovyPageForkCompileTask extends AbstractCompile { @Optional String serverpath + @Inject + protected ObjectFactory getObjectFactory() { + throw new UnsupportedOperationException(); + } + @Nested - GspCompileOptions compileOptions = new GspCompileOptions() + GspCompileOptions compileOptions = getObjectFactory().newInstance(GspCompileOptions.class) @Override @PathSensitive(PathSensitivity.RELATIVE) diff --git a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GspCompileOptions.groovy b/src/main/groovy/org/grails/gradle/plugin/web/gsp/GspCompileOptions.groovy index d093490f..a21376fb 100644 --- a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GspCompileOptions.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/web/gsp/GspCompileOptions.groovy @@ -1,22 +1,29 @@ package org.grails.gradle.plugin.web.gsp +import org.gradle.api.model.ObjectFactory import org.gradle.api.tasks.Input import org.gradle.api.tasks.Nested -import org.gradle.api.tasks.compile.BaseForkOptions +import org.gradle.api.tasks.compile.AbstractOptions import org.gradle.api.tasks.compile.GroovyForkOptions +import javax.inject.Inject; /** -* Presents the Compile Options used by the {@llink GroovyPageForkCompileTask} -* -* @author David Estes -* @since 4.0 -*/ -class GspCompileOptions implements Serializable { + * Presents the Compile Options used by the {@llink GroovyPageForkCompileTask} + * + * @author David Estes + * @since 4.0 + */ +abstract class GspCompileOptions extends AbstractOptions { private static final long serialVersionUID = 0L; @Input - String encoding = "UTF-8" + String encoding = "UTF-8" + + @Inject + protected ObjectFactory getObjectFactory() { + throw new UnsupportedOperationException(); + } @Nested - GroovyForkOptions forkOptions = new GroovyForkOptions() + GroovyForkOptions forkOptions = getObjectFactory().newInstance(GroovyForkOptions.class) } \ No newline at end of file