Skip to content

Commit

Permalink
Upload limit and web app description
Browse files Browse the repository at this point in the history
First, fix a too small upload limit and increase it to 5 MB which is necessary
for purchase invoice documents.

Then, add a web.xml file along WAR generation to specify application version
and build number.
  • Loading branch information
dellermann committed Dec 7, 2016
1 parent 4341904 commit 51bdc9f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
39 changes: 31 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,9 @@ task wrapper(type: Wrapper) {

/* compiling */
task buildInfo << {
def buildNumberFile = file('grails-app/conf/buildNumber')
String buildNumber = '0'
if (buildNumberFile.exists()) {
buildNumber = buildNumberFile.text.trim()
buildNumber = ((buildNumber as long) + 1L).toString()
}
buildNumberFile.text = buildNumber
def formatter = new SimpleDateFormat('''yyyy-MM-dd'T'HH:mm:ssZ''')
def replaceTokens = [
'info.app.buildNumber': buildNumber,
'info.app.buildNumber': computeBuildNumber(1L).toString(),
'info.app.buildDate': formatter.format(new Date())
]

Expand All @@ -229,11 +222,27 @@ processResources.finalizedBy buildInfo

/* archive building */
war {
doFirst {
copy {
from(sourceSets.main.resources) {
include 'web.xml'
}
into temporaryDir
filter(
ReplaceTokens,
tokens: [
version: project.version,
buildNumber: computeBuildNumber().toString()
]
)
}
}
from(processResources) {
include 'launcher*.properties'
include 'logo.png'
include 'spinner.gif'
}
webXml = new File(temporaryDir, 'web.xml')
}
bootRepackage.dependsOn jar
// This doesn't work. Probably the property is set during execution time.
Expand Down Expand Up @@ -310,3 +319,17 @@ eclipse {
natures 'org.springsource.ide.eclipse.gradle.core.nature'
}
}


long computeBuildNumber(long offset = 0L) {
long buildNumber = 0L

File buildNumberFile = file('grails-app/conf/buildNumber')
if (buildNumberFile.exists()) {
buildNumber = buildNumberFile.text.trim() as long
if (offset > 0L) buildNumber += offset
}
if (offset > 0L) buildNumberFile.text = buildNumber.toString()

buildNumber
}
3 changes: 3 additions & 0 deletions grails-app/conf/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ grails:
maxsize: 1000
controllers:
defaultScope: singleton
upload:
maxFileSize: 5242880
maxRequestSize: 5242880
converters:
encoding: UTF-8
views:
Expand Down
2 changes: 1 addition & 1 deletion grails-app/conf/buildNumber
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11061
11068
6 changes: 6 additions & 0 deletions src/main/resources/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>SpringCRM @version@ (Build @buildNumber@)</display-name>
</web-app>

0 comments on commit 51bdc9f

Please sign in to comment.