Skip to content

Commit 212fcd8

Browse files
committed
Merged fix for GRAILS-4969 "Quartz conflicts with grails-bootstrap"
1 parent aae90ea commit 212fcd8

File tree

4 files changed

+350
-4
lines changed

4 files changed

+350
-4
lines changed

gradle/assemble.gradle

Lines changed: 346 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
import org.apache.tools.ant.filters.ReplaceTokens
2+
3+
// todo Ask why startGrails and startGrails.bat live in two different locations (one with placeholder, the other probably manually maintained)
4+
// todo Retrieve bundlor zip via dependency DSL
5+
// todo Retrieve svn plugins via dependency DSL (ask regarding SNAPSHOTS)
6+
// todo Add correct description to all Jar tasks
7+
8+
manifest.mainAttributes(
9+
"Built-By": System.properties['user.name'],
10+
"Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
11+
"Implementation-Title": "Grails",
12+
"Ant-Version": 'Apache Ant 1.7.1', // todo we just have this property to make it easy to compare manifests. Remove it when this build is life
13+
"Implementation-Version": version,
14+
"Implementation-Vendor": 'grails.org')
15+
16+
// todo Once the base Java plugin is out, we will use this and then there will be no default jar and we can remove this line.
17+
jar.enabled = false
18+
19+
tasks.withType(Jar).allObjects {jar ->
20+
jar.osgify = false
21+
jar.mavenArtifact = false
22+
jar.appFileJar = false
23+
}
24+
25+
task sharedFilesJar(type: Jar, description: 'Package up the files that are shared by both applications and plugins.') {
26+
appendix = "shared-files"
27+
appFileJar = true
28+
from("src/war/WEB-INF") {
29+
into "web-app/WEB-INF"
30+
include "applicationContext.xml", "sitemesh.xml", "tld/*.tld"
31+
}
32+
from("src/grails/grails-app/conf") {
33+
into "grails-app/conf"
34+
include "DataSource.groovy", "UrlMappings.groovy"
35+
}
36+
}
37+
38+
task sharedApplicationFilesJar(type: Jar, description: 'Package up the files that are exclusive to applications.') {
39+
appendix = "app-files"
40+
appFileJar = true
41+
from("src/war") {
42+
into "web-app"
43+
exclude "WEB-INF/**"
44+
}
45+
from("src/grails/grails-app") {
46+
into "grails-app"
47+
exclude "taglib/**", "utils/**", "conf/DataSource.groovy", "conf/UrlMappings.groovy"
48+
}
49+
}
50+
51+
task sharedPluginFilesJar(type: Jar, description: 'Package up the files that are exclusive to plugins.') {
52+
appendix = "plugin-files"
53+
appFileJar = true
54+
from("src/grails/templates/plugins")
55+
from("src/grails") {
56+
include "grails-app/conf/BuildConfig.groovy", "grails-app/views/error.gsp"
57+
}
58+
from("src/grails/plugin")
59+
}
60+
61+
task docGeneratingFilesJar(type: Jar, description: 'Package up files used for generating documentation.') {
62+
appendix = "doc-files"
63+
appFileJar = true
64+
from("src/grails/docs")
65+
}
66+
67+
task integrationFilesJar(type: Jar, description: 'Files to integrate Grails with IDEs and build systems.') {
68+
appendix = "integration-files"
69+
appFileJar = true
70+
from("src/grails/templates/ide-support", "src/grails/ant")
71+
}
72+
73+
appFilesJars = tasks.withType(Jar).matching({ jar -> jar.appFileJar } as Spec)
74+
75+
appFilesJars.allObjects {jar ->
76+
configure(jar) {
77+
version = ''
78+
destinationDir = "$buildDir/appFileJars" as File
79+
}
80+
}
81+
82+
task appFilesJars {
83+
dependsOn { appFilesJars.all }
84+
}
85+
86+
distJars = tasks.withType(Jar).matching({ jar -> !jar.appFileJar } as Spec)
87+
88+
task libs {
89+
destinationDir = 'dist'
90+
dependsOn { distJars.all }
91+
}
92+
93+
distJars.allObjects {jar ->
94+
jar.baseName = "grails"
95+
jar.destinationDir = libs.destinationDir as File
96+
}
97+
98+
99+
handlersAndSchemasMetaInf = {
100+
from 'src/jar/META-INF'
101+
include '**/*.handlers', '**/*.schemas'
102+
}
103+
104+
task testJar(type: Jar, description: 'Package up the Grails testing jar') {
105+
appendix = "test"
106+
metaInf handlersAndSchemasMetaInf
107+
from mainClassesIncludeSpec("grails/test/**", "**/groovy/grails/test/**")
108+
osgify = true
109+
mavenArtifact = true
110+
}
111+
112+
task docsJar(type: Jar, dependsOn: docGeneratingFilesJar, description: 'Package up files used for generating documentation.') {
113+
appendix = "docs"
114+
metaInf handlersAndSchemasMetaInf
115+
from mainClassesIncludeSpec("grails/doc/**", "**/groovy/grails/documentation/**")
116+
from docGeneratingFilesJar.archivePath
117+
osgify = true
118+
mavenArtifact = true
119+
}
120+
121+
task springJar(type: Jar, description: 'Package up the Spring related Grails classes') {
122+
appendix = "spring"
123+
metaInf handlersAndSchemasMetaInf
124+
from mainClassesIncludeSpec("grails/spring/**", "**/groovy/grails/commons/spring/**")
125+
osgify = true
126+
mavenArtifact = true
127+
}
128+
129+
task bootstrapJar(type: Jar, description: 'Package up the classes used to bootstrap Grails') {
130+
appendix = "bootstrap"
131+
metaInf handlersAndSchemasMetaInf
132+
from mainClassesIncludeSpec("grails/util/AbstractBuildSettings*","grails/util/BuildSettings*", "grails/util/GrailsNameUtils*", "grails/util/Environment*", "grails/util/Metadata*",
133+
"grails/util/BuildScope*", "grails/util/GrailsMain*", "grails/ant/**/*", "**/groovy/grails/cli/**/*", "**/groovy/grails/resolve/**/*",
134+
"grails/build/**")
135+
from "build.properties"
136+
mavenArtifact = true
137+
}
138+
139+
task scriptsJar(type: Jar, description: 'Package up files used for generating documentation.') {
140+
appendix = "scripts"
141+
from sourceSets.buildScripts.classes, "scripts/log4j.properties"
142+
osgify = true
143+
mavenArtifact = true
144+
}
145+
146+
task gormJar(type: Jar, description: 'Package up GORM related classes.') {
147+
appendix = "gorm"
148+
metaInf handlersAndSchemasMetaInf
149+
from mainClassesIncludeSpec("grails/orm/**", "**/groovy/grails/orm/hibernate/**", "**/groovy/grails/plugins/orm/hibernate/**",
150+
"**/groovy/grails/validation/Hibernate**")
151+
osgify = true
152+
mavenArtifact = true
153+
}
154+
155+
task webJar(type: Jar, description: 'Package up web related classes.') {
156+
appendix = "web"
157+
from(sourceSets.main.classes) {
158+
include "grails/converters/**", "grails/util/**", "grails/web/**", "**/groovy/grails/web/**", "**/groovy/grails/plugins/web/**",
159+
"**/groovy/grails/plugins/converters/**", "**/groovy/grails/webflow/executor/support/GrailsConventionsFlowExecutorArgumentHandler*"
160+
exclude "grails/util/Generate**"
161+
}
162+
from(sourceSets.jsp21.classes)
163+
osgify = true
164+
mavenArtifact = true
165+
}
166+
167+
task webflowJar(type: Jar, description: 'Package up Web Flow integration classes.') {
168+
appendix = "webflow"
169+
from mainClassesIncludeSpec("**/groovy/grails/webflow/**", "**/groovy/grails/plugins/webflow/**")
170+
osgify = true
171+
mavenArtifact = true
172+
}
173+
174+
task crudJar(type: Jar, description: 'Package up scaffolding related classes.') {
175+
appendix = "crud"
176+
from mainClassesIncludeSpec("**/groovy/grails/scaffolding/**", "**/groovy/grails/plugins/scaffolding/**")
177+
osgify = true
178+
mavenArtifact = true
179+
}
180+
181+
task resourcesJar(type: Jar, dependsOn: [sharedFilesJar, sharedApplicationFilesJar, integrationFilesJar, sharedPluginFilesJar],
182+
description: 'Package up JAR containing all Grails templates and static resources.') {
183+
appendix = "resources"
184+
from(projectDir) {
185+
include "conf/webdefault.xml", "src/grails/templates/artifacts/**", "src/grails/templates/scaffolding/**",
186+
"src/war/WEB-INF/web*.template.xml", "src/war/WEB-INF/tld/*/*.tld"
187+
}
188+
from(sharedApplicationFilesJar.archivePath)
189+
from(integrationFilesJar.archivePath)
190+
from(sharedPluginFilesJar.archivePath)
191+
from(sharedFilesJar.archivePath)
192+
osgify = true
193+
mavenArtifact = true
194+
}
195+
196+
task coreJar(type: Jar, description: 'Package up core JAR containing the central APIs of the framework') {
197+
appendix = "core"
198+
metaInf {
199+
from "src/jar/META-INF"
200+
include 'services/**'
201+
}
202+
from(sourceSets.main.classes) {
203+
include "grails/ui/**", "grails/util/**", "grails/validation/**", "grails/persistence/**",
204+
"**/groovy/grails/aop/framework/**", "**/groovy/grails/beans/factory/**", "**/groovy/grails/commons/**",
205+
"**/groovy/grails/context/**", "**/groovy/grails/compiler/**", "**/groovy/grails/orm/support/**",
206+
"**/groovy/grails/exceptions/**", "**/groovy/grails/support/**", "**/groovy/grails/test/**",
207+
"**/groovy/grails/validation/**", "**/groovy/grails/plugins/**"
208+
exclude "grails/util/BuildSettings*", "grails/util/GrailsNameUtils*", "grails/util/Environment*",
209+
"grails/util/Metadata*", "grails/util/BuildScope*", "grails/util/GrailsMain*", "**/groovy/grails/commons/spring/**",
210+
"**/groovy/grails/plugins/orm/hibernate**", "**/groovy/grails/plugins/web/**", "**/groovy/grails/plugins/converters/**",
211+
"**/groovy/grails/plugins/webflow/**", "**/groovy/grails/plugins/scaffolding/**", "**/groovy/grails/validation/Hibernate**",
212+
"grails/test/**", "**/groovy/grails/test/**"
213+
}
214+
mavenArtifact = true
215+
}
216+
217+
task osgiJar(type: Jar, dependsOn: [bootstrapJar, coreJar], description: 'Create an OSGi jar that merges the core and bootstrap JARs for OSGi comptabibility.') {
218+
appendix = "osgi"
219+
from bootstrapJar.archivePath, coreJar.archivePath
220+
osgify = true
221+
}
222+
223+
task initBundlor(type: Copy) {
224+
dir = "$buildDir/bundlor"
225+
version = '1.0.0.RELEASE'
226+
from zipTree("bundlor/bundlor-${version}.zip")
227+
into dir
228+
}
229+
230+
distJars.matching({ jar -> jar.osgify } as Spec).allObjects {task ->
231+
task.dependsOn initBundlor
232+
task.doLast {
233+
if(new File("${initBundlor.dir}/bundlor-${initBundlor.version}").exists()) {
234+
def bundlorPath = fileTree("${initBundlor.dir}/bundlor-${initBundlor.version}/dist") +
235+
fileTree("${initBundlor.dir}/bundlor-${initBundlor.version}/lib")
236+
Properties antBuildProps = new Properties()
237+
antBuildProps.load(new FileInputStream("$projectDir/build.properties"))
238+
ant {
239+
antBuildProps.each {key, value ->
240+
if (key.startsWith('bundlor.')) {
241+
ant.properties[key] = value
242+
}
243+
}
244+
taskdef(resource: "com/springsource/bundlor/ant/antlib.xml", uri: "antlib:com.springsource.bundlor.ant",
245+
classpath: bundlorPath.asPath)
246+
'antlib:com.springsource.bundlor.ant:bundlor'(
247+
inputPath: archivePath,
248+
outputPath: archivePath,
249+
bundleVersion: version,
250+
manifestTemplatePath: "$projectDir/maven/grails-${appendix}.mf",
251+
failOnWarnings: "true") {
252+
propertyset() {
253+
propertyref(prefix: "bundlor.")
254+
mapper(type: "glob", from: "bundlor.*", to: "*")
255+
}
256+
}
257+
}
258+
}
259+
260+
}
261+
}
262+
263+
def mainClassesIncludeSpec(String[] args) {
264+
copySpec {
265+
from(sourceSets.main.classes) {
266+
args.each { include it }
267+
}
268+
}
269+
}
270+
271+
task pluginsFromSvn {
272+
dir = "$buildDir/pluginsFromSvn"
273+
grailsHibernateDest = "$dir/grails-hibernate-${version}.zip"
274+
grailsTomcatDest = "$dir/grails-tomcat-${version}.zip"
275+
outputs.files grailsHibernateDest, grailsTomcatDest
276+
doFirst {
277+
ant {
278+
mkdir(dir: dir)
279+
def versionTag = version.replaceAll(/\./, '_').toUpperCase()
280+
get(src: "http://svn.codehaus.org/grails/trunk/grails-plugins/grails-hibernate/tags/RELEASE_${versionTag}/grails-hibernate-${version}.zip",
281+
dest: grailsHibernateDest, verbose: true, usetimestamp: true)
282+
get(src: "http://svn.codehaus.org/grails/trunk/grails-plugins/grails-tomcat/tags/RELEASE_${versionTag}/grails-tomcat-${version}.zip",
283+
dest: grailsTomcatDest, verbose: true, usetimestamp: true)
284+
285+
}
286+
}
287+
}
288+
289+
binExecutables = ["cygrails", "grails", "grails-debug", "grails-debug.bat", "grails.bat"]
290+
291+
distSpec = copySpec {
292+
from(projectDir) {
293+
into "grails-$version"
294+
include 'lib/', 'gradle/', 'media/', 'samples/', 'scripts/', 'conf/', 'build.gradle', 'build.properties',
295+
'LICENSE', 'INSTALL', "src/", "gradlew.bat","gradle.properties"
296+
exclude 'ant/bin'
297+
298+
// this file is accounted for later with special handling to do some token replacement
299+
exclude 'src/grails/grails-macros.xml'
300+
}
301+
from(projectDir) {
302+
into "grails-$version"
303+
include "gradlew"
304+
fileMode = 0755
305+
}
306+
from(docs.destinationDir) {
307+
into "grails-$version/doc"
308+
}
309+
exclude "**/CVS/**"
310+
from(project.files(pluginsFromSvn.dir) { builtBy 'pluginsFromSvn' }) {
311+
into "grails-$version/plugins"
312+
}
313+
from('bin') {
314+
into "grails-$version/bin"
315+
include binExecutables
316+
fileMode = 0755
317+
}
318+
from('src/resources/docs/README') {
319+
into "grails-$version"
320+
filter(ReplaceTokens, tokens: ['grails.version': version])
321+
}
322+
from("src/resources/bash") {
323+
include "startGrails.bat", "startGrails"
324+
into "grails-$version/bin"
325+
filter(ReplaceTokens, tokens: ['grails.version': version])
326+
fileMode = 0755
327+
}
328+
from(libs.destinationDir) {
329+
into "grails-$version/dist"
330+
exclude "*.zip"
331+
}
332+
from("src/grails/grails-macros.xml") {
333+
into "grails-$version/src/grails"
334+
filter(ReplaceTokens, tokens: ['grails.version': version])
335+
}
336+
}
337+
338+
task zipDist(type: Zip) {
339+
from distSpec
340+
dependsOn tasks.withType(Jar).all, docs
341+
}
342+
343+
task zipDoc(type: Zip) {
344+
appendix = 'docs'
345+
from docs.destinationDir
346+
}

scripts/_GrailsSettings.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if (grailsSettings.grailsHome) {
4545
ant.property(file: "${grailsHome}/build.properties")
4646
}
4747
else {
48-
ant.property(resource: "build.properties")
48+
ant.property(resource: "grails.build.properties")
4949
}
5050

5151
/**

src/java/grails/util/BuildSettings.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ class BuildSettings {
464464
}
465465

466466
private def loadBuildPropertiesFromClasspath(Properties buildProps) {
467-
InputStream stream = getClass().classLoader.getResourceAsStream("build.properties")
468-
if(stream) {
467+
InputStream stream = getClass().classLoader.getResourceAsStream("grails.build.properties")
468+
if (stream) {
469469
buildProps.load(stream)
470470
}
471471
}

src/java/grails/util/GrailsMain.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if (!grailsHome) {
2121

2222
// Load the build properties so that we can read the Grails version.
2323
def props = new Properties()
24-
props.load(getClass().getClassLoader().getResourceAsStream("build.properties"))
24+
props.load(getClass().getClassLoader().getResourceAsStream("grails.build.properties"))
2525

2626
// We need JAVA_HOME so that we can get hold of the "tools.jar" file.
2727
def javaHome = new File(System.getenv("JAVA_HOME"))

0 commit comments

Comments
 (0)