From 601f6952df798a311ed0a29989699441fd22b0de Mon Sep 17 00:00:00 2001 From: Michael Yan Date: Wed, 24 Jan 2024 21:26:29 +0800 Subject: [PATCH] Grace: fixed know issues --- .../src/main/groovy/grails/boot/Grails.java | 89 ++++++++++--------- .../groovy/grails/boot/GrailsBuilder.java | 17 +++- .../groovy/grails/util/GrailsVersion.java | 2 +- .../grails/io/support/ResourceLocator.java | 13 +++ .../groovy/grails/ui/shell/GrailsShell.groovy | 2 + .../GlobalGrailsPluginTransformation.groovy | 2 +- .../plugin/core/GrailsGradlePlugin.groovy | 37 +++++--- .../profiles/GrailsProfileGradlePlugin.groovy | 38 ++++---- ...ginsInfoApplicationContextInitializer.java | 4 +- .../plugins/i18n/I18nGrailsPlugin.groovy | 4 +- ...railsDependenciesDependencyManagement.java | 6 +- .../profile/commands/CreateAppCommand.groovy | 24 ++--- 12 files changed, 141 insertions(+), 97 deletions(-) diff --git a/grace-boot/src/main/groovy/grails/boot/Grails.java b/grace-boot/src/main/groovy/grails/boot/Grails.java index bff33c186c..3693500844 100644 --- a/grace-boot/src/main/groovy/grails/boot/Grails.java +++ b/grace-boot/src/main/groovy/grails/boot/Grails.java @@ -421,50 +421,53 @@ protected void configureDirectoryWatcher(DirectoryWatcher directoryWatcher, Stri protected void printRunStatus(ConfigurableApplicationContext applicationContext) { try { - GrailsApplication app = applicationContext.getBean(GrailsApplication.APPLICATION_ID, GrailsApplication.class); - String protocol = app.getConfig().getProperty("server.ssl.key-store") != null ? "https" : "http"; - if (applicationContext.getParent() != null) { - applicationContext.publishEvent( - new ApplicationPreparedEvent( - this, - new String[0], - (ConfigurableApplicationContext) applicationContext.getParent()) - ); - } - String contextPath = app.getConfig().getProperty("server.servlet.context-path", ""); - String hostName = app.getConfig().getProperty("server.address", "localhost"); - int port = 8080; - if (applicationContext instanceof WebServerApplicationContext) { - port = ((WebServerApplicationContext) applicationContext).getWebServer().getPort(); - } - String hostAddress = "localhost"; - try { - hostAddress = InetAddress.getLocalHost().getHostAddress(); - } - catch (UnknownHostException e) { - getApplicationLog().warn("The host name could not be determined, using `localhost` as fallback"); + Log log = getApplicationLog(); + if (log.isDebugEnabled()) { + GrailsApplication app = applicationContext.getBean(GrailsApplication.APPLICATION_ID, GrailsApplication.class); + String protocol = app.getConfig().getProperty("server.ssl.key-store") != null ? "https" : "http"; + if (applicationContext.getParent() != null) { + applicationContext.publishEvent( + new ApplicationPreparedEvent( + this, + new String[0], + (ConfigurableApplicationContext) applicationContext.getParent()) + ); + } + String contextPath = app.getConfig().getProperty("server.servlet.context-path", ""); + String hostName = app.getConfig().getProperty("server.address", "localhost"); + int port = 8080; + if (applicationContext instanceof WebServerApplicationContext) { + port = ((WebServerApplicationContext) applicationContext).getWebServer().getPort(); + } + String hostAddress = "localhost"; + try { + hostAddress = InetAddress.getLocalHost().getHostAddress(); + } + catch (UnknownHostException e) { + log.warn("The host name could not be determined, using `localhost` as fallback"); + } + StringBuilder sb = new StringBuilder(); + sb.append("%n----------------------------------------------------------------------------------------------"); + sb.append("%n Application: %s"); + sb.append("%n Version: %s"); + sb.append("%n Environment: %s"); + sb.append("%n Local: %s://%s:%s%s"); + sb.append("%n External: %s://%s:%s%s"); + sb.append("%n----------------------------------------------------------------------------------------------"); + sb.append("%n"); + log.debug(String.format(sb.toString(), + app.getConfig().getProperty("info.app.name"), + app.getConfig().getProperty("info.app.version"), + Environment.getCurrent().getName(), + protocol, + hostName, + port, + contextPath, + protocol, + hostAddress, + port, + contextPath)); } - StringBuilder sb = new StringBuilder(); - sb.append("%n----------------------------------------------------------------------------------------------"); - sb.append("%n Application: %s"); - sb.append("%n Version: %s"); - sb.append("%n Environment: %s"); - sb.append("%n Local: %s://%s:%s%s"); - sb.append("%n External: %s://%s:%s%s"); - sb.append("%n----------------------------------------------------------------------------------------------"); - sb.append("%n"); - getApplicationLog().info(String.format(sb.toString(), - app.getConfig().getProperty("info.app.name"), - app.getConfig().getProperty("info.app.version"), - Environment.getCurrent().getName(), - protocol, - hostName, - port, - contextPath, - protocol, - hostAddress, - port, - contextPath)); } catch (Exception ignored) { } diff --git a/grace-boot/src/main/groovy/grails/boot/GrailsBuilder.java b/grace-boot/src/main/groovy/grails/boot/GrailsBuilder.java index 6db405c8a8..71358b2b04 100644 --- a/grace-boot/src/main/groovy/grails/boot/GrailsBuilder.java +++ b/grace-boot/src/main/groovy/grails/boot/GrailsBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,22 +15,24 @@ */ package grails.boot; -import io.micronaut.spring.context.MicronautApplicationContext; import org.springframework.boot.SpringApplication; import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.io.ResourceLoader; import org.springframework.util.ClassUtils; +import org.springframework.util.ReflectionUtils; /** * Fluent API for constructing Grails instances. * Simple extension of {@link SpringApplicationBuilder}. * * @author Graeme Rocher + * @author Michael Yan * @since 3.0.6 */ public class GrailsBuilder extends SpringApplicationBuilder { - private MicronautApplicationContext micronautContext; + private ConfigurableApplicationContext micronautContext; public GrailsBuilder(Class... sources) { super(sources); @@ -43,7 +45,14 @@ protected SpringApplication createSpringApplication(ResourceLoader resourceLoade public GrailsBuilder enableMicronaut() { if (ClassUtils.isPresent("io.micronaut.spring.context.MicronautApplicationContext", getClass().getClassLoader())) { - this.micronautContext = new MicronautApplicationContext(); + try { + Class clazz = getClass().getClassLoader().loadClass("io.micronaut.spring.context.MicronautApplicationContext"); + this.micronautContext = (ConfigurableApplicationContext) ReflectionUtils.accessibleConstructor(clazz).newInstance(); + } + catch (Exception e) { + throw new IllegalStateException( + "Can't enable Micronaut as the parent application context of Grails", e); + } } else { throw new IllegalStateException( diff --git a/grace-bootstrap/src/main/groovy/grails/util/GrailsVersion.java b/grace-bootstrap/src/main/groovy/grails/util/GrailsVersion.java index dc3b32391b..ff9b5b866a 100644 --- a/grace-bootstrap/src/main/groovy/grails/util/GrailsVersion.java +++ b/grace-bootstrap/src/main/groovy/grails/util/GrailsVersion.java @@ -34,7 +34,7 @@ */ public final class GrailsVersion { - private static final Pattern VERSION_PATTERN = Pattern.compile("((\\d+)(\\.\\d+)+)(-(\\p{Alpha}+)-(\\w+))?(-(SNAPSHOT|\\d{14}([-+]\\d{4})?))?"); + private static final Pattern VERSION_PATTERN = Pattern.compile("((\\d+)(\\.\\d+)+)(-(\\p{Alpha}+)(\\w+))?(-(SNAPSHOT|\\d{14}([-+]\\d{4})?))?"); private final String version; diff --git a/grace-bootstrap/src/main/groovy/org/grails/io/support/ResourceLocator.java b/grace-bootstrap/src/main/groovy/org/grails/io/support/ResourceLocator.java index 91a2171515..a0ee69d5ed 100644 --- a/grace-bootstrap/src/main/groovy/org/grails/io/support/ResourceLocator.java +++ b/grace-bootstrap/src/main/groovy/org/grails/io/support/ResourceLocator.java @@ -85,6 +85,14 @@ private void initializeForSearchLocation(String searchLocation) { this.classSearchDirectories.add(directory.getCanonicalPath()); } } + File[] appDirectories = new File(searchLocationPlusSlash + "app") + .listFiles(file -> file.isDirectory() && !file.isHidden()); + + if (appDirectories != null) { + for (File directory : appDirectories) { + this.classSearchDirectories.add(directory.getCanonicalPath()); + } + } } catch (IOException ignored) { } @@ -180,6 +188,11 @@ public Resource findResourceForClassName(String className) { this.classNameToResourceCache.put(className, resource); break; } + resource = resolveExceptionSafe("app/domain/**/" + className + ext); + if (resource != null && resource.exists()) { + this.classNameToResourceCache.put(className, resource); + break; + } } } } diff --git a/grace-console/src/main/groovy/grails/ui/shell/GrailsShell.groovy b/grace-console/src/main/groovy/grails/ui/shell/GrailsShell.groovy index 89d7c3d742..ea77a62092 100644 --- a/grace-console/src/main/groovy/grails/ui/shell/GrailsShell.groovy +++ b/grace-console/src/main/groovy/grails/ui/shell/GrailsShell.groovy @@ -19,6 +19,7 @@ import groovy.transform.CompileStatic import groovy.transform.InheritConstructors import org.apache.groovy.groovysh.Groovysh import org.apache.groovy.groovysh.InteractiveShellRunner +import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.tools.shell.IO import org.springframework.boot.ApplicationArguments import org.springframework.boot.ApplicationContextFactory @@ -86,6 +87,7 @@ class GrailsShell extends Grails { bindingCustomizers?.each { customizer -> customizer.customize(binding) } Groovysh groovysh = new Groovysh(binding, new IO()) { + CompilerConfiguration configuration = CompilerConfiguration.DEFAULT @Override void displayWelcomeBanner(InteractiveShellRunner runner) { diff --git a/grace-core/src/main/groovy/org/grails/compiler/injection/GlobalGrailsPluginTransformation.groovy b/grace-core/src/main/groovy/org/grails/compiler/injection/GlobalGrailsPluginTransformation.groovy index 009c6cb0ea..ed22c979e2 100644 --- a/grace-core/src/main/groovy/org/grails/compiler/injection/GlobalGrailsPluginTransformation.groovy +++ b/grace-core/src/main/groovy/org/grails/compiler/injection/GlobalGrailsPluginTransformation.groovy @@ -179,7 +179,7 @@ class GlobalGrailsPluginTransformation implements ASTTransformation, Compilation Map pluginProperties = info.getProperties() String pluginVersion = pluginProperties['version'] ?: projectVersion String grailsVersion = pluginProperties['grailsVersion'] ?: getClass().getPackage().getImplementationVersion() + ' > *' - String excludes = pluginProperties['pluginExcludes'] + Object excludes = pluginProperties['pluginExcludes'] if (excludes instanceof List) { pluginExcludes.clear() pluginExcludes.addAll(excludes) diff --git a/grace-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy b/grace-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy index 9ace1d8439..4307f3c556 100644 --- a/grace-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy +++ b/grace-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy @@ -202,10 +202,11 @@ class GrailsGradlePlugin extends GroovyPlugin { @CompileDynamic private void applyBomImport(DependencyManagementExtension dme, Project project) { + String grailsVersion = resolveGrailsVersion(project) String springBootVersion = resolveSpringBootVersion(project) dme.imports({ - mavenBom("org.grails:grails-bom:${grailsVersion}") mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") + mavenBom("org.graceframework:grace-bom:${grailsVersion}") }) dme.setApplyMavenExclusions(false) } @@ -215,7 +216,7 @@ class GrailsGradlePlugin extends GroovyPlugin { } void addDefaultProfile(Project project, Configuration profileConfig) { - project.dependencies.add(PROFILE_CONFIGURATION, "org.grails.profiles:${System.getProperty('grails.profile') ?: defaultProfile}:") + project.dependencies.add(PROFILE_CONFIGURATION, "org.graceframework.profiles:${System.getProperty('grails.profile') ?: defaultProfile}:") } @CompileDynamic @@ -226,7 +227,7 @@ class GrailsGradlePlugin extends GroovyPlugin { Task buildPropertiesTask = project.tasks.create('buildProperties') Map buildPropertiesContents = [ - 'grails.env': Environment.isSystemSet() ? Environment.current.name : Environment.PRODUCTION.name, + 'grails.env': Environment.isSystemSet() ? Environment.current.getName() : Environment.PRODUCTION.getName(), 'info.app.name': project.name, 'info.app.version': project.version instanceof Serializable ? project.version : project.version.toString(), 'info.app.grailsVersion': grailsVersion] @@ -331,7 +332,7 @@ class GrailsGradlePlugin extends GroovyPlugin { project.tasks.create(taskName, ApplicationContextCommandTask) { classpath = fileCollection command = commandName - systemProperty Environment.KEY, System.getProperty(Environment.KEY, Environment.DEVELOPMENT.name) + systemProperty Environment.KEY, System.getProperty(Environment.KEY, Environment.DEVELOPMENT.getName()) if (project.hasProperty('args')) { args(CommandLineParser.translateCommandline(project.args)) } @@ -383,7 +384,7 @@ class GrailsGradlePlugin extends GroovyPlugin { } protected String resolveGrailsVersion(Project project) { - def grailsVersion = project.findProperty('grailsVersion') + def grailsVersion = project.findProperty('grailsVersion') ?: project.findProperty('graceVersion') grailsVersion = grailsVersion ?: new GrailsDependenciesDependencyManagement().getGrailsVersion() @@ -470,8 +471,8 @@ class GrailsGradlePlugin extends GroovyPlugin { TaskContainer tasks = project.tasks String grailsEnvSystemProperty = System.getProperty(Environment.KEY) - tasks.withType(Test).each systemPropertyConfigurer.curry(grailsEnvSystemProperty ?: Environment.TEST.name) - tasks.withType(JavaExec).each systemPropertyConfigurer.curry(grailsEnvSystemProperty ?: Environment.DEVELOPMENT.name) + tasks.withType(Test).each systemPropertyConfigurer.curry(grailsEnvSystemProperty ?: Environment.TEST.getName()) + tasks.withType(JavaExec).each systemPropertyConfigurer.curry(grailsEnvSystemProperty ?: Environment.DEVELOPMENT.getName()) } protected void configureConsoleTask(Project project) { @@ -557,9 +558,9 @@ class GrailsGradlePlugin extends GroovyPlugin { taskContainer.getByName(sourceSet.processResourcesTaskName) { AbstractCopyTask task -> GrailsExtension grailsExt = project.extensions.getByType(GrailsExtension) - boolean native2ascii = grailsExt.native2ascii + boolean native2ascii = grailsExt.isNative2ascii() task.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) - if (native2ascii && grailsExt.native2asciiAnt && !taskContainer.findByName('native2ascii')) { + if (native2ascii && grailsExt.isNative2asciiAnt() && !taskContainer.findByName('native2ascii')) { File destinationDir = ((ProcessResources) task).destinationDir Task native2asciiTask = createNative2AsciiTask(taskContainer, project.file("${grailsAppDir}/i18n"), destinationDir) task.dependsOn(native2asciiTask) @@ -581,7 +582,7 @@ class GrailsGradlePlugin extends GroovyPlugin { filter(ReplaceTokens, tokens: replaceTokens) } } - else if (!grailsExt.native2asciiAnt) { + else if (!grailsExt.isNative2asciiAnt()) { task.from(sourceSet.resources) { include '**/*.properties' filter(ReplaceTokens, tokens: replaceTokens) @@ -644,7 +645,7 @@ class GrailsGradlePlugin extends GroovyPlugin { if (project.tasks.findByName('runScript') == null) { project.tasks.create('runScript', ApplicationContextScriptTask) { classpath = project.sourceSets.main.runtimeClasspath + project.configurations.console + project.configurations.profile - systemProperty Environment.KEY, System.getProperty(Environment.KEY, Environment.DEVELOPMENT.name) + systemProperty Environment.KEY, System.getProperty(Environment.KEY, Environment.DEVELOPMENT.getName()) if (project.hasProperty('args')) { args(CommandLineParser.translateCommandline(project.args)) } @@ -655,9 +656,19 @@ class GrailsGradlePlugin extends GroovyPlugin { @CompileDynamic protected void configureRunCommand(Project project) { if (project.tasks.findByName('runCommand') == null) { + def findMainClass = project.tasks.findByName('findMainClass') + findMainClass.doLast { + ExtraPropertiesExtension extraProperties = (ExtraPropertiesExtension) project.getExtensions().getByName('ext') + def mainClassName = extraProperties.get('mainClassName') + if (mainClassName) { + project.tasks.withType(ApplicationContextCommandTask) { ApplicationContextCommandTask task -> + task.args mainClassName + } + } + } project.tasks.create('runCommand', ApplicationContextCommandTask) { classpath = project.sourceSets.main.runtimeClasspath + project.configurations.console + project.configurations.profile - systemProperty Environment.KEY, System.getProperty(Environment.KEY, Environment.DEVELOPMENT.name) + systemProperty Environment.KEY, System.getProperty(Environment.KEY, Environment.DEVELOPMENT.getName()) if (project.hasProperty('args')) { args(CommandLineParser.translateCommandline(project.args)) } @@ -699,7 +710,7 @@ class GrailsGradlePlugin extends GroovyPlugin { GrailsExtension grailsExt = project.extensions.getByType(GrailsExtension) - if (grailsExt.pathingJar && Os.isFamily(Os.FAMILY_WINDOWS)) { + if (grailsExt.isPathingJar() && Os.isFamily(Os.FAMILY_WINDOWS)) { project.tasks.withType(JavaExec) { JavaExec task -> if (task.name in ['console', 'shell'] || task instanceof ApplicationContextCommandTask diff --git a/grace-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfileGradlePlugin.groovy b/grace-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfileGradlePlugin.groovy index e6d332fd7f..9f12da9cdf 100644 --- a/grace-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfileGradlePlugin.groovy +++ b/grace-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfileGradlePlugin.groovy @@ -19,15 +19,17 @@ import groovy.transform.CompileStatic import org.gradle.api.Action import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.artifacts.DependencyResolveDetails +import org.gradle.api.artifacts.Configuration import org.gradle.api.file.CopySpec import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact import org.gradle.api.plugins.GroovyPlugin +import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.tasks.Copy +import org.gradle.api.tasks.SourceSet +import org.gradle.api.tasks.SourceSetContainer import org.gradle.api.tasks.bundling.Jar import grails.io.IOUtils -import grails.util.BuildSettings import org.grails.cli.profile.commands.script.GroovyScriptCommand import org.grails.gradle.plugin.profiles.tasks.ProfileCompilerTask @@ -51,21 +53,25 @@ class GrailsProfileGradlePlugin implements Plugin { void apply(Project project) { project.getPluginManager().apply(GroovyPlugin) project.configurations.create(CONFIGURATION_NAME) - def profileConfiguration = project.configurations.create(RUNTIME_CONFIGURATION) - - profileConfiguration.resolutionStrategy.eachDependency { - DependencyResolveDetails details = (DependencyResolveDetails) it - def requested = details.requested - def group = requested.group - def version = requested.version - - if (!group || !version) { - group = group ?: 'org.grails.profiles' - version = version ?: BuildSettings.grailsVersion - - details.useTarget(group: group, name: requested.name, version: version) + Configuration profileConfiguration = project.configurations.create(RUNTIME_CONFIGURATION) + profileConfiguration.setCanBeConsumed(false) + profileConfiguration.setCanBeResolved(true) + profileConfiguration.setVisible(false) + project.getPlugins().withType(GroovyPlugin, { javaPlugin -> + SourceSetContainer sourceSets = project.getExtensions() + .getByType(JavaPluginExtension).getSourceSets() + sourceSets.configureEach { SourceSet sourceSet -> + project.getConfigurations() + .getByName(sourceSet.getCompileClasspathConfigurationName()) + .extendsFrom(profileConfiguration) + project.getConfigurations() + .getByName(sourceSet.getImplementationConfigurationName()) + .extendsFrom(profileConfiguration) + project.getConfigurations() + .getByName(sourceSet.getRuntimeClasspathConfigurationName()) + .extendsFrom(profileConfiguration) } - } + }) def profileYml = project.file('profile.yml') diff --git a/grace-plugin-api/src/main/groovy/org/grails/plugins/support/GrailsPluginsInfoApplicationContextInitializer.java b/grace-plugin-api/src/main/groovy/org/grails/plugins/support/GrailsPluginsInfoApplicationContextInitializer.java index 21b3453eb3..ecf152e7a5 100644 --- a/grace-plugin-api/src/main/groovy/org/grails/plugins/support/GrailsPluginsInfoApplicationContextInitializer.java +++ b/grace-plugin-api/src/main/groovy/org/grails/plugins/support/GrailsPluginsInfoApplicationContextInitializer.java @@ -76,8 +76,8 @@ public void onApplicationEvent(ApplicationStartedEvent event) { } sb.append("%n----------------------------------------------------------------------------------------------%n"); - if (logger.isInfoEnabled()) { - logger.info(String.format(sb.toString())); + if (logger.isDebugEnabled()) { + logger.debug(String.format(sb.toString())); } } diff --git a/grace-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy b/grace-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy index 5c5f2bb680..c478cee13c 100644 --- a/grace-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy +++ b/grace-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy @@ -38,8 +38,8 @@ import org.grails.spring.context.support.ReloadableResourceBundleMessageSource class I18nGrailsPlugin extends Plugin implements PriorityOrdered { String version = GrailsUtil.getGrailsVersion() - String watchedResources = ['file:./grails-app/i18n/**/*.properties', - 'file:./app/i18n/**/*.properties'] + def watchedResources = ['file:./grails-app/i18n/**/*.properties', + 'file:./app/i18n/**/*.properties'] @Override Closure doWithSpring() { diff --git a/grace-shell/src/main/groovy/org/grails/cli/compiler/dependencies/GrailsDependenciesDependencyManagement.java b/grace-shell/src/main/groovy/org/grails/cli/compiler/dependencies/GrailsDependenciesDependencyManagement.java index 9d297aa3af..245f49772b 100644 --- a/grace-shell/src/main/groovy/org/grails/cli/compiler/dependencies/GrailsDependenciesDependencyManagement.java +++ b/grace-shell/src/main/groovy/org/grails/cli/compiler/dependencies/GrailsDependenciesDependencyManagement.java @@ -42,7 +42,7 @@ private static Model readModel() { try { return modelProcessor.read(GrailsDependenciesDependencyManagement.class - .getResourceAsStream("grails-bom-effective.xml"), null); + .getResourceAsStream("grace-bom-effective.xml"), null); } catch (IOException ex) { throw new IllegalStateException("Failed to build model from effective pom", ex); @@ -50,7 +50,7 @@ private static Model readModel() { } public String getGrailsVersion() { - return find("grails-core").getVersion(); + return find("grace-core").getVersion(); } public String getGroovyVersion() { @@ -58,7 +58,7 @@ public String getGroovyVersion() { } public String getGormVersion() { - return find("grails-datastore-core").getVersion(); + return find("grace-datastore-core").getVersion(); } public String getMicronautVersion() { diff --git a/grace-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy b/grace-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy index 7999b64cd8..cf9efd2b24 100644 --- a/grace-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy +++ b/grace-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy @@ -110,7 +110,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos return cursor } else if (!profileNames.contains(val)) { - String valStr = val + String valStr = val.toString() List candidateProfiles = profileNames.findAll { String pn -> pn.startsWith(valStr) @@ -131,7 +131,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos return cursor } else if (!profileNames.contains(val)) { - String valStr = val + String valStr = val.toString() if (valStr.endsWith(',')) { String[] specified = valStr.split(',') candidates.addAll(featureNames.findAll { String f -> @@ -405,7 +405,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos @CompileDynamic protected File unzipProfile(AntBuilder ant, Resource location) { - URI url = location.URL + URL url = location.URL File tmpDir = unzippedDirectories.get(url) if (tmpDir == null) { @@ -427,7 +427,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos repo.startsWith('http') ? "${' ' * spaces}maven { url \"${repo}\" }" : "${' ' * spaces}${repo}" } - String repositories = profile.repositories.collect(repositoryUrl.curry(4)).unique().join(ln) + String repositories = profile.repositories.sort().reverse().collect(repositoryUrl.curry(4)).unique().join(ln) List profileDependencies = profile.dependencies List dependencies = profileDependencies.findAll { Dependency dep -> @@ -448,7 +448,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos List gradleDependencies = convertToGradleDependencies(dependencies) - String dependencyString = gradleDependencies + String dependenciesString = gradleDependencies .sort({ GradleDependency dep -> dep.scope }) .collect({ GradleDependency dep -> dep.toString(4) }) .unique() @@ -458,9 +458,9 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos for (Feature f in features) { buildRepositories.addAll(f.getBuildRepositories()) } - buildRepositories = buildRepositories.collect(repositoryUrl.curry(8)).unique().join(ln) + String buildRepositoriesString = buildRepositories.sort().reverse().collect(repositoryUrl.curry(8)).unique().join(ln) - buildDependencies = buildDependencies.collect { Dependency dep -> + String buildDependenciesString = buildDependencies.collect { Dependency dep -> String artifactStr = resolveArtifactString(dep) " classpath \"${artifactStr}\"".toString() }.unique().join(ln) @@ -475,24 +475,24 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos } } - buildPlugins = buildPlugins.unique().join(ln) + String buildPluginsString = buildPlugins.unique().join(ln) ant.replace(dir: targetDirectory) { replacefilter { replacetoken('@buildPlugins@') - replacevalue(buildPlugins) + replacevalue(buildPluginsString) } replacefilter { replacetoken('@dependencies@') - replacevalue(dependencyString) + replacevalue(dependenciesString) } replacefilter { replacetoken('@buildDependencies@') - replacevalue(buildDependencies) + replacevalue(buildDependenciesString) } replacefilter { replacetoken('@buildRepositories@') - replacevalue(buildRepositories) + replacevalue(buildRepositoriesString) } replacefilter { replacetoken('@repositories@')