@@ -6,7 +6,7 @@ def libsConfigurations = []
66subprojects { subproject ->
77 if (subproject. name == ' grails-dependencies' ) return
88 if (subproject. name == ' grails-bom' ) return
9- if (subproject. name == ' grails-core' ) {
9+ if (subproject. name == ' grails-shell ' || subproject . name == ' grails- core' ) {
1010
1111 configurations {
1212 libsConfigurations << libs {
@@ -137,13 +137,57 @@ task sourcesJars(type: Sync) {
137137 from { sourcesFor(libsConfigurations* . copyRecursive { it. name. startsWith(' grails-datastore' ) }. collect { it. transitive = false ; it }) }
138138}
139139
140- task install (dependsOn : [populateDependencies]) { task ->
140+ task grailsCreateStartScripts (type : GrailsCreateStartScripts ) {
141+ description = " Creates OS specific scripts to run grails-shell as a JVM application."
142+ mainClass. set(' org.grails.cli.GrailsCli' )
143+ applicationName = ' grails'
144+ defaultJvmOpts = [" -XX:+TieredCompilation" , " -XX:TieredStopAtLevel=1" , " -XX:CICompilerCount=3" ]
145+ outputDir = file(' bin' )
146+ classpath = rootProject. childProjects[' grails-shell' ]. configurations. runtimeClasspath
147+ projectArtifacts = rootProject. childProjects[' grails-shell' ]. tasks[' jar' ]. outputs. files. collect { " dist/${ it.name} " }
148+ doLast {
149+ ant. replace(file : file(' bin/grails' ), token : ' media/gradle.icns' , value : ' media/icons/grails.icns' )
150+ ant. chmod(file : file(' bin/grails' ), perm : ' ugo+rx' )
151+ }
152+ }
153+
154+ class GrailsCreateStartScripts extends org.gradle.api.tasks.application. CreateStartScripts {
155+
156+ @Input
157+ Collection<String > projectArtifacts= []
158+
159+ @org.gradle.api.tasks.TaskAction
160+ void generate () {
161+ def generator = new org.gradle.api.internal.plugins.StartScriptGenerator ()
162+ generator. unixStartScriptGenerator. template = project. rootProject. childProjects[' grails-shell' ]. resources. text. fromFile(' src/main/resources/unixStartScript.txt' )
163+ generator. applicationName = getApplicationName()
164+ generator. mainClassName = getMainClassName()
165+ generator. defaultJvmOpts = getDefaultJvmOpts()
166+ generator. optsEnvironmentVar = getOptsEnvironmentVar()
167+ generator. exitEnvironmentVar = getExitEnvironmentVar()
168+ generator. classpath = projectArtifacts + getClasspath(). resolvedConfiguration. resolvedArtifacts. collect { artifact ->
169+ def dependency = artifact. moduleVersion. id
170+ String installedFile = " lib/$dependency . group /$dependency . name /jars/$artifact . file . name "
171+ if (dependency. group== ' org.grails' && ! project. file(installedFile). exists()) {
172+ installedFile = " dist/$artifact . file . name "
173+ }
174+ installedFile
175+ }
176+ generator. scriptRelPath = " bin/${ getUnixScript().name} "
177+ generator. generateUnixScript(getUnixScript())
178+ generator. generateWindowsScript(getWindowsScript())
179+ }
180+ }
181+
182+ task install (dependsOn : [populateDependencies, grailsCreateStartScripts]) { task ->
141183 subprojects { Project project ->
142184 if (! project. name. startsWith(' grails-test-suite' )) {
143185 task. dependsOn(" $project . name :publishToMavenLocal" )
144186 }
145187 }
146188}
189+ // task install(dependsOn: [populateDependencies, grailsCreateStartScripts] + subprojects.findAll { !it.name.startsWith('grails-test-suite') }
190+ // *.collect { Project p -> p.tasks.withType(PublishToMavenLocal)})
147191
148192task zipDist (type : Zip , dependsOn : [sourcesJars, install]) {
149193 destinationDir = " ${ buildDir} /distributions" as File
0 commit comments