Permalink
Browse files

Merge branch '3.1.x' into 3.2.x

  • Loading branch information...
2 parents 94a1833 + 721289b commit c80a7c618adae933ffd5d2946fdc64dd78b0086e @jeffbrown jeffbrown committed Oct 25, 2016
Showing with 352 additions and 34 deletions.
  1. +1 −1 build.gradle
  2. +2 −2 grails-core/src/main/groovy/org/grails/compiler/injection/EnhancesTraitTransformation.groovy
  3. +3 −9 ...core/src/main/groovy/org/grails/compiler/injection/GlobalGrailsClassInjectorTransformation.groovy
  4. +0 −10 grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
  5. +0 −1 grails-plugin-async/src/main/groovy/grails/artefact/AsyncController.groovy
  6. +33 −0 grails-plugin-async/src/main/groovy/grails/compiler/traits/AsyncControllerTraitInjector.groovy
  7. +1 −0 grails-plugin-async/src/main/resources/META-INF/grails.factories
  8. +0 −1 grails-plugin-controllers/src/main/groovy/grails/artefact/Controller.groovy
  9. +43 −0 grails-plugin-controllers/src/main/groovy/grails/compiler/traits/ControllerTraitInjector.groovy
  10. +1 −0 grails-plugin-controllers/src/main/resources/META-INF/grails.factories
  11. +2 −0 ...test/groovy/org/grails/compiler/web/ControllerActionTransformerClosureActionOverridingSpec.groovy
  12. +2 −0 ...plugin-controllers/src/test/groovy/org/grails/compiler/web/ControllerActionTransformerSpec.groovy
  13. +0 −1 grails-plugin-domain-class/src/main/groovy/grails/artefact/DomainClass.groovy
  14. +38 −0 grails-plugin-domain-class/src/main/groovy/grails/compiler/traits/DomainClassTraitInjector.groovy
  15. +1 −0 grails-plugin-domain-class/src/main/resources/META-INF/grails.factories
  16. +36 −0 grails-plugin-gsp/src/ast/groovy/grails/compiler/traits/ControllerTagLibraryTraitInjector.groovy
  17. +1 −0 grails-plugin-gsp/src/main/resources/META-INF/grails.factories
  18. +0 −1 grails-plugin-interceptors/src/main/groovy/grails/artefact/Interceptor.groovy
  19. +39 −0 grails-plugin-interceptors/src/main/groovy/grails/compiler/traits/InterceptorTraitInjector.groovy
  20. +1 −0 grails-plugin-interceptors/src/main/resources/META-INF/grails.factories
  21. +0 −2 grails-plugin-rest/src/main/groovy/grails/artefact/controller/RestResponder.groovy
  22. +32 −0 grails-plugin-rest/src/main/groovy/grails/compiler/traits/RestResponderTraitInjector.groovy
  23. +1 −0 grails-plugin-rest/src/main/resources/META-INF/grails.factories
  24. +0 −1 grails-plugin-services/src/main/groovy/grails/artefact/Service.groovy
  25. +38 −0 grails-plugin-services/src/main/groovy/grails/compiler/traits/ServiceTraitInjector.groovy
  26. +1 −0 grails-plugin-services/src/main/resources/META-INF/grails.factories
  27. +37 −0 grails-web-databinding/src/main/groovy/grails/compiler/traits/WebDataBindingTraitInjector.groovy
  28. +0 −2 grails-web-databinding/src/main/groovy/grails/web/databinding/WebDataBinding.groovy
  29. +1 −0 grails-web-databinding/src/main/resources/META-INF/grails.factories
  30. +0 −1 grails-web-taglib/src/main/groovy/grails/artefact/TagLibrary.groovy
  31. +0 −2 grails-web-taglib/src/main/groovy/grails/artefact/gsp/TagLibraryInvoker.groovy
  32. +37 −0 grails-web-taglib/src/main/groovy/grails/compiler/traits/TagLibraryTraitInjector.groovy
  33. +1 −0 grails-web-taglib/src/main/resources/META-INF/grails.factories
View
@@ -472,7 +472,7 @@ subprojects { project ->
}
}
- compileGroovy.dependsOn processResources
+
}
@@ -86,8 +86,8 @@ class EnhancesTraitTransformation extends AbstractArtefactTypeAstTransformation
ast.classes.add transformerNode
- def resourcesTargetDirectory = GlobalGrailsClassInjectorTransformation.resolveResourcesTargetDirectory(source)
- GlobalGrailsClassInjectorTransformation.updateGrailsFactoriesWithType(transformerNode, GlobalGrailsClassInjectorTransformation.TRAIT_INJECTOR_CLASS, resourcesTargetDirectory)
+ def compilationTargetDirectory = GlobalGrailsClassInjectorTransformation.resolveCompilationTargetDirectory(source)
+ GlobalGrailsClassInjectorTransformation.updateGrailsFactoriesWithType(transformerNode, GlobalGrailsClassInjectorTransformation.TRAIT_INJECTOR_CLASS, compilationTargetDirectory)
}
@@ -5,7 +5,6 @@ import grails.compiler.ast.ClassInjector
import grails.core.ArtefactHandler
import grails.io.IOUtils
import grails.plugins.metadata.GrailsPlugin
-import grails.util.BuildSettings
import grails.util.GrailsNameUtils
import groovy.transform.CompilationUnitAware
import groovy.transform.CompileDynamic
@@ -65,7 +64,7 @@ class GlobalGrailsClassInjectorTransformation implements ASTTransformation, Comp
Set<String> transformedClasses = []
String pluginVersion = null
ClassNode pluginClassNode = null
- def compilationTargetDirectory = resolveResourcesTargetDirectory(source)
+ def compilationTargetDirectory = resolveCompilationTargetDirectory(source)
def pluginXmlFile = new File(compilationTargetDirectory, "META-INF/grails-plugin.xml")
for (ClassNode classNode : classes) {
@@ -143,10 +142,6 @@ class GlobalGrailsClassInjectorTransformation implements ASTTransformation, Comp
generatePluginXml(pluginClassNode, pluginVersion, transformedClasses, pluginXmlFile)
}
- static File resolveResourcesTargetDirectory(SourceUnit source) {
- BuildSettings.RESOURCES_DIR ?: new File(resolveCompilationTargetDirectory(source), '../../resources/main/')
- }
-
static File resolveCompilationTargetDirectory(SourceUnit source) {
File targetDirectory = source.configuration.targetDirectory
if(targetDirectory==null && source.getClass().name == 'org.codehaus.jdt.groovy.control.EclipseSourceUnit') {
@@ -155,14 +150,13 @@ class GlobalGrailsClassInjectorTransformation implements ASTTransformation, Comp
return targetDirectory
}
- static boolean updateGrailsFactoriesWithType(ClassNode classNode, ClassNode superType, File targetDirectory) {
+ static boolean updateGrailsFactoriesWithType(ClassNode classNode, ClassNode superType, File compilationTargetDirectory) {
if (GrailsASTUtils.isSubclassOfOrImplementsInterface(classNode, superType)) {
if(Modifier.isAbstract(classNode.getModifiers())) return false
def classNodeName = classNode.name
// generate META-INF/grails.factories
-
- def factoriesFile = new File(targetDirectory, "META-INF/grails.factories")
+ def factoriesFile = new File(compilationTargetDirectory, "META-INF/grails.factories")
factoriesFile.parentFile.mkdirs()
def props = new Properties()
def superTypeName = superType.getName()
@@ -127,8 +127,6 @@ class GrailsGradlePlugin extends GroovyPlugin {
configureRunCommand(project)
configurePathingJar(project)
-
- configureResourceProcessing(project)
}
protected void configureProfile(Project project) {
@@ -233,14 +231,6 @@ class GrailsGradlePlugin extends GroovyPlugin {
System.setProperty(BuildSettings.APP_BASE_DIR, project.projectDir.absolutePath)
}
- protected void configureResourceProcessing(Project project) {
- def tasks = project.tasks
- def resourcesTask = tasks.findByName('processResources')
- if (resourcesTask) {
- tasks.findByName('compileGroovy')?.dependsOn resourcesTask
- }
- }
-
protected void configureApplicationCommands(Project project) {
def applicationContextCommands = FactoriesLoaderSupport.loadFactoryNames(APPLICATION_CONTEXT_COMMAND_CLASS)
for (ctxCommand in applicationContextCommands) {
@@ -37,7 +37,6 @@ import org.springframework.web.context.request.RequestContextHolder
*
*/
@CompileStatic
-@Enhances('Controller')
trait AsyncController extends Events {
/**
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package grails.compiler.traits
+
+import grails.artefact.AsyncController
+
+/**
+ *
+ * @author Jeff Brown
+ * @since 3.0
+ *
+ */
+class AsyncControllerTraitInjector extends ControllerTraitInjector {
+
+ @Override
+ Class getTrait() {
+ AsyncController
+ }
+
+}
@@ -0,0 +1 @@
+grails.compiler.traits.TraitInjector=grails.compiler.traits.AsyncControllerTraitInjector
@@ -66,7 +66,6 @@ import java.lang.reflect.Method
*
*/
@CompileStatic
-@Enhances('Controller')
trait Controller implements ResponseRenderer, ResponseRedirector, RequestForwarder, DataBinder, WebAttributes, ServletAttributes {
private MimeTypesApiSupport mimeTypesSupport = new MimeTypesApiSupport()
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package grails.compiler.traits
+
+import grails.artefact.Controller
+import groovy.transform.CompileStatic
+
+/**
+ *
+ * A {@link TraitInjector} that injects controllers with the {@link Controller} trait
+ *
+ * @author Jeff Brown
+ * @author Graeme Rocher
+ *
+ * @since 3.0
+ *
+ */
+@CompileStatic
+class ControllerTraitInjector implements TraitInjector {
+
+ @Override
+ Class getTrait() {
+ Controller
+ }
+
+ @Override
+ String[] getArtefactTypes() {
+ ['Controller'] as String[]
+ }
+}
@@ -0,0 +1 @@
+grails.compiler.traits.TraitInjector=grails.compiler.traits.ControllerTraitInjector
@@ -1,6 +1,8 @@
package org.grails.compiler.web
import grails.compiler.ast.ClassInjector
+import grails.compiler.traits.ControllerTraitInjector
+import grails.compiler.traits.TraitInjector
import grails.util.GrailsWebMockUtil
import org.grails.compiler.injection.GrailsAwareClassLoader
@@ -1,6 +1,8 @@
package org.grails.compiler.web
import grails.compiler.ast.ClassInjector
+import grails.compiler.traits.ControllerTraitInjector
+import grails.compiler.traits.TraitInjector
import grails.util.BuildSettings
import grails.util.GrailsWebMockUtil
import grails.web.Action
@@ -32,7 +32,6 @@ import org.grails.core.artefact.DomainClassArtefactHandler
*
*/
@CompileStatic
-@Enhances('Domain')
trait DomainClass {
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package grails.compiler.traits
+
+import grails.artefact.DomainClass
+import org.grails.core.artefact.DomainClassArtefactHandler
+
+/**
+ *
+ * @author Jeff Brown
+ * @since 3.0
+ *
+ */
+class DomainClassTraitInjector implements TraitInjector {
+
+ Class getTrait() {
+ DomainClass
+ }
+
+
+ @Override
+ String[] getArtefactTypes() {
+ [DomainClassArtefactHandler.TYPE]
+ }
+}
@@ -0,0 +1 @@
+grails.compiler.traits.TraitInjector=grails.compiler.traits.DomainClassTraitInjector
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2014 original authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package grails.compiler.traits
+
+import grails.artefact.gsp.TagLibraryInvoker
+import groovy.transform.CompileStatic
+
+
+
+/**
+ * A {@link TraitInjector} that adds the ability to invoke tag libraries from a controller
+ *
+ * @author Graeme Rocher
+ * @since 3.0
+ */
+@CompileStatic
+class ControllerTagLibraryTraitInjector extends ControllerTraitInjector {
+
+ @Override
+ Class getTrait() {
+ TagLibraryInvoker
+ }
+}
@@ -0,0 +1 @@
+grails.compiler.traits.TraitInjector=grails.compiler.traits.ControllerTagLibraryTraitInjector
@@ -50,7 +50,6 @@ import java.util.regex.Pattern
* @since 3.0
*/
@CompileStatic
-@Enhances('Interceptor')
trait Interceptor implements ResponseRenderer, ResponseRedirector, RequestForwarder, DataBinder, WebAttributes, ServletAttributes, Ordered {
/**
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2015 original authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package grails.compiler.traits
+
+import grails.artefact.Interceptor
+import groovy.transform.CompileStatic
+
+/**
+ * Injects the {@link Interceptor} trait by convention
+ *
+ * @author Graeme Rocher
+ * @since 3.0
+ */
+@CompileStatic
+class InterceptorTraitInjector implements TraitInjector {
+
+ @Override
+ Class getTrait() {
+ Interceptor
+ }
+
+ @Override
+ String[] getArtefactTypes() {
+ ['Interceptor'] as String[]
+ }
+}
@@ -1 +1,2 @@
+grails.compiler.traits.TraitInjector=grails.compiler.traits.InterceptorTraitInjector
grails.core.ArtefactHandler=org.grails.plugins.web.interceptors.InterceptorArtefactHandler
@@ -15,7 +15,6 @@
*/
package grails.artefact.controller
-import grails.artefact.Enhances
import groovy.transform.CompileDynamic
import grails.artefact.Controller
import grails.artefact.controller.support.ResponseRenderer
@@ -45,7 +44,6 @@ import org.springframework.validation.Errors
*
*/
@CompileStatic
-@Enhances('Controller')
trait RestResponder {
private String PROPERTY_RESPONSE_FORMATS = "responseFormats"
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package grails.compiler.traits
+
+import grails.artefact.controller.RestResponder
+
+/**
+ *
+ * @author Jeff Brown
+ * @since 3.0
+ *
+ */
+class RestResponderTraitInjector extends ControllerTraitInjector {
+
+ @Override
+ Class getTrait() {
+ RestResponder
+ }
+}
@@ -0,0 +1 @@
+grails.compiler.traits.TraitInjector=grails.compiler.traits.RestResponderTraitInjector
Oops, something went wrong.

0 comments on commit c80a7c6

Please sign in to comment.