From da5b1790dc7fa489c46effc590b480fa303c6378 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Sun, 17 Nov 2024 19:08:22 -0800 Subject: [PATCH 01/15] I18nAutoConfiguration --- .../plugins/i18n/I18nAutoConfiguration.java | 21 +++++++++++++++++++ .../plugins/i18n/I18nGrailsPlugin.groovy | 2 -- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java diff --git a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java new file mode 100644 index 00000000000..605561621b6 --- /dev/null +++ b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java @@ -0,0 +1,21 @@ +package org.grails.plugins.i18n; + +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.web.servlet.DispatcherServlet; +import org.springframework.web.servlet.LocaleResolver; +import org.springframework.web.servlet.i18n.SessionLocaleResolver; + +@AutoConfiguration(before = { WebMvcAutoConfiguration.class }) +@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET) +public class I18nAutoConfiguration { + + @Bean + @ConditionalOnMissingBean(name = DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME) + public LocaleResolver localeResolver() { + return new SessionLocaleResolver(); + } +} diff --git a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy index 34d97d4356e..41d18c9ec31 100644 --- a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy +++ b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy @@ -63,8 +63,6 @@ class I18nGrailsPlugin extends Plugin { localeChangeInterceptor(ParamsAwareLocaleChangeInterceptor) { paramName = "lang" } - - localeResolver(SessionLocaleResolver) }} @Override From fbe10f82c6ec09b95ec6299480ba3797a02f167e Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Sun, 17 Nov 2024 19:21:09 -0800 Subject: [PATCH 02/15] Auto configure localeChangeInterceptor --- .../org/grails/plugins/i18n/I18nAutoConfiguration.java | 8 ++++++++ .../org/grails/plugins/i18n/I18nGrailsPlugin.groovy | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java index 605561621b6..b4a05e265fd 100644 --- a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java +++ b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java @@ -1,5 +1,6 @@ package org.grails.plugins.i18n; +import org.grails.web.i18n.ParamsAwareLocaleChangeInterceptor; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; @@ -7,6 +8,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.LocaleResolver; +import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; import org.springframework.web.servlet.i18n.SessionLocaleResolver; @AutoConfiguration(before = { WebMvcAutoConfiguration.class }) @@ -18,4 +20,10 @@ public class I18nAutoConfiguration { public LocaleResolver localeResolver() { return new SessionLocaleResolver(); } + + public LocaleChangeInterceptor localeChangeInterceptor() { + ParamsAwareLocaleChangeInterceptor localeChangeInterceptor = new ParamsAwareLocaleChangeInterceptor(); + localeChangeInterceptor.setParamName("lang"); + return localeChangeInterceptor; + } } diff --git a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy index 41d18c9ec31..1b711c9cd66 100644 --- a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy +++ b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy @@ -59,10 +59,6 @@ class I18nGrailsPlugin extends Plugin { } defaultEncoding = encoding } - - localeChangeInterceptor(ParamsAwareLocaleChangeInterceptor) { - paramName = "lang" - } }} @Override From c299c99ead521bb677658b63c50c3c12777c4e7d Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Sun, 17 Nov 2024 19:23:27 -0800 Subject: [PATCH 03/15] add AutoConfiguration.imports file --- ....springframework.boot.autoconfigure.AutoConfiguration.imports | 1 + 1 file changed, 1 insertion(+) create mode 100644 grails-plugin-i18n/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports diff --git a/grails-plugin-i18n/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/grails-plugin-i18n/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000000..070ecd4bead --- /dev/null +++ b/grails-plugin-i18n/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +org.grails.plugins.web.controllers.ControllersAutoConfiguration From fffa81bfdcb74b3fe26c943ad2241058d3900e8a Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Sun, 17 Nov 2024 20:08:53 -0800 Subject: [PATCH 04/15] missing @Bean --- .../groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java | 1 + 1 file changed, 1 insertion(+) diff --git a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java index b4a05e265fd..d0b5bd55fa8 100644 --- a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java +++ b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java @@ -21,6 +21,7 @@ public LocaleResolver localeResolver() { return new SessionLocaleResolver(); } + @Bean public LocaleChangeInterceptor localeChangeInterceptor() { ParamsAwareLocaleChangeInterceptor localeChangeInterceptor = new ParamsAwareLocaleChangeInterceptor(); localeChangeInterceptor.setParamName("lang"); From 1b47f9be0b92a0423548f6c475dfdf4d2a1dee8a Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Sun, 17 Nov 2024 20:33:37 -0800 Subject: [PATCH 05/15] AutoConfiguration.imports file --- ...springframework.boot.autoconfigure.AutoConfiguration.imports | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grails-plugin-i18n/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/grails-plugin-i18n/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 070ecd4bead..6e4f0121063 100644 --- a/grails-plugin-i18n/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/grails-plugin-i18n/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1 +1 @@ -org.grails.plugins.web.controllers.ControllersAutoConfiguration +org.grails.plugins.i18n.I18nAutoConfiguration From 9b1b698e748ca7674fc0eda5e71499343295c000 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Sun, 17 Nov 2024 20:41:06 -0800 Subject: [PATCH 06/15] auto configure messageSource --- .../plugins/i18n/I18nAutoConfiguration.java | 35 ++++++++++++++++++- .../plugins/i18n/I18nGrailsPlugin.groovy | 24 ------------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java index d0b5bd55fa8..96b3820dd11 100644 --- a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java +++ b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java @@ -1,20 +1,41 @@ package org.grails.plugins.i18n; +import grails.config.Settings; +import grails.core.GrailsApplication; +import grails.plugins.GrailsPluginManager; +import grails.util.Environment; +import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource; import org.grails.web.i18n.ParamsAwareLocaleChangeInterceptor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; +import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; +import org.springframework.context.support.AbstractApplicationContext; import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.LocaleResolver; import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; import org.springframework.web.servlet.i18n.SessionLocaleResolver; -@AutoConfiguration(before = { WebMvcAutoConfiguration.class }) +@AutoConfiguration(before = { MessageSourceAutoConfiguration.class, WebMvcAutoConfiguration.class }) @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET) public class I18nAutoConfiguration { + @Value("${" + Settings.GSP_VIEW_ENCODING + ":UTF-8}") + private String encoding; + + @Value("${" + Settings.GSP_ENABLE_RELOAD + ":false}") + private boolean gspEnableReload; + + @Value("${" + Settings.I18N_CACHE_SECONDS + ":5}") + private int cacheSeconds; + + @Value("${" + Settings.I18N_FILE_CACHE_SECONDS + ":5}") + private int fileCacheSeconds; + @Bean @ConditionalOnMissingBean(name = DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME) public LocaleResolver localeResolver() { @@ -27,4 +48,16 @@ public LocaleChangeInterceptor localeChangeInterceptor() { localeChangeInterceptor.setParamName("lang"); return localeChangeInterceptor; } + + @Bean(AbstractApplicationContext.MESSAGE_SOURCE_BEAN_NAME) + public MessageSource messageSource(GrailsApplication grailsApplication, GrailsPluginManager pluginManager) { + PluginAwareResourceBundleMessageSource messageSource = new PluginAwareResourceBundleMessageSource(grailsApplication, pluginManager); + messageSource.setDefaultEncoding(encoding); + messageSource.setFallbackToSystemLocale(false); + if (Environment.getCurrent().isReloadEnabled() || gspEnableReload) { + messageSource.setCacheSeconds(cacheSeconds); + messageSource.setFileCacheSeconds(fileCacheSeconds); + } + return messageSource; + } } diff --git a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy index 1b711c9cd66..0c6d7625d3a 100644 --- a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy +++ b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy @@ -15,19 +15,12 @@ */ package org.grails.plugins.i18n -import grails.config.Config -import grails.config.Settings -import grails.core.GrailsApplication import grails.plugins.Plugin import grails.util.BuildSettings -import grails.util.Environment import grails.util.GrailsUtil import groovy.util.logging.Slf4j -import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource -import org.grails.web.i18n.ParamsAwareLocaleChangeInterceptor import org.springframework.context.support.ReloadableResourceBundleMessageSource import org.springframework.core.io.Resource -import org.springframework.web.servlet.i18n.SessionLocaleResolver import java.nio.file.Files @@ -44,23 +37,6 @@ class I18nGrailsPlugin extends Plugin { String version = GrailsUtil.getGrailsVersion() String watchedResources = "file:./${baseDir}/**/*.properties".toString() - @Override - Closure doWithSpring() {{-> - GrailsApplication application = grailsApplication - Config config = application.config - boolean gspEnableReload = config.getProperty(Settings.GSP_ENABLE_RELOAD, Boolean, false) - String encoding = config.getProperty(Settings.GSP_VIEW_ENCODING, 'UTF-8') - - messageSource(PluginAwareResourceBundleMessageSource, application, pluginManager) { - fallbackToSystemLocale = false - if (Environment.current.isReloadEnabled() || gspEnableReload) { - cacheSeconds = config.getProperty(Settings.I18N_CACHE_SECONDS, Integer, 5) - fileCacheSeconds = config.getProperty(Settings.I18N_FILE_CACHE_SECONDS, Integer, 5) - } - defaultEncoding = encoding - } - }} - @Override void onChange(Map event) { def ctx = applicationContext From 0abd343127405fcff52700d922bc3f3581b6ae65 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Mon, 18 Nov 2024 01:27:16 -0800 Subject: [PATCH 07/15] force localeResolver --- .../groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java index 96b3820dd11..439f6e28641 100644 --- a/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java +++ b/grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java @@ -36,8 +36,7 @@ public class I18nAutoConfiguration { @Value("${" + Settings.I18N_FILE_CACHE_SECONDS + ":5}") private int fileCacheSeconds; - @Bean - @ConditionalOnMissingBean(name = DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME) + @Bean(DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME) public LocaleResolver localeResolver() { return new SessionLocaleResolver(); } From e24b0cf848a7c52d6164202dfd042613192bde0c Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Mon, 18 Nov 2024 08:47:30 -0800 Subject: [PATCH 08/15] use EnableAutoConfiguration over SpringBootApplication --- .../groovy/grails/boot/EmbeddedContainerWithGrailsSpec.groovy | 4 ++-- .../groovy/grails/boot/GrailsSpringApplicationSpec.groovy | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grails-web-boot/src/test/groovy/grails/boot/EmbeddedContainerWithGrailsSpec.groovy b/grails-web-boot/src/test/groovy/grails/boot/EmbeddedContainerWithGrailsSpec.groovy index 729cb09440f..f0de34e50ed 100644 --- a/grails-web-boot/src/test/groovy/grails/boot/EmbeddedContainerWithGrailsSpec.groovy +++ b/grails-web-boot/src/test/groovy/grails/boot/EmbeddedContainerWithGrailsSpec.groovy @@ -3,7 +3,7 @@ package grails.boot import grails.artefact.Artefact import grails.boot.config.GrailsAutoConfiguration import grails.web.Controller -import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory @@ -31,7 +31,7 @@ class EmbeddedContainerWithGrailsSpec extends Specification { new URL("http://localhost:${context.webServer.port}/foos").text == 'all foos' } - @SpringBootApplication + @EnableAutoConfiguration static class Application extends GrailsAutoConfiguration { @Bean ConfigurableServletWebServerFactory webServerFactory() { diff --git a/grails-web-boot/src/test/groovy/grails/boot/GrailsSpringApplicationSpec.groovy b/grails-web-boot/src/test/groovy/grails/boot/GrailsSpringApplicationSpec.groovy index d02c981a27a..f40b6d0fd3c 100644 --- a/grails-web-boot/src/test/groovy/grails/boot/GrailsSpringApplicationSpec.groovy +++ b/grails-web-boot/src/test/groovy/grails/boot/GrailsSpringApplicationSpec.groovy @@ -2,7 +2,7 @@ package grails.boot import grails.boot.config.GrailsAutoConfiguration import org.springframework.boot.SpringApplication -import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory @@ -32,7 +32,7 @@ class GrailsSpringApplicationSpec extends Specification{ } - @SpringBootApplication + @EnableAutoConfiguration static class Application extends GrailsAutoConfiguration { @Bean ConfigurableServletWebServerFactory webServerFactory() { From 7bc70925088ce2a03c27666c74b1c947d649fadc Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 18 Nov 2024 14:01:03 -0500 Subject: [PATCH 09/15] add `CONTRIBUTING.md` --- CONTRIBUTING.md | 245 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..613d68a8273 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,245 @@ + +# Contributing to Grails + +First off, thanks for taking the time to contribute! ❤️ + +Grails is an open source project with an active community and we rely heavily on that community to help make Grails better. As such, there are various ways in which people can contribute to Grails. One of these is by [writing useful plugins](https://docs.grails.org/latest/guide/plugins.html) and making them publicly available. + +All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉 + +> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about: +> - Star the project +> - Tweet about it +> - Refer this project in your project's readme +> - Mention the project at local meetups and tell your friends/colleagues +> - [Donate](https://opencollective.com/friends-of-grails) to the Friends of Grails initiative so others can work on the project. + + +## Table of Contents + +- [I Have a Question](#i-have-a-question) +- [I Want to Write a Grails Plugin](#i-want-to-write-a-grails-plugin) +- [I Want To Contribute](#i-want-to-contribute) + - [Reporting Bugs](#reporting-bugs) +- [Suggesting Enhancements](#suggesting-enhancements) +- [Your First Code Contribution](#your-first-code-contribution) +- [Improving The Documentation](#improving-the-documentation) +- [Code Style](#code-style) +- [Commit Messages](#commit-messages) +- [Join The Project Team](#join-the-project-team) + + + +## I Have a Question + +> If you want to ask a question, we assume that you have read the available [Documentation](https://docs.grails.org/latest/). + +Before you ask a question, it is best to search for existing [Issues](https://github.com/grails/grails-core/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first. + +If you then still feel the need to ask a question and need clarification, we recommend the following: + +- Ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/grails). +- Chat with us on [Slack](https://grails.slack.com). +- If your question is due to a bug, open an [Issue](https://github.com/grails/grails-core/issues/new). + - Provide as much context as you can about what you're running into. + - Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. + +## I Want to Write a Grails Plugin + +[Grails Plugins](https://docs.grails.org/latest/guide/plugins.html) are similar to a Grails Application project, but they include a plugin descriptor and package shared functionality for other Grails Applications to use. More information can be found [here](https://docs.grails.org/latest/guide/plugins.html#creatingAndInstallingPlugins). + +## I Want to Contribute + +> ### Legal Notice +> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license. All committers must sign the project's CLA. More detailed requirements are available in the project's [CLA](https://cla-assistant.io/grails/grails-core). + +### Reporting Bugs + + +#### Before Submitting a Bug Report + +A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible. + +- Make sure that you are using the latest version. +- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://docs.grails.org/latest/). If you are looking for support, you might want to check [this section](#i-have-a-question)). +- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/grails/grails-coreissues?q=label%3Abug). +- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue. +- Collect information about the bug: +- Stack trace (Traceback) +- OS, Platform and Version (Windows, Linux, macOS, x86, ARM) +- Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant. +- Possibly your input and the output +- Can you reliably reproduce the issue? And can you also reproduce it with older versions? Sample projects always are the best at investigating bugs. + + +#### How Do I Submit a Good Bug Report? + +> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead, sensitive bugs must be sent by email to security@grails.org. + +Grails uses GitHub to track issues in the [core framework](https://github.com/grails/grails-core/issues). Similarly, for its documentation there is a [separate tracker](https://github.com/grails/grails-doc/issues). If you run into an issue with the project: + +- Open an [Issue](https://github.com/grails/grails-core/issues/new). +- Explain the behavior you would expect and the actual behavior. +- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case. +- Provide the information you collected in the previous section. + +Once it's filed: + +- The project team will label the issue accordingly. +- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `info: need review`. Bugs with the `info: need review` tag will not be addressed until they are reproduced. +- If the team is able to reproduce the issue, it will be marked `status: acknowledged`, as well as possibly other tags (such as `type: critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution). + + +### Suggesting Enhancements + +This section guides you through submitting an enhancement suggestion for Grails, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions. + + +#### Before Submitting an Enhancement + +- Make sure that you are using the latest version. +- Read the [documentation](https://docs.grails.org/latest/) carefully and find out if the functionality is already covered, maybe by an individual configuration. +- Perform a [search](https://github.com/grails/grails-core/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. +- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library. + + +#### How Do I Submit a Good Enhancement Suggestion? + +Enhancement suggestions are tracked as [GitHub issues](https://github.com/grails/grails-core/issues). + +- Use a **clear and descriptive title** for the issue to identify the suggestion. +- Provide a **step-by-step description of the suggested enhancement** in as many details as possible. +- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you. +- **Explain why this enhancement would be useful** to most Grails users. You may also want to point out the other projects that solved it better and which could serve as inspiration. + +### Your First Code Contribution + + +#### Environment Setup + +##### 1. Forking the Code +One of the benefits of [GitHub](http://github.com) is the way that you can easily contribute to a project by [forking the repository](https://help.github.com/articles/fork-a-repo/) and [sending pull requests](https://help.github.com/articles/creating-a-pull-request/) with your changes. Please see GitHub's guides on how to create a fork and submit that fork. For easier illustration, the remainder of this document will use the `grails` repositories, but when working locally you should use your own fork. + +##### 2. Tool Setup + +If you're interested in contributing fixes and features to any part of grails, you will have to learn how to get hold of the project's source, build it and test it with your own applications. Before you start, make sure you have: + +* A git client +* An Editor such as [IntelliJ](https://www.jetbrains.com/idea/). + +Once you have the pre-requisite packages installed, the next step is to download the Grails source code, which is hosted at [GitHub](http://github.com) in several repositories owned by the http://github.com/grails["grails" GitHub user]. This is a simple case of cloning the repository you're interested in. For example, to get the core framework run: + + git clone http://github.com/grails/grails-core.git + +This will create a `grails-core` directory in your current working directory containing all the project source files. The next step is setting up the JDK to use. Grails makes use of [SDKMAN!](https://sdkman.io/) for easy JDK setup. Each Grails project should have a `.sdkmanrc` in it's root directory. Change to the `grails-core` directory and install the preferred JDK by issuing the command: + + sdk env . + +##### 3. Grails Home Setup + +If you look at the project structure, you'll see that it does not look like a standard `GRAILS_HOME` installation. But, it's very simple to turn it into one. Just run this from the root directory of the project: + + ./gradlew install + +This will fetch all the standard dependencies required by Grails and then build a `GRAILS_HOME` installation. Note that this target skips the extensive collection of Grails test classes, which can take some time to complete. + +Once the above command has finished, simply set the `GRAILS_HOME` environment variable to the checkout directory and add the "bin" directory to your path. When you next type `grails` command to run, you'll be using the version you just built. + +If you are using http://sdkman.io[SDKMAN] then that can also be used to work with this local installation via the following: + + sdk install grails dev /path/to/grails-core + +You will also need to publish your local installation to your local maven. + + ./gradlew publishToMavenLocal + +Now you will have a dev version in your local which you can use to test your features. + + +#### Testing Your Change +Grails has both local test coverage in the form of `unit` and `integration` tests and an entire functional test suite located at [grails-functional-tests](https://github.com/grails/grails-functional-tests/). + +##### 1. Running `grails-core` tests +To run the full suite of tests in `grails-core` execute: + + ./gradlew test + +These will take a while (15-30 mins), so consider running individual tests using the command line. For example, to run the test spec `BinaryPluginSpec` simply execute the following command: + + ./gradlew :grails-core:test --tests *.BinaryPluginSpec + +##### 2. Running the functional tests +To run the functional tests against the current `grails-core`: +1. Publish your branch to Maven Local + + + ./gradlew publishToMavenLocal + + +2. Checkout the associated branch in [grails-functional-tests](https://github.com/grails/grails-functional-tests/). +3. Add `mavenLocal()` at the top of the repositories block in the root `build.gradle` of `grails/grails-functional-tests`. +4. Run the Functional Tests: + + + ./gradlew build + + +5. Check the test results & verify that the build completes successfully. + +##### 3. Advanced Troubleshooting +Sometimes it's useful to debug your local application to see what's going wrong. Instead of using `./gradlew bootRun` use: + + ./gradlew bootRun --debug-jvm + +By default, Grails forks a JVM to run the application. The `-debug-jvm` argument causes the debugger to be associated with the forked JVM. You can then attach your debugger as proceed as normal. + +### Improving The Documentation +There are many aspects to [Grail's documentation](https://grails.org/documentation.html): +- [API](https://docs.grails.org/latest/api/) documentation in the code itself via javadoc & groovydoc. +- [The Grails User Guide](https://docs.grails.org/6.2.1/guide/single.html) from the [grails-doc](https://github.com/grails/grails-doc) project. +- Various how-to [Guides](https://guides.grails.org/index.html) from the [grails-guides](https://github.com/grails/grails-guides) project. + + +#### Improving the User Guide +The user guide is written using [Asciidoctor](http://asciidoctor.org/docs/user-manual/). The simplest way to contribute fixes is to simply click on the "Improve this doc" link that is to the right of each section of the documentation. + +This will link to the GitHub edit screen where you can make changes, preview them and create a pull request. + + +#### Building the Guide +If you want to make significant changes, such as changing the structure of the table of contents etc. then we recommend you build the user guide. To do that simply checkout the sources from GitHub: + + $ git clone https://github.com/grails/grails-doc/ + $ cd grails-doc + +The source files can be found in the `src/en/guide` directory. Whilst the Table of Contents (TOC) is defined in the `src/en/guide/toc.yml` file. + +Each YAML key points to a Asciidoc template. For example consider the following YAML: + + introduction: + title: Introduction + whatsNew: + title: What's new in Grails 3.2? + ... + +The `introduction` key points to `src/en/guide/introduction.adoc`. The `title` key defines the title that is dislayed in the TOC. Because `whatsNew` key is nested underneath the `introduction` key it points to `src/en/guide/introduction/whatsNew.adoc`, which is nested in a directory called `introduction`. + +Essentially, using the `toc.yml` file and the directory structure you can manipulate the structure of the user guide. + +To generate the documentation run the `publishGuide` task: + + ./gradlew publishGuide -x apiDocs + +NOTE: In the above example we skip the `apiDocs` task to speed up building of the guide, otherwise all Groovydoc documentation will be built too! + +Once the guide is built simply open the `build/docs/index.html` file in a browser to review your changes. + +## Code Style + +Grails code style mostly mirrors the Spring Framework's [Style Guide](https://github.com/spring-projects/spring-framework/blob/main/CONTRIBUTING.md#source-code-style). We are currently working on a more detailed proposal under ticket [#13754](https://github.com/grails/grails-core/issues/13754). + +### Commit Messages +Grails makes use of [Release Drafter](https://github.com/release-drafter/release-drafter) to draft its release notes so commit messages are important. They should follow the project's rules. While a change can be incrementally made under many commits, pull requests should be squashed into a single, meaningful commit message. + +## Join The Project Team +For people willing to contribute more than an occasional pull request, consider joining our core team. Inquire in the `questions` channel in slack to learn more. \ No newline at end of file From 22745caac4a302996194590f67ceac68e5fd0016 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Mon, 18 Nov 2024 15:29:05 -0600 Subject: [PATCH 10/15] Trivial grammar --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 613d68a8273..0039b5f5499 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ All types of contributions are encouraged and valued. See the [Table of Contents > And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about: > - Star the project > - Tweet about it -> - Refer this project in your project's readme +> - Refer to this project in your project's readme > - Mention the project at local meetups and tell your friends/colleagues > - [Donate](https://opencollective.com/friends-of-grails) to the Friends of Grails initiative so others can work on the project. @@ -242,4 +242,4 @@ Grails code style mostly mirrors the Spring Framework's [Style Guide](https://gi Grails makes use of [Release Drafter](https://github.com/release-drafter/release-drafter) to draft its release notes so commit messages are important. They should follow the project's rules. While a change can be incrementally made under many commits, pull requests should be squashed into a single, meaningful commit message. ## Join The Project Team -For people willing to contribute more than an occasional pull request, consider joining our core team. Inquire in the `questions` channel in slack to learn more. \ No newline at end of file +For people willing to contribute more than an occasional pull request, consider joining our core team. Inquire in the `questions` channel in slack to learn more. From 05db0e8f1c674d26ba2c6f4ae1baf64a7f6da94d Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Tue, 19 Nov 2024 07:30:33 -0800 Subject: [PATCH 11/15] Move GrailsFilters configuration from grails-spring module to grails-web-common so that grails-spring is not required for grails-boot. Fixes #13854 --- grails-bootstrap/build.gradle | 2 +- .../plugins/web/controllers/ControllersAutoConfiguration.java | 3 +-- grails-web-common/build.gradle | 1 + .../main/groovy/org/grails/web}/config/http/GrailsFilters.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename {grails-spring/src/main/groovy/org/grails/spring => grails-web-common/src/main/groovy/org/grails/web}/config/http/GrailsFilters.java (97%) diff --git a/grails-bootstrap/build.gradle b/grails-bootstrap/build.gradle index 468d0ac0766..f52649e741d 100644 --- a/grails-bootstrap/build.gradle +++ b/grails-bootstrap/build.gradle @@ -8,7 +8,7 @@ dependencies { // when used by grails-gradle-plugin // see: https://docs.gradle.org/current/userguide/compatibility.html#groovy implementation "org.springframework:spring-context" - api "org.springframework.boot:spring-boot-autoconfigure" + implementation "org.springframework.boot:spring-boot-autoconfigure" compileOnly "org.codehaus.groovy:groovy:$GroovySystem.version" diff --git a/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersAutoConfiguration.java b/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersAutoConfiguration.java index acd61f6c431..85b916322e0 100644 --- a/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersAutoConfiguration.java +++ b/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersAutoConfiguration.java @@ -3,7 +3,7 @@ import grails.config.Settings; import jakarta.servlet.DispatcherType; import jakarta.servlet.Filter; -import org.grails.spring.config.http.GrailsFilters; +import org.grails.web.config.http.GrailsFilters; import org.grails.web.filters.HiddenHttpMethodFilter; import org.grails.web.servlet.mvc.GrailsWebRequestFilter; import org.springframework.beans.factory.annotation.Value; @@ -16,7 +16,6 @@ import org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; import org.springframework.web.filter.CharacterEncodingFilter; import java.util.EnumSet; diff --git a/grails-web-common/build.gradle b/grails-web-common/build.gradle index 67536278618..eac6e4ebad5 100644 --- a/grails-web-common/build.gradle +++ b/grails-web-common/build.gradle @@ -10,6 +10,7 @@ dependencies { compileOnly "jakarta.servlet:jakarta.servlet-api" testCompileOnly "org.springframework:spring-test" + compileOnly "org.springframework.boot:spring-boot-autoconfigure" api "org.springframework:spring-webmvc" api "org.springframework:spring-context-support" implementation "com.github.ben-manes.caffeine:caffeine" diff --git a/grails-spring/src/main/groovy/org/grails/spring/config/http/GrailsFilters.java b/grails-web-common/src/main/groovy/org/grails/web/config/http/GrailsFilters.java similarity index 97% rename from grails-spring/src/main/groovy/org/grails/spring/config/http/GrailsFilters.java rename to grails-web-common/src/main/groovy/org/grails/web/config/http/GrailsFilters.java index b003dc50fb5..6b381a5c87c 100644 --- a/grails-spring/src/main/groovy/org/grails/spring/config/http/GrailsFilters.java +++ b/grails-web-common/src/main/groovy/org/grails/web/config/http/GrailsFilters.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package org.grails.spring.config.http; +package org.grails.web.config.http; import org.springframework.boot.autoconfigure.security.SecurityProperties; From 0e1f7e4fefc4301a1313eda05c43762b1848952c Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Tue, 19 Nov 2024 10:13:46 -0800 Subject: [PATCH 12/15] change to autoconfigure to api --- grails-web-common/build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grails-web-common/build.gradle b/grails-web-common/build.gradle index eac6e4ebad5..157ea36afd9 100644 --- a/grails-web-common/build.gradle +++ b/grails-web-common/build.gradle @@ -10,7 +10,8 @@ dependencies { compileOnly "jakarta.servlet:jakarta.servlet-api" testCompileOnly "org.springframework:spring-test" - compileOnly "org.springframework.boot:spring-boot-autoconfigure" + // now used by plugins for autoconfiguration + api "org.springframework.boot:spring-boot-autoconfigure" api "org.springframework:spring-webmvc" api "org.springframework:spring-context-support" implementation "com.github.ben-manes.caffeine:caffeine" From 59e1d270012741b46f89b123899c24a9ae72dfde Mon Sep 17 00:00:00 2001 From: Scott Murphy Date: Tue, 19 Nov 2024 16:47:49 -0800 Subject: [PATCH 13/15] Update UPGRADE7.md --- UPGRADE7.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/UPGRADE7.md b/UPGRADE7.md index 5ed8948da0e..023c046720d 100644 --- a/UPGRADE7.md +++ b/UPGRADE7.md @@ -12,3 +12,18 @@ Experienced while upgrading modules for Grails 7 - Fields with a public modifier were not returned with MetaClassImpl#getProperties() in groovy 3, but are now. ## NOTE: This document is a draft and the explanations are only highlights and will be expanded further prior to release of 7.0. + +### Cool New Features +- You can now @Scaffold Controllers and Services and virtually eliminate any boiler plate code. +- Hello Exterminator, Good by bugs! Lot's of things started working... and working well! For instance, use of controller namespaces now work seemlessly. +- Bootstrap 5.3.3 support. Saffolding and Fields tags now optionally support boostrap classes. +- Priortization of AutoConfiguration over bean overriding. +- Lightweight, Removal of numerous dependencies. +- grails-bom overhaul for keeping depedencies up to date and in sync. +- g:form now automatically provides csrf protection when Spring Security CSRF is enabled. +- Massive decoupling of dependencies and cleanup between modules. SiteMesh dependencies is no longer compiled into controllers fused between numerous modules. SiteMesh isn't even required to use Grails! +- SiteMesh ahs been upgrade to SiteMesh 3! +- Completely up to date modern stack that has been optimized for easier future transitions. +- GSP can now be used OUTSIDE of Grails! see grails-boot +- Works with Spring Security 6 out of the box. No plugin needed! +- Tested and works with Java [17-23](https://github.com/grails/grails-core/blob/0549617f27aeb5b90b64797fa4147dde40fc9c86/.github/workflows/gradle.yml#L18) From 46bd273517b24ce056722b17fda7c057189ba4f9 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Wed, 20 Nov 2024 14:32:40 -0600 Subject: [PATCH 14/15] minor grammar fix --- UPGRADE7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE7.md b/UPGRADE7.md index 023c046720d..88625842b70 100644 --- a/UPGRADE7.md +++ b/UPGRADE7.md @@ -21,7 +21,7 @@ Experienced while upgrading modules for Grails 7 - Lightweight, Removal of numerous dependencies. - grails-bom overhaul for keeping depedencies up to date and in sync. - g:form now automatically provides csrf protection when Spring Security CSRF is enabled. -- Massive decoupling of dependencies and cleanup between modules. SiteMesh dependencies is no longer compiled into controllers fused between numerous modules. SiteMesh isn't even required to use Grails! +- Massive decoupling of dependencies and cleanup between modules. SiteMesh dependencies are no longer compiled into controllers fused between numerous modules. SiteMesh isn't even required to use Grails! - SiteMesh ahs been upgrade to SiteMesh 3! - Completely up to date modern stack that has been optimized for easier future transitions. - GSP can now be used OUTSIDE of Grails! see grails-boot From c0750cbef4f9c868a2d01a6569ec21df9ec78248 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Thu, 21 Nov 2024 13:47:18 -0500 Subject: [PATCH 15/15] Fix link --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0039b5f5499..e8e88306d91 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -127,7 +127,7 @@ If you're interested in contributing fixes and features to any part of grails, y * A git client * An Editor such as [IntelliJ](https://www.jetbrains.com/idea/). -Once you have the pre-requisite packages installed, the next step is to download the Grails source code, which is hosted at [GitHub](http://github.com) in several repositories owned by the http://github.com/grails["grails" GitHub user]. This is a simple case of cloning the repository you're interested in. For example, to get the core framework run: +Once you have the pre-requisite packages installed, the next step is to download the Grails source code, which is hosted at [GitHub](http://github.com) in several repositories owned by the ["grails" GitHub user](http://github.com/grails). This is a simple case of cloning the repository you're interested in. For example, to get the core framework run: git clone http://github.com/grails/grails-core.git