diff --git a/issue-11767/build.gradle b/issue-11767/build.gradle
new file mode 100644
index 00000000..b4e5297c
--- /dev/null
+++ b/issue-11767/build.gradle
@@ -0,0 +1,50 @@
+buildscript {
+ repositories {
+ maven { url = 'https://repo.grails.org/grails/core' }
+ }
+ dependencies {
+ classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion"
+ }
+}
+
+group = 'issue11767.app'
+
+apply plugin: 'application'
+apply plugin: 'groovy'
+apply plugin: 'org.grails.grails-web'
+
+repositories {
+ mavenCentral()
+ maven { url = 'https://repo.grails.org/grails/core' }
+}
+
+dependencyManagement {
+ imports { mavenBom "org.grails:grails-bom:$grailsVersion" }
+ applyMavenExclusions false
+}
+
+dependencies {
+
+ implementation project(':issue-11767-plugin')
+
+ implementation 'org.grails:grails-core'
+ implementation 'org.grails:grails-logging'
+ implementation 'org.grails:grails-plugin-url-mappings'
+ implementation 'org.springframework.boot:spring-boot-starter-tomcat'
+
+ compileOnly 'io.micronaut:micronaut-inject-groovy'
+
+ testImplementation 'io.micronaut:micronaut-http-client'
+ testImplementation 'io.micronaut:micronaut-inject-groovy'
+ testImplementation 'org.grails:grails-web-testing-support'
+ testImplementation 'org.spockframework:spock-core'
+
+}
+
+application {
+ mainClass = 'issue11767.Application'
+}
+
+java {
+ sourceCompatibility = JavaVersion.VERSION_11
+}
\ No newline at end of file
diff --git a/issue-11767/grails-app/conf/application.yml b/issue-11767/grails-app/conf/application.yml
new file mode 100644
index 00000000..66b746d8
--- /dev/null
+++ b/issue-11767/grails-app/conf/application.yml
@@ -0,0 +1,43 @@
+my:
+ value1: 'this is value 1 from application.yml'
+
+---
+
+info:
+ app:
+ name: '@info.app.name@'
+ version: '@info.app.version@'
+ grailsVersion: '@info.app.grailsVersion@'
+grails:
+ mime:
+ disable:
+ accept:
+ header:
+ userAgents:
+ - Gecko
+ - WebKit
+ - Presto
+ - Trident
+ types:
+ all: '*/*'
+ atom: application/atom+xml
+ css: text/css
+ csv: text/csv
+ form: application/x-www-form-urlencoded
+ html:
+ - text/html
+ - application/xhtml+xml
+ js: text/javascript
+ json:
+ - application/json
+ - text/json
+ multipartForm: multipart/form-data
+ pdf: application/pdf
+ rss: application/rss+xml
+ text: text/plain
+ hal:
+ - application/hal+json
+ - application/hal+xml
+ xml:
+ - text/xml
+ - application/xml
\ No newline at end of file
diff --git a/issue-11767/grails-app/conf/logback.xml b/issue-11767/grails-app/conf/logback.xml
new file mode 100644
index 00000000..b7d4957e
--- /dev/null
+++ b/issue-11767/grails-app/conf/logback.xml
@@ -0,0 +1,21 @@
+
+
+ Plugin Groovy Spring Bean - my.value1: ${pluginGroovySpringBean.value1} + Plugin Groovy Spring Bean - my.value2: ${pluginGroovySpringBean.value2} ++ """.stripIndent() + } +} \ No newline at end of file diff --git a/issue-11767/grails-app/controllers/issue11767/app/UrlMappings.groovy b/issue-11767/grails-app/controllers/issue11767/app/UrlMappings.groovy new file mode 100644 index 00000000..c36a5e95 --- /dev/null +++ b/issue-11767/grails-app/controllers/issue11767/app/UrlMappings.groovy @@ -0,0 +1,11 @@ +package issue11767.app + +class UrlMappings { + static mappings = { + "/$controller/$action?/$id?(.$format)?"{ + constraints { + // apply constraints here + } + } + } +} diff --git a/issue-11767/grails-app/init/issue11767/app/Application.groovy b/issue-11767/grails-app/init/issue11767/app/Application.groovy new file mode 100644 index 00000000..90602cd3 --- /dev/null +++ b/issue-11767/grails-app/init/issue11767/app/Application.groovy @@ -0,0 +1,12 @@ +package issue11767.app + +import grails.boot.GrailsApp +import grails.boot.config.GrailsAutoConfiguration +import groovy.transform.CompileStatic + +@CompileStatic +class Application extends GrailsAutoConfiguration { + static void main(String[] args) { + GrailsApp.run(Application, args) + } +} diff --git a/issue-11767/src/integration-test/groovy/issue11767/app/ConfigLoadingSpec.groovy b/issue-11767/src/integration-test/groovy/issue11767/app/ConfigLoadingSpec.groovy new file mode 100644 index 00000000..0403e3e9 --- /dev/null +++ b/issue-11767/src/integration-test/groovy/issue11767/app/ConfigLoadingSpec.groovy @@ -0,0 +1,42 @@ +package issue11767.app + +import grails.testing.mixin.integration.Integration +import grails.testing.spock.OnceBefore +import io.micronaut.http.HttpRequest +import io.micronaut.http.client.HttpClient +import spock.lang.AutoCleanup +import spock.lang.Shared +import spock.lang.Specification +import spock.lang.Unroll + +@Integration +class ConfigLoadingSpec extends Specification { + + @Shared + @AutoCleanup + HttpClient httpClient + + @OnceBefore + void init() { + def baseUrl = "http://localhost:$serverPort" + httpClient = HttpClient.create(baseUrl.toURL()) + } + + @Unroll + void '#beanType beans can load plugin config values'(String beanType, String expectedResponseValue) { + + when: 'The app controller is visited' + def request = HttpRequest.GET('/app') + String response = httpClient.toBlocking().retrieve(request, String) + + then: 'The value from the plugin is found' + response.contains(expectedResponseValue) + + where: + beanType || expectedResponseValue + 'Plugin Groovy Spring' || 'Plugin Groovy Spring Bean - my.value2: this is value 2 from plugin.yml' + 'Plugin Groovy Micronaut' || 'Plugin Groovy Micronaut Bean - my.value2: this is value 2 from plugin.yml' + 'Plugin Java Micronaut' || 'Plugin Java Micronaut Bean - my.value2: this is value 2 from plugin.yml' + 'App Groovy Micronaut' || 'App Groovy Micronaut Bean - my.value2: this is value 2 from plugin.yml' + } +} diff --git a/issue-11767/src/main/groovy/issue11767/app/AppGroovyMicronautBean.groovy b/issue-11767/src/main/groovy/issue11767/app/AppGroovyMicronautBean.groovy new file mode 100644 index 00000000..2d4a3785 --- /dev/null +++ b/issue-11767/src/main/groovy/issue11767/app/AppGroovyMicronautBean.groovy @@ -0,0 +1,9 @@ +package issue11767.app + +import io.micronaut.context.annotation.ConfigurationProperties + +@ConfigurationProperties('my') +class AppGroovyMicronautBean { + String value1 + String value2 +} diff --git a/plugins/issue-11767-plugin/build.gradle b/plugins/issue-11767-plugin/build.gradle new file mode 100644 index 00000000..c9c64284 --- /dev/null +++ b/plugins/issue-11767-plugin/build.gradle @@ -0,0 +1,35 @@ +buildscript { + repositories { + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" + } +} + +apply plugin: 'groovy' +apply plugin: 'org.grails.grails-plugin' + +group = 'issue11767.plugin' + +repositories { + mavenCentral() + maven { url = 'https://repo.grails.org/grails/core' } +} + +dependencyManagement { + imports { + mavenBom "org.grails:grails-bom:$grailsVersion" + } + applyMavenExclusions false +} + +dependencies { + annotationProcessor 'io.micronaut:micronaut-inject-java' + implementation 'org.grails:grails-core' + compileOnly 'io.micronaut:micronaut-inject-groovy' +} + +java { + sourceCompatibility = JavaVersion.VERSION_11 +} \ No newline at end of file diff --git a/plugins/issue-11767-plugin/grails-app/conf/plugin.yml b/plugins/issue-11767-plugin/grails-app/conf/plugin.yml new file mode 100644 index 00000000..d3c99d27 --- /dev/null +++ b/plugins/issue-11767-plugin/grails-app/conf/plugin.yml @@ -0,0 +1,3 @@ +my: + value1: 'this is value 1 from plugin.yml' + value2: 'this is value 2 from plugin.yml' \ No newline at end of file diff --git a/plugins/issue-11767-plugin/grails-app/init/issue11767/plugin/Application.groovy b/plugins/issue-11767-plugin/grails-app/init/issue11767/plugin/Application.groovy new file mode 100644 index 00000000..d9b78557 --- /dev/null +++ b/plugins/issue-11767-plugin/grails-app/init/issue11767/plugin/Application.groovy @@ -0,0 +1,16 @@ +package issue11767.plugin + +import grails.boot.GrailsApp +import grails.boot.config.GrailsAutoConfiguration +import groovy.transform.CompileStatic +import grails.plugins.metadata.* +import org.springframework.context.annotation.ComponentScan + +@CompileStatic +@PluginSource +@ComponentScan(basePackages = 'issue11767.plugin') +class Application extends GrailsAutoConfiguration { + static void main(String[] args) { + GrailsApp.run(Application, args) + } +} diff --git a/plugins/issue-11767-plugin/src/main/groovy/issue11767/plugin/MyPluginGrailsPlugin.groovy b/plugins/issue-11767-plugin/src/main/groovy/issue11767/plugin/MyPluginGrailsPlugin.groovy new file mode 100644 index 00000000..6c678882 --- /dev/null +++ b/plugins/issue-11767-plugin/src/main/groovy/issue11767/plugin/MyPluginGrailsPlugin.groovy @@ -0,0 +1,15 @@ +package issue11767.plugin + +import grails.plugins.* + +class Issue11767GrailsPlugin extends Plugin { + + def title = 'Issue 11767' + def author = 'Mattias Reichel' + def authorEmail = '' + def description = '' + + Closure doWithSpring() {{ -> + pluginGroovySpringBean(PluginGroovySpringBean) + }} +} \ No newline at end of file diff --git a/plugins/issue-11767-plugin/src/main/groovy/issue11767/plugin/PluginGroovyMicronautBean.groovy b/plugins/issue-11767-plugin/src/main/groovy/issue11767/plugin/PluginGroovyMicronautBean.groovy new file mode 100644 index 00000000..684a97cc --- /dev/null +++ b/plugins/issue-11767-plugin/src/main/groovy/issue11767/plugin/PluginGroovyMicronautBean.groovy @@ -0,0 +1,11 @@ +package issue11767.plugin + +import groovy.transform.CompileStatic +import io.micronaut.context.annotation.ConfigurationProperties + +@CompileStatic +@ConfigurationProperties('my') +class PluginGroovyMicronautBean { + String value1 + String value2 +} diff --git a/plugins/issue-11767-plugin/src/main/groovy/issue11767/plugin/PluginGroovySpringBean.groovy b/plugins/issue-11767-plugin/src/main/groovy/issue11767/plugin/PluginGroovySpringBean.groovy new file mode 100644 index 00000000..03f319bd --- /dev/null +++ b/plugins/issue-11767-plugin/src/main/groovy/issue11767/plugin/PluginGroovySpringBean.groovy @@ -0,0 +1,13 @@ +package issue11767.plugin + +import groovy.transform.CompileStatic +import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.context.annotation.Configuration + +@CompileStatic +@Configuration +@ConfigurationProperties(prefix = 'my') +class PluginGroovySpringBean { + String value1 + String value2 +} diff --git a/plugins/issue-11767-plugin/src/main/java/issue11767/plugin/PluginJavaMicronautBean.java b/plugins/issue-11767-plugin/src/main/java/issue11767/plugin/PluginJavaMicronautBean.java new file mode 100644 index 00000000..19a259ca --- /dev/null +++ b/plugins/issue-11767-plugin/src/main/java/issue11767/plugin/PluginJavaMicronautBean.java @@ -0,0 +1,26 @@ +package issue11767.plugin; + +import io.micronaut.context.annotation.ConfigurationProperties; + +@ConfigurationProperties("my") +public class PluginJavaMicronautBean { + + private String value1; + private String value2; + + public String getValue1() { + return value1; + } + + public void setValue1(String value1) { + this.value1 = value1; + } + + public String getValue2() { + return value2; + } + + public void setValue2(String value2) { + this.value2 = value2; + } +} diff --git a/plugins/loadafter/build.gradle b/plugins/loadafter/build.gradle index 36eacfdd..5ea63305 100755 --- a/plugins/loadafter/build.gradle +++ b/plugins/loadafter/build.gradle @@ -37,7 +37,6 @@ dependencies { api "org.grails:grails-dependencies" api "javax.servlet:javax.servlet-api:$servletApiVersion" - //testCompile "org.grails:grails-plugin-testing" implementation "org.grails.plugins:spring-security-core:$springSecurityCoreVersion" console "org.grails:grails-console" diff --git a/settings.gradle b/settings.gradle index 2807c417..d7aa75ac 100644 --- a/settings.gradle +++ b/settings.gradle @@ -46,3 +46,7 @@ project(':loadafter').projectDir = new File('plugins/loadafter') include 'issue11005' project(':issue11005').projectDir = new File('plugins/issue11005') + +include 'issue-11767' +include 'issue-11767-plugin' +project(':issue-11767-plugin').projectDir = new File('plugins/issue-11767-plugin')
+ Plugin Groovy Micronaut Bean - my.value1: ${pluginGroovyMicronautConfigBean.value1} + Plugin Groovy Micronaut Bean - my.value2: ${pluginGroovyMicronautConfigBean.value2} +
+ Plugin Java Micronaut Bean - my.value1: ${pluginJavaMicronautConfigBean.value1} + Plugin Java Micronaut Bean - my.value2: ${pluginJavaMicronautConfigBean.value2} +
+ App Groovy Micronaut Bean - my.value1: ${appGroovyMicronautConfigBean.value1} + App Groovy Micronaut Bean - my.value2: ${appGroovyMicronautConfigBean.value2} +