Skip to content

Commit

Permalink
Merge branch '6.2.x' into renovate/com.gradle.enterprise-3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesfredley authored Sep 28, 2024
2 parents 6cb5421 + d528067 commit 21ee84f
Show file tree
Hide file tree
Showing 17 changed files with 343 additions and 1 deletion.
50 changes: 50 additions & 0 deletions issue-11767/build.gradle
Original file line number Diff line number Diff line change
@@ -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
}
43 changes: 43 additions & 0 deletions issue-11767/grails-app/conf/application.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions issue-11767/grails-app/conf/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>

<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<withJansi>true</withJansi>
<encoder>
<charset>UTF-8</charset>
<pattern>%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex</pattern>
</encoder>
</appender>

<root level="error">
<appender-ref ref="STDOUT" />
</root>

<logger name="grails.boot.config.GrailsApplicationPostProcessor" level="DEBUG" additivity="false"><appender-ref ref="STDOUT"/></logger>

</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package issue11767.app

import issue11767.plugin.PluginGroovyMicronautBean
import issue11767.plugin.PluginGroovySpringBean
import issue11767.plugin.PluginJavaMicronautBean
import org.springframework.beans.factory.annotation.Autowired

class AppController {

PluginGroovySpringBean pluginGroovySpringBean
@Autowired PluginGroovyMicronautBean pluginGroovyMicronautConfigBean
@Autowired PluginJavaMicronautBean pluginJavaMicronautConfigBean
@Autowired AppGroovyMicronautBean appGroovyMicronautConfigBean

def index() {
render """
<pre>
Plugin Groovy Spring Bean - my.value1: ${pluginGroovySpringBean.value1}
Plugin Groovy Spring Bean - my.value2: ${pluginGroovySpringBean.value2}
<br>
Plugin Groovy Micronaut Bean - my.value1: ${pluginGroovyMicronautConfigBean.value1}
Plugin Groovy Micronaut Bean - my.value2: ${pluginGroovyMicronautConfigBean.value2}
<br>
Plugin Java Micronaut Bean - my.value1: ${pluginJavaMicronautConfigBean.value1}
Plugin Java Micronaut Bean - my.value2: ${pluginJavaMicronautConfigBean.value2}
<br>
App Groovy Micronaut Bean - my.value1: ${appGroovyMicronautConfigBean.value1}
App Groovy Micronaut Bean - my.value2: ${appGroovyMicronautConfigBean.value2}
</pre>
""".stripIndent()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package issue11767.app

class UrlMappings {
static mappings = {
"/$controller/$action?/$id?(.$format)?"{
constraints {
// apply constraints here
}
}
}
}
12 changes: 12 additions & 0 deletions issue-11767/grails-app/init/issue11767/app/Application.groovy
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package issue11767.app

import io.micronaut.context.annotation.ConfigurationProperties

@ConfigurationProperties('my')
class AppGroovyMicronautBean {
String value1
String value2
}
35 changes: 35 additions & 0 deletions plugins/issue-11767-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 3 additions & 0 deletions plugins/issue-11767-plugin/grails-app/conf/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
my:
value1: 'this is value 1 from plugin.yml'
value2: 'this is value 2 from plugin.yml'
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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)
}}
}
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
1 change: 0 additions & 1 deletion plugins/loadafter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')

0 comments on commit 21ee84f

Please sign in to comment.