Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile grails-shell, grails-gradle-model and grails-bootstrap w/ Gradle Groovy version #13653

Merged
merged 29 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f6de935
compile grails-shell and grails-gradle-model with the Groovy version …
jamesfredley Sep 18, 2024
9c66b00
Update grails-boostrap
jamesfredley Sep 19, 2024
f77f071
Merge branch '7.0.x' into jamesfredley/fix-use-gradle-groovy-version
jamesfredley Sep 20, 2024
42dd604
Remove code that forces Groovy 4 now that dependencies have been updated
jamesfredley Sep 20, 2024
ba22622
cleanup
jamesfredley Sep 20, 2024
4663a52
cleanup
jamesfredley Sep 20, 2024
d869a0c
restore groovy 4 configuration
jamesfredley Sep 20, 2024
3ab8ea4
Adjust dependency scope
jamesfredley Sep 20, 2024
743b4b6
more version cleanup
jamesfredley Sep 20, 2024
36942dd
more cleanup
jamesfredley Sep 20, 2024
8b74731
cleanup
jamesfredley Sep 20, 2024
0073110
update github workflow
jamesfredley Sep 21, 2024
27af60b
update github workflow
jamesfredley Sep 21, 2024
0051fff
Remove code that forces Groovy 4 now that dependencies have been updated
jamesfredley Sep 21, 2024
0d11153
try --rerun-tasks
jamesfredley Sep 21, 2024
6cfc4cb
test with groovy 3 on test
jamesfredley Sep 21, 2024
d1c0949
force groovy 3 in grails-bootstrap
jamesfredley Sep 21, 2024
6462ea5
groovy 4.0.23
jamesfredley Sep 21, 2024
95493cd
experiment
jamesfredley Sep 21, 2024
c1fa6a9
followup experiment
jamesfredley Sep 21, 2024
5bda1fb
Revert "force groovy 3 in grails-bootstrap"
jamesfredley Sep 21, 2024
0a98a80
Update dependencies
jamesfredley Sep 21, 2024
94391ba
Revert "try --rerun-tasks"
jamesfredley Sep 21, 2024
18640d5
Revert "Remove code that forces Groovy 4 now that dependencies have b…
jamesfredley Sep 21, 2024
e088592
Revert "update github workflow"
jamesfredley Sep 21, 2024
26f22d7
Revert "update github workflow"
jamesfredley Sep 21, 2024
17cc395
PR feedback
jamesfredley Sep 21, 2024
6b62af5
fix groovydoc
jamesfredley Sep 21, 2024
a926e13
fix: get `groovydoc` task working again
matrei Sep 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,13 @@ if (isReleaseVersion) {
allprojects {

// FORCE UPGRADE OF GROOVY IN DEPENDENCIES TO GROOVY 4
configurations.configureEach {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.codehaus.groovy' && details.requested.name != 'groovy-bom') {
details.useTarget(group: 'org.apache.groovy', name: details.requested.name, version: groovyVersion)
// except in projects that will be run by Gradle during the build
if (!compiledByGradleGroovyVersion(project)) {
configurations.configureEach {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.codehaus.groovy' && details.requested.name != 'groovy-bom') {
details.useTarget(group: 'org.apache.groovy', name: details.requested.name, version: groovyVersion)
}
}
}
}
Expand Down Expand Up @@ -435,9 +438,6 @@ subprojects { project ->
if (project.name == 'grails-dependencies') return
if (project.name == 'grails-bom') return

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

if (project.name =~ /^(grails-web|grails-plugin-|grails-test-suite|grails-test)/) {
dependencies {
api "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
Expand Down Expand Up @@ -478,14 +478,17 @@ subprojects { project ->
dependencies {
documentation("org.fusesource.jansi:jansi:$jansiVersion")
documentation("jline:jline:$jlineVersion")
documentation "org.apache.groovy:groovy-ant:$groovyVersion"
documentation "org.apache.groovy:groovy-cli-picocli:$groovyVersion"
documentation ("com.github.javaparser:javaparser-core:$javaParserCoreVersion")

if (project.name =~ /^(grails-bootstrap)/ || project.name =~ /^(grails-gradle-model)/) {
compileOnly groovyDependency
if (compiledByGradleGroovyVersion(project)) {
documentation "org.codehaus.groovy:groovy:$GroovySystem.version"
documentation "org.codehaus.groovy:groovy-ant:$GroovySystem.version"
documentation "org.codehaus.groovy:groovy-cli-picocli:$GroovySystem.version"
} else {
api groovyDependency
documentation "org.apache.groovy:groovy:$groovyVersion"
documentation "org.apache.groovy:groovy-ant:$groovyVersion"
documentation "org.apache.groovy:groovy-cli-picocli:$groovyVersion"
}

testImplementation "org.apache.groovy:groovy-test-junit5:$groovyVersion"
Expand Down Expand Up @@ -602,6 +605,12 @@ subprojects { project ->
jvmArgs += debugArguments
}
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
}

// From this point on we need the subprojects to be fully configured, so force their full evaluation
Expand Down Expand Up @@ -643,3 +652,11 @@ project.afterEvaluate {
}
}
}

// compile with the Groovy version provided by Gradle
// to ensure build compatibility with Gradle, currently Groovy 3.0.x
// when used by grails-gradle-plugin
// see: https://docs.gradle.org/current/userguide/compatibility.html#groovy
boolean compiledByGradleGroovyVersion(Project currentProject) {
currentProject.name in ['grails-bootstrap', 'grails-gradle-model', 'grails-shell']
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ gradleNexusPluginVersion=2.3.1
gradleNexusPublishPluginVersion=1.3.0
gradleExtraConfigurationsPluginVersion=10.0.1
gradleLicensePluginVersion=0.16.1
groovyVersion=4.0.22
groovyVersion=4.0.23
gspVersion=7.0.0-SNAPSHOT
hamcrestVersion=3.0
h2Version=2.2.224
Expand Down
9 changes: 7 additions & 2 deletions gradle/docs.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ configurations {
}

dependencies {
documentation "org.apache.groovy:groovy-groovydoc:$groovyVersion"
if (compiledByGradleGroovyVersion(project)) {
documentation "org.codehaus.groovy:groovy-groovydoc:$GroovySystem.version"
} else {
documentation "org.apache.groovy:groovy-groovydoc:$groovyVersion"
}
}

ext.grailsDocSrc = project.findProperty('grails-doc.home') ?: project.buildDir.absolutePath + "/checkout/grails-docs-src"
Expand Down Expand Up @@ -89,7 +93,8 @@ task javadoc(type:Javadoc, group: 'documentation') {

tasks.register('groovydoc', Groovydoc) {
final Set<Project> subProjects = subprojects.findAll {
it.name != 'grails-dependencies' && it.name != 'grails-bom' && !it.name.startsWith("grails-test-suite") }
!(it.name in ['grails-dependencies', 'grails-bom', 'grails-bootstrap', 'grails-gradle-model', 'grails-shell'])
&& !it.name.startsWith("grails-test-suite") }
def groovydocClasspath = files(configurations.documentation + subProjects.configurations.compileClasspath)
// exclude problematic jar file from javadoc classpath
// http://www.adam-bien.com/roller/abien/entry/trouble_with_crippled_java_ee
Expand Down
36 changes: 21 additions & 15 deletions grails-bootstrap/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
import org.apache.tools.ant.filters.ReplaceTokens

dependencies {
compileOnly ( "org.apache.groovy:groovy-xml:$groovyVersion" )
compileOnly ( "org.apache.groovy:groovy-templates:$groovyVersion" )
api "org.yaml:snakeyaml:$snakeyamlVersion"
api "io.micronaut:micronaut-inject:$micronautVersion"

compileOnly("io.methvin:directory-watcher:$directoryWatcherVersion")
compileOnly("org.fusesource.jansi:jansi:$jansiVersion")
compileOnly("jline:jline:$jlineVersion")
compileOnly("net.java.dev.jna:jna:$jnaVersion")
// compile grails-bootstap with the Groovy version provided by Gradle
// to ensure build compatibility with Gradle, currently Groovy 3.0.x
// when used by grails-gradle-plugin
// see: https://docs.gradle.org/current/userguide/compatibility.html#groovy
compileOnly "org.codehaus.groovy:groovy:$GroovySystem.version"
compileOnly "org.codehaus.groovy:groovy-templates:$GroovySystem.version"
compileOnly "org.codehaus.groovy:groovy-xml:$GroovySystem.version"
compileOnly "org.codehaus.groovy:groovy-ant:$GroovySystem.version"

compileOnly "io.methvin:directory-watcher:$directoryWatcherVersion"
compileOnly "org.fusesource.jansi:jansi:$jansiVersion"
compileOnly "jline:jline:$jlineVersion"
compileOnly "net.java.dev.jna:jna:$jnaVersion"

// Ant
compileOnly "org.apache.groovy:groovy-ant:$groovyVersion"
testImplementation ( "org.apache.groovy:groovy-xml:$groovyVersion" )
testImplementation ( "org.apache.groovy:groovy-templates:$groovyVersion" )
testImplementation("org.fusesource.jansi:jansi:$jansiVersion")
testImplementation("jline:jline:$jlineVersion")
api "org.yaml:snakeyaml:$snakeyamlVersion"
api "io.micronaut:micronaut-inject:$micronautVersion", {
exclude group: 'org.apache.groovy'
}

testImplementation "org.apache.groovy:groovy-xml:$groovyVersion"
testImplementation "org.apache.groovy:groovy-templates:$groovyVersion"
testImplementation "org.fusesource.jansi:jansi:$jansiVersion"
testImplementation "jline:jline:$jlineVersion"
}

processResources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ public class EntityASTTransformation implements ASTTransformation, CompilationUn

public void visit(ASTNode[] astNodes, SourceUnit sourceUnit) {

if (!(astNodes[0] instanceof AnnotationNode node) || !(astNodes[1] instanceof AnnotatedNode parent)) {
if (!(astNodes[0] instanceof AnnotationNode) || !(astNodes[1] instanceof AnnotatedNode)) {
throw new RuntimeException("Internal error: wrong types: $node.class / $parent.class");
}

if (!MY_TYPE.equals(node.getClassNode()) || !(parent instanceof ClassNode cNode)) {
AnnotatedNode parent = (AnnotatedNode) astNodes[1];
AnnotationNode node = (AnnotationNode) astNodes[0];
if (!MY_TYPE.equals(node.getClassNode()) || !(parent instanceof ClassNode)) {
return;
}

ClassNode cNode = (ClassNode) parent;
String cName = cNode.getName();
if (cNode.isInterface()) {
throw new RuntimeException("Error processing interface '" + cName + "'. " +
Expand Down
7 changes: 7 additions & 0 deletions grails-gradle-model/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dependencies {
// compile grails-gradle-model with the Groovy version provided by Gradle
// to ensure build compatibility with Gradle, currently Groovy 3.0.x
// when used by grails-gradle-plugin
// see: https://docs.gradle.org/current/userguide/compatibility.html#groovy
compileOnly "org.codehaus.groovy:groovy:$GroovySystem.version"
}
24 changes: 19 additions & 5 deletions grails-shell/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,27 @@ ext {
}

dependencies {
// compile grails-shell with the Groovy version provided by Gradle
// to ensure build compatibility with Gradle, currently Groovy 3.0.x
// when used by grails-gradle-plugin
// see: https://docs.gradle.org/current/userguide/compatibility.html#groovy
compileOnly "org.codehaus.groovy:groovy:$GroovySystem.version"
compileOnly "org.codehaus.groovy:groovy-templates:$GroovySystem.version"
compileOnly "org.codehaus.groovy:groovy-xml:$GroovySystem.version"
compileOnly "org.codehaus.groovy:groovy-ant:$GroovySystem.version"
compileOnly "org.codehaus.groovy:groovy-json:$GroovySystem.version"

runtimeOnly "org.apache.groovy:groovy-ant:$groovyVersion"
runtimeOnly "org.apache.groovy:groovy-json:$groovyVersion"
runtimeOnly "org.apache.groovy:groovy-jmx:$groovyVersion"
runtimeOnly "org.apache.groovy:groovy-xml:$groovyVersion"

api project(":grails-bootstrap")
api project(":grails-gradle-model")
api "org.apache.ant:ant:$antVersion"
api "org.apache.groovy:groovy-ant:$groovyVersion"
api "org.apache.groovy:groovy-json:$groovyVersion"
api "org.apache.groovy:groovy-jmx:$groovyVersion"
api "org.fusesource.jansi:jansi:$jansiVersion"
api "jline:jline:$jlineVersion"
api "org.gradle:gradle-tooling-api:$gradleToolingApiVersion"
compileOnly "org.apache.groovy:groovy-templates:$groovyVersion"
api "org.apache.groovy:groovy-xml:$groovyVersion"

compileOnly "org.springframework.boot:spring-boot:$springBootVersion"
compileOnly "org.springframework.boot:spring-boot-loader-tools:$springBootVersion"
Expand Down Expand Up @@ -56,6 +66,10 @@ dependencies {

testImplementation "net.sf.expectit:expectit-core:$expectitCoreVersion"
testImplementation "com.github.jnr:jnr-posix:$jnrPosixVersion"
testImplementation "org.apache.groovy:groovy-xml:$groovyVersion"
testImplementation "org.apache.groovy:groovy-json:$groovyVersion"
testImplementation "org.apache.groovy:groovy-templates:$groovyVersion"
testImplementation "org.apache.groovy:groovy-ant:$groovyVersion"

runtimeOnly "org.slf4j:slf4j-simple:$slf4jVersion"
runtimeOnly "org.codehaus.plexus:plexus-component-api:$plexusComponentApiVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@ public List<UrlMapping> evaluateMappings(Resource resource) {

@Override
public List<UrlMapping> evaluateMappings(Class<?> mappingsClass) {
var obj = (GroovyObject) BeanUtils.instantiateClass(mappingsClass);
if (obj instanceof Script script) {
var binding = new Binding();
var closure = new MappingCapturingClosure(script);
GroovyObject obj = (GroovyObject) BeanUtils.instantiateClass(mappingsClass);
if (obj instanceof Script) {
Script script = (Script) obj;
Binding binding = new Binding();
MappingCapturingClosure closure = new MappingCapturingClosure(script);
binding.setVariable("mappings", closure);
script.setBinding(binding);
script.run();
Expand Down Expand Up @@ -596,8 +597,10 @@ private Object _invoke(String methodName, Object arg, Object delegate) {
urlDefiningMode = false;
}
args = args != null && args.length > 0 ? args : new Object[] {Collections.emptyMap()};
if (args[0] instanceof Closure<?> callable) {
var urlData = createUrlMappingData(mappedURI, isResponseCode);
if (args[0] instanceof Closure<?>) {
UrlMappingData urlData = createUrlMappingData(mappedURI, isResponseCode);

Closure<?> callable = (Closure<?>) args[0];

if (delegate != null) {
callable.setDelegate(delegate);
Expand Down Expand Up @@ -638,7 +641,8 @@ private Object _invoke(String methodName, Object arg, Object delegate) {
return urlMapping;
}

if (args[0] instanceof Map<?,?> namedArguments) {
if (args[0] instanceof Map) {
Map<?,?> namedArguments = (Map<?,?>) args[0];
String version = null;

if (namedArguments.containsKey(UrlMapping.VERSION)) {
Expand Down Expand Up @@ -704,7 +708,8 @@ private Object _invoke(String methodName, Object arg, Object delegate) {
}
}
} else if ((!urlDefiningMode || (!parentResources.isEmpty() && parentResources.peek().isGroup)) && CONSTRAINTS.equals(mappedURI)) {
if (args.length > 0 && (args[0] instanceof Closure<?> callable)) {
if (args.length > 0 && (args[0] instanceof Closure<?>)) {
Closure<?> callable = (Closure<?>) args[0];
var builder = constraintsEvaluator.newConstrainedPropertyBuilder(UrlMapping.class);
for (var constrainedProperty : currentConstraints) {
builder.getConstrainedProperties().put(constrainedProperty.getPropertyName(), constrainedProperty);
Expand All @@ -729,7 +734,8 @@ private List<String> calculateIncludes(Map<?,?> namedArguments, List<String> def

Object excludesObject = namedArguments.get("excludes");
if (excludesObject != null) {
if (excludesObject instanceof List<?> excludeList) {
if (excludesObject instanceof List<?>) {
List<?> excludeList = (List<?>) excludesObject;
for (Object exc : excludeList) {
if (exc != null) {
includes.remove(exc.toString().toLowerCase());
Expand All @@ -741,7 +747,8 @@ private List<String> calculateIncludes(Map<?,?> namedArguments, List<String> def
}
Object includesObject = namedArguments.get("includes");
if (includesObject != null) {
if (includesObject instanceof List<?> includeList) {
if (includesObject instanceof List<?>) {
List<?> includeList = (List<?>) includesObject;
includes.clear();
for (Object inc : includeList) {
if (inc != null) {
Expand Down Expand Up @@ -1079,7 +1086,8 @@ private UrlMapping getURLMappingForNamedArgs(Map<?,?> namedArguments, UrlMapping
var exceptionArg = getException(namedArguments, bindingVariables);

if (isResponseCode && exceptionArg != null) {
if (exceptionArg instanceof Class<?> exClass) {
if (exceptionArg instanceof Class<?>) {
Class<?> exClass = (Class<?>) exceptionArg;
if (Throwable.class.isAssignableFrom(exClass)) {
((ResponseCodeUrlMapping) urlMapping).setExceptionType(exClass);
} else {
Expand Down
Loading