Skip to content

Commit 5057f8f

Browse files
authored
Merge pull request #1250 from rainboyan
* pr/1250: Create grace-plugin-taglibs Closes gh-1250
2 parents 7457d09 + 7dc73ae commit 5057f8f

File tree

74 files changed

+803
-114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+803
-114
lines changed

grace-plugin-gsp/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
dependencies {
22
compileOnly libs.jakarta.servlet
3-
api libs.commons.text
43
api project(":grace-core")
54
api project(":grace-plugin-api")
65
api project(":grace-plugin-codecs")
6+
implementation project(":grace-plugin-taglibs")
77
api project(":grace-web-gsp")
88
api project(":grace-web-mvc")
9-
api project(":grace-web-taglib")
109
api project(":grace-web-url-mappings")
1110
api libs.spring.boot.autoconfigure
1211
annotationProcessor libs.spring.boot.autoconfigureProcessor

grace-plugin-gsp/src/main/groovy/org/grails/plugins/web/GroovyPagesAutoConfiguration.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
import org.grails.web.pages.GroovyPagesServlet;
6565
import org.grails.web.servlet.view.GroovyPageViewResolver;
6666
import org.grails.web.sitemesh.GroovyPageLayoutFinder;
67-
import org.grails.web.taglib.StandaloneTagLibraryLookup;
6867
import org.grails.web.util.GrailsApplicationAttributes;
6968

7069
/**
@@ -190,12 +189,6 @@ public FilteringCodecsByContentTypeSettings filteringCodecsByContentTypeSettings
190189
return new FilteringCodecsByContentTypeSettings(grailsApplication.getIfAvailable());
191190
}
192191

193-
@Bean
194-
@ConditionalOnMissingBean
195-
public DefaultGrailsTagDateHelper grailsTagDateHelper() {
196-
return new DefaultGrailsTagDateHelper();
197-
}
198-
199192
@Bean
200193
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
201194
public ServletRegistrationBean<GroovyPagesServlet> groovyPagesServlet() {
@@ -253,14 +246,6 @@ public GroovyPageViewResolver jspViewResolver(GroovyPagesProperties groovyPagesP
253246
return groovyPageViewResolver;
254247
}
255248

256-
@Bean
257-
@ConditionalOnMissingBean
258-
public StandaloneTagLibraryLookup gspTagLibraryLookup(ObjectProvider<GrailsApplication> grailsApplication) {
259-
StandaloneTagLibraryLookup tagLibraryLookup = new StandaloneTagLibraryLookup();
260-
grailsApplication.ifAvailable(tagLibraryLookup::setGrailsApplication);
261-
return tagLibraryLookup;
262-
}
263-
264249
@Bean({"groovyTemplateEngine", "groovyPagesTemplateEngine"})
265250
@ConditionalOnMissingBean
266251
public GroovyPagesTemplateEngine groovyPagesTemplateEngine(

grace-plugin-gsp/src/main/groovy/org/grails/plugins/web/GroovyPagesGrailsPlugin.groovy

Lines changed: 3 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2004-2024 the original author or authors.
2+
* Copyright 2004-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,24 +18,10 @@ package org.grails.plugins.web
1818
import groovy.transform.CompileStatic
1919
import org.springframework.core.Ordered
2020

21-
import grails.core.gsp.GrailsTagLibClass
2221
import grails.plugins.Plugin
2322
import grails.util.GrailsUtil
2423
import grails.web.pages.GroovyPagesUriService
25-
import org.grails.core.artefact.gsp.TagLibArtefactHandler
2624
import org.grails.gsp.GroovyPagesTemplateEngine
27-
import org.grails.plugins.web.taglib.ApplicationTagLib
28-
import org.grails.plugins.web.taglib.CountryTagLib
29-
import org.grails.plugins.web.taglib.FormTagLib
30-
import org.grails.plugins.web.taglib.FormatTagLib
31-
import org.grails.plugins.web.taglib.JavascriptTagLib
32-
import org.grails.plugins.web.taglib.PluginTagLib
33-
import org.grails.plugins.web.taglib.RenderTagLib
34-
import org.grails.plugins.web.taglib.SitemeshTagLib
35-
import org.grails.plugins.web.taglib.UrlMappingTagLib
36-
import org.grails.plugins.web.taglib.ValidationTagLib
37-
import org.grails.taglib.TagLibraryLookup
38-
import org.grails.taglib.TagLibraryMetaUtils
3925
import org.grails.web.pages.FilteringCodecsByContentTypeSettings
4026

4127
/**
@@ -54,49 +40,14 @@ class GroovyPagesGrailsPlugin extends Plugin implements Ordered {
5440
def version = GrailsUtil.getGrailsVersion()
5541
def dependsOn = [core: GrailsUtil.getGrailsVersion()]
5642

57-
def watchedResources = ["file:./plugins/*/grails-app/taglib/**/*TagLib.groovy",
58-
"file:./grails-app/taglib/**/*TagLib.groovy",
59-
"file:./plugins/*/app/taglib/**/*TagLib.groovy",
60-
"file:./app/taglib/**/*TagLib.groovy"]
61-
62-
def providedArtefacts = [
63-
ApplicationTagLib,
64-
CountryTagLib,
65-
FormatTagLib,
66-
FormTagLib,
67-
JavascriptTagLib,
68-
RenderTagLib,
69-
UrlMappingTagLib,
70-
ValidationTagLib,
71-
PluginTagLib,
72-
SitemeshTagLib
73-
]
74-
7543
int order = 600
7644

7745
/**
7846
* Configures the various Spring beans required by GSP
7947
*/
80-
Closure doWithSpring() {
81-
{ ->
82-
def application = grailsApplication
83-
84-
// Now go through tag libraries and configure them in Spring too. With AOP proxies and so on
85-
def taglibs = application.getArtefacts(TagLibArtefactHandler.TYPE)
86-
for (taglib in taglibs) {
87-
final tagLibClass = taglib.clazz
88-
89-
"${taglib.fullName}"(tagLibClass) { bean ->
90-
bean.autowire = true
91-
bean.lazyInit = true
48+
Closure doWithSpring() { { ->
9249

93-
// Taglib scoping support could be easily added here. Scope could be based on a static field in the taglib class.
94-
//bean.scope = 'request'
95-
}
96-
}
97-
98-
}
99-
}
50+
} }
10051

10152
/**
10253
* Clear the page cache with the ApplicationContext is loaded
@@ -109,27 +60,8 @@ class GroovyPagesGrailsPlugin extends Plugin implements Ordered {
10960

11061
@Override
11162
void onChange(Map<String, Object> event) {
112-
def application = grailsApplication
11363
def ctx = applicationContext
11464

115-
if (application.isArtefactOfType(TagLibArtefactHandler.TYPE, event.source)) {
116-
GrailsTagLibClass taglibClass = (GrailsTagLibClass) application.addArtefact(TagLibArtefactHandler.TYPE, event.source)
117-
if (taglibClass) {
118-
// replace tag library bean
119-
def beanName = taglibClass.fullName
120-
beans {
121-
"$beanName"(taglibClass.clazz) { bean ->
122-
bean.autowire = true
123-
}
124-
}
125-
126-
// The tag library lookup class caches "tag -> taglib class"
127-
// so we need to update it now.
128-
def lookup = applicationContext.getBean('gspTagLibraryLookup', TagLibraryLookup)
129-
lookup.registerTagLib(taglibClass)
130-
TagLibraryMetaUtils.enhanceTagLibMetaClass(taglibClass, lookup)
131-
}
132-
}
13365
// clear uri cache after changes
13466
ctx.getBean('groovyPagesUriService', GroovyPagesUriService).clear()
13567
}

grace-plugin-gsp/src/test/groovy/org/grails/web/taglib/AbstractGrailsTagTests.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import org.grails.plugins.codecs.URLCodec
7171
import org.grails.plugins.core.CoreConfiguration
7272
import org.grails.plugins.databinding.DataBindingConfiguration
7373
import org.grails.plugins.support.PluginManagerAwareBeanPostProcessor
74+
import org.grails.plugins.web.GrailsTagLibraryAutoConfiguration
7475
import org.grails.plugins.web.GroovyPagesAutoConfiguration
7576
import org.grails.plugins.web.controllers.ControllersPluginConfiguration
7677
import org.grails.plugins.web.mapping.UrlMappingsPluginConfiguration
@@ -102,6 +103,7 @@ abstract class AbstractGrailsTagTests {
102103
CodecsPluginConfiguration,
103104
ControllersPluginConfiguration,
104105
DataBindingConfiguration,
106+
GrailsTagLibraryAutoConfiguration,
105107
GroovyPagesAutoConfiguration,
106108
MimeTypesConfiguration,
107109
UrlMappingsPluginConfiguration]
@@ -317,6 +319,7 @@ class MockController {
317319
dependantPluginClasses << gcl.loadClass("org.grails.plugins.web.mapping.UrlMappingsGrailsPlugin")
318320
dependantPluginClasses << gcl.loadClass("org.grails.plugins.web.controllers.ControllersGrailsPlugin")
319321
dependantPluginClasses << gcl.loadClass("org.grails.plugins.web.GroovyPagesGrailsPlugin")
322+
dependantPluginClasses << gcl.loadClass("org.grails.plugins.web.TaglibsGrailsPlugin")
320323

321324
List<DefaultGrailsPlugin> dependentPlugins = dependantPluginClasses.collect {
322325
new DefaultGrailsPlugin(it, new DescriptiveResource(it.toString()), grailsApplication)

grace-plugin-rest/build.gradle

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ dependencies {
2020
transitive = false
2121
}
2222
compileOnly libs.grace.datastore.gorm.support
23-
compileOnly(project(":grace-web-gsp")) {
24-
exclude group:'org.graceframework', module:'grace-core'
25-
exclude group:'org.graceframework', module:'grace-encoder'
26-
exclude group:'org.graceframework', module:'grace-web-common'
27-
}
23+
compileOnly project(":grace-web-gsp")
2824
implementation libs.caffeine
2925

3026
testImplementation libs.jakarta.servlet

grace-plugin-taglibs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## grace-plugin-taglibs

grace-plugin-taglibs/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
dependencies {
2+
compileOnly libs.jakarta.servlet
3+
api libs.commons.text
4+
api project(":grace-core")
5+
api project(":grace-plugin-api")
6+
api project(":grace-plugin-codecs")
7+
api project(":grace-web-gsp")
8+
api project(":grace-web-mvc")
9+
api project(":grace-web-taglib")
10+
api project(":grace-web-url-mappings")
11+
api libs.spring.boot.autoconfigure
12+
annotationProcessor libs.spring.boot.autoconfigureProcessor
13+
annotationProcessor libs.spring.boot.configurationProcessor
14+
15+
testImplementation libs.spring.test
16+
testImplementation project(":grace-test-support")
17+
}

grace-plugin-gsp/src/main/groovy/grails/compiler/traits/ControllerTagLibraryTraitInjector.groovy renamed to grace-plugin-taglibs/src/main/groovy/grails/compiler/traits/ControllerTagLibraryTraitInjector.groovy

File renamed without changes.

grace-plugin-gsp/src/main/groovy/org/grails/plugins/web/DefaultGrailsTagDateHelper.groovy renamed to grace-plugin-taglibs/src/main/groovy/org/grails/plugins/web/DefaultGrailsTagDateHelper.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2004-2022 the original author or authors.
2+
* Copyright 2004-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

grace-plugin-gsp/src/main/groovy/org/grails/plugins/web/GrailsTagDateHelper.groovy renamed to grace-plugin-taglibs/src/main/groovy/org/grails/plugins/web/GrailsTagDateHelper.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2004-2022 the original author or authors.
2+
* Copyright 2004-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)