-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
232 lines (212 loc) · 7 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
// Apply the java plugin to add support for Java
plugins {
id 'java'
id 'application'
id 'eclipse'
//id "de.undercouch.download" version "3.0.0"
}
// In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
//mavenCentral()
jcenter()
}
configurations {
jdo {
extendsFrom compile
}
//libProvided
//compile.extendsFrom libProvided
}
// In this section you declare the dependencies for your production and test code
dependencies {
// The production code uses the SLF4J logging API at compile time
compile 'org.slf4j:slf4j-api:1.7.13'
compile 'io.vertx:vertx-web:3.2.1'
compile 'io.vertx:vertx-rx-java:3.2.1'
compile 'io.vertx:vertx-core:3.2.1'
//compile 'com.google.guava:guava:19.0'
compile 'ch.qos.logback:logback-classic:1.1.7'
compile 'org.datanucleus:datanucleus-accessplatform-jdo-rdbms:5.0.0-m4'
compile 'com.h2database:h2:1.4.192'
compile 'com.google.inject:guice:4.0'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'commons-io:commons-io:2.5'
compile 'com.github.jknack:handlebars:4.0.5'
runtime 'org.javassist:javassist:3.20.0-GA'
compile 'org.codehaus.groovy:groovy:2.4.7'
runtime 'org.fusesource.jansi:jansi:1.13'
jdo 'org.datanucleus:datanucleus-enhancer:5.0.0-m4'
testCompile 'junit:junit:4.12'
testCompile 'io.vertx:vertx-unit:3.2.1'
testCompile ('guru.nidi.raml:raml-tester:0.8.8'){
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
}
testCompile 'org.jboss.resteasy:resteasy-client:3.0.17.Final'
//testCompile 'org.jboss.resteasy:resteasy-jackson-provider:3.0.17.Final'
testCompile 'org.jboss.resteasy:resteasy-jackson2-provider:3.0.17.Final'
}
def mainVerticle = "com.x.verticles.MainVerticle"
mainClassName = "io.vertx.core.Launcher"
run {
args = ["run", mainVerticle]
}
task downloadRamlConsole (type: Copy) {
def webrootDir = file('src/main/resources/META-INF/webroot')
println webrootDir
if ( !webrootDir.isDirectory() ){
println "Downloading raml-console patched release from GitHub..."
try{
if(!buildDir.exists()) buildDir.mkdirs();
def ramlConsoleZip = new File (buildDir, 'raml-console.zip')
def fileOutputStream = ramlConsoleZip.newOutputStream()
fileOutputStream << new URL('https://github.com/denis-kalinin/api-console/releases/download/v3.0.2.294/raml-console_3.0.2.294.zip').openStream()
fileOutputStream.close()
println "Downloaded!"
from zipTree(ramlConsoleZip)
into webrootDir
}catch(Exception e){
e.printStackTrace()
throw new GradleException(e.getMessage())
}
}
}
processResources.dependsOn downloadRamlConsole
test{
testLogging.showStandardStreams = true
}
task datanucleusEnhance {
description "Enhance JDO model classes using DataNucleus Enhancer"
dependsOn compileJava
doLast {
// define the entity classes
def entityFiles = fileTree(sourceSets.main.output.classesDir).matching {
include 'com/x/models/*.class'
}
println "Enhancing with DataNucleus the following files"
entityFiles.getFiles().each {
println it
}
// define Ant task for DataNucleus Enhancer
ant.taskdef(
name : 'datanucleusenhancer',
classpath : sourceSets.main.runtimeClasspath.asPath,
classname : 'org.datanucleus.enhancer.EnhancerTask'
)
// run the DataNucleus Enhancer as an Ant task
ant.datanucleusenhancer(
classpath: sourceSets.main.runtimeClasspath.asPath,
verbose: true,
api: "JDO") {
entityFiles.addToAntBuilder(ant, 'fileset', FileCollection.AntType.FileSet)
}
}
}
classes.dependsOn datanucleusEnhance
task copyLibs(type: Copy) {
from configurations.compile
into relativePath(buildDir)+'/'+libsDirName+'/lib'
}
//processResources.dependsOn copyLibs
jar {
manifest {
attributes 'Main-Class' : mainClassName,
'Main-Verticle' : mainVerticle,
'Class-Path' : configurations.runtime.collect { 'lib/'+it.getName() }.join(' ')
}
baseName = project.name
/*
from {
configurations.runtime.collect {
it.isDirectory() ? it : zipTree(it)
}
}
*/
//with jar
}
task sourcesJar(type: Jar, dependsOn: classes, description: 'Generates sources jar-file') {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc, description: 'Put Javadoc API documentation in jar-file') {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
//fatjar is not working with JDO from Datanucleus...
/*
task fatJar (type: Jar) {
manifest {
attributes 'Main-Class' : 'io.vertx.core.Launcher',
'Main-Verticle' : 'com.x.services.MainVerticle'
}
baseName = project.name + '-all'
from {
(configurations.compile - configurations.libProvided).collect {
it.isDirectory() ? it : zipTree(it)
}
}
with jar
}
assemble.dependsOn fatJar
*/
startScripts {
doLast {
def windowsScriptFile = file getWindowsScript()
def unixScriptFile = file getUnixScript()
windowsScriptFile.text = windowsScriptFile.text.replace('%APP_HOME%\\lib\\' +jar.baseName+'.jar' , '%APP_HOME%\\' + jar.baseName + '.jar')
unixScriptFile.text = unixScriptFile.text.replace('$APP_HOME/lib/' + jar.baseName + '.jar', '$APP_HOME/' + jar.baseName + '.jar')
}
}
task awsCodeDeploy(type: Copy, description: 'Prepares distribution for AWS CodeDeploy'){
into(relativePath(buildDir)+'/awsCodeDeploy')
from 'src/deploy/aws/codedeploy/appspec.yml'
into('deployScripts') { from fileTree (dir: 'src/deploy/aws/codedeploy/deployScripts') }
into(project.name){
into('lib'){ from configurations.runtime}
into('bin'){ from startScripts }
from jar
from fileTree(dir: 'src/main/dist')
into('javadoc'){ from javadoc }
from sourcesJar
}
}
//awsCodeDeploy.dependsOn javadocJar, sourcesJar
assemble.dependsOn awsCodeDeploy
//assemble.dependsOn fatJar
distributions {
main {
contents {
from jar
}
}
}
/*
project.ext {
bundleInportPackages = [
'org.apache.felix.service.command',
'org.apache.karaf.shell.commands',
'org.apache.karaf.shell.console',
'org.datanucleus.plugin',
'*'
]
bundleExportPackages = [
"*"
]
}
jar {
//it.dependsOn enhance
manifest {
instruction 'Import-Package' , bundleInportPackages.join(',')
instruction 'Export-Package' , bundleExportPackages.join(',')
attributes['JPA-PersistenceUnits' ] = 'DATA_DATANUCLEUS'
attributes['Meta-Persistence' ] = 'META-INF/persistence.xml'
attributes['DynamicImport-Package' ] = '*'
}
}
*/