-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
155 lines (136 loc) · 3.93 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
apply plugin: 'java'
apply plugin: 'js'
apply plugin: 'tomcat'
apply plugin: 'war'
apply plugin: 'eclipse'
apply from: 'sass.gradle'
//
// Process javascript files
//
def javascriptSource = "${projectDir}/src/main/javascript"
def javascriptDest = "${buildDir}/js"
task processJavascript(dependsOn: 'minifyJs') {
inputs.dir '${javascriptSource}'
outputs.dir '${javascriptDest}'
}
jshint.configure {
source = fileTree(dir: javascriptSource, include: "**/*.js")
dest = file("${javascriptDest}/jshint.out")
}
combineJs.configure {
source = fileTree(dir: javascriptSource, include: "**/*.js")
dest = file("${javascriptDest}/all.js")
}.dependsOn("jshint")
minifyJs.configure {
source = file("${javascriptDest}/all.js")
dest = file("${javascriptDest}/all-min.js")
}.dependsOn("combineJs")
def sassSource = "${projectDir}/src/main/scss"
def cssDest = "${project.buildDir}/css"
def outputCssStyle = "compressed" // this should probably be set to 'expanded' or 'nested' for dev envs
// Process css files
compileSass.configure {
inputs.dir "${sassSource}"
outputs.dir "${cssDest}"
inputDir = project.file("${sassSource}")
outputDir = new File("${cssDest}")
outputStyle = "${outputCssStyle}"
}
//
// War creation to pull in js (after processing)
//
war.configure {
from (javascriptDest) {
into 'js' include '**/*.js'
}
from (compileSass.outputDir) {
into 'css' include '**/*.css'
}
}.dependsOn("processJavascript","compileSass")
//
// JBoss Deployment tasks and configuration
//
def jbossVersion = '4.2.3.GA'
def jbossDistDir = "${buildDir}/jboss"
configurations {
jboss
jbossdeploy
}
dependencies {
def cargoVersion = '1.2.4'
jboss "org.jboss.jbossas:jboss-as-dist:${jbossVersion}"
jbossdeploy "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",
"org.codehaus.cargo:cargo-ant:$cargoVersion"
}
task jbossInstall(type: Copy) {
configurations.jboss.findAll {
from zipTree(it)
into "${jbossDistDir}"
doFirst {
println "Expanding jboss distribution into ${jbossDistDir}"
}
}
}
task jbossStart (dependsOn: jbossInstall) {
doFirst {
def jbossRunFile = "${jbossDistDir}/jboss-${jbossVersion}/bin/run"
println "Starting ${jbossRunFile}"
def os = System.getProperty("os.name").toLowerCase()
if (os.contains("windows")) {
// start a seperate process in windows
ant.exec(executable: 'cmd', spawn: 'true') {
arg(value: '/c')
arg(value: "start ${jbossRunFile}.bat")
}
} else {
// Not windows (assume linux variant)
println "Not supported in Linux yet"
}
}
}
task jbossDeploy(dependsOn: war) << {
ClassLoader antClassLoader = org.apache.tools.ant.Project.class.classLoader
configurations.jbossdeploy.each { File f ->
antClassLoader.addURL(f.toURI().toURL())
}
ant.taskdef(resource: 'cargo.tasks')
ant.cargo(containerId: 'jboss42x', type: 'remote', action: 'redeploy') {
configuration(type: 'runtime') {
property(name: 'cargo.hostname', value: 'localhost')
property(name: 'cargo.servlet.port', value: '8080')
ant.deployable(type: 'war', file: "${buildDir}/libs/GradleTest.war") {
property(name: 'context', value: 'test')
}
}
}
}
//
// Project dependencies
//
repositories {
mavenLocal();
mavenCentral();
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4+'
def tomcatVersion = '6.0.35'
tomcat "org.apache.tomcat:catalina:${tomcatVersion}",
"org.apache.tomcat:coyote:${tomcatVersion}",
"org.apache.tomcat:jasper:${tomcatVersion}"
}
//
// Gradle plugin dependencies
//
buildscript {
repositories {
mavenCentral()
add(new org.apache.ivy.plugins.resolver.URLResolver()) {
name = 'GitHub'
addArtifactPattern 'http://cloud.github.com/downloads/[organisation]/[module]/[module]-[revision].[ext]'
}
}
dependencies {
classpath 'com.eriwen:gradle-js-plugin:1.1'
classpath 'bmuschko:gradle-tomcat-plugin:0.9.4';
}
}