forked from jason-lang/jason
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
466 lines (399 loc) · 14.1 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
/*
Jason Gradle build file
*/
plugins {
id "ca.coglinc.javacc" version "2.3.1"
// see https://github.com/johnmartel/javaccPlugin
}
defaultTasks 'jar'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'
version '2.1'
group 'org.jason-lang'
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
maven {
url "http://jacamo.sourceforge.net/maven2"
}
//maven {
// url "http://jade.tilab.com/maven"
//}
flatDir {
dirs 'jedit', 'demos/persistent-belief-base/lib'
}
}
configurations {
umljavadoc // see http://www.umlgraph.org/doc/indexw.html
}
dependencies {
compile group: 'net.sf.ingenias', name: 'jade', version: '4.3'
//compile group: 'com.tilab.jade', name: 'jade', version: '4.4.0'
compile group: 'org.jacamo', name: 'cartago', version: '2.3-SNAPSHOT'
compile group: 'org.jacamo', name: 'jaca', version: '2.3-SNAPSHOT'
// from jEdit
compile fileTree(dir: 'jedit', include: '*.jar') // using fileTree, jedit jars are not included as a dependency in the pom file
runtime group: 'org.apache.ant', name: 'ant', version: '1.9.7'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile name: 'hsqldb'
umljavadoc 'org.umlgraph:umlgraph:5.6'
}
// copy dep jars and scritps into build directory
task copyJarsToBuild {
inputs.files configurations.runtime.files
inputs.dir 'scripts'
outputs.dir 'build/libs'
outputs.dir 'build/scripts'
doLast {
copy {
from configurations.runtime
into 'build/libs'
}
copy {
from 'scripts'
into 'build/scripts'
include '**'
filter {
String line -> line.replaceAll("JasonREL=[0-9]+\\.[0-9]+", "JasonREL="+project.version)
}
filter {
String line -> line.replaceAll("JadeREL", file(project.configurations.compile.find { it.name.startsWith("jade-") }).name)
}
}
}
}
jar {
baseName 'jason'
manifest {
attributes 'Main-Class': 'jason.util.ConfigGUI',
'Specification-Title': 'Jason Language',
'Specification-Version': project.version,
'Implementation-Version': new Date().toString()
}
/*doFirst {
Properties props = new Properties()
props.put('version', '')
props.put('release', project.version)
props.store(new File(project.buildDir.absolutePath +'/classes/main/dist.properties').newWriter(), null)
}*/
}
jar.dependsOn(copyJarsToBuild)
task jarCore(type: Jar, dependsOn: 'classes') {
baseName 'jason-core'
from 'build/classes/main'
from 'build/resources/main'
exclude '**/MindInspectorAgArch*'
exclude '**/MindInspectorWebImpl*'
exclude 'jason/environment/grid/**/*'
exclude 'jason/jeditplugin/**/*'
exclude 'jason/runtime/MASConsole*'
exclude 'jason/runtime/OutputStreamAdapter*'
exclude 'jason/util/ConfigGUI*'
exclude 'jason/util/CheckVersion*'
exclude 'jason/control/ExecutionControlGUI*'
exclude 'jason/infra/centralised/*GUI*'
// exclude 'jason/infra/centralised/RunCentralised*'
// exclude 'jason/infra/jade/**/*'
exclude 'jason/infra/jade/Run*'
exclude 'jason/infra/repl/**/*'
// exclude 'jason/infra/components/**/*'
}
clean {
delete 'bin'
delete 'doc/api'
delete 'doc/faq.html'
delete 'readme.html'
delete 'release-notes.html'
delete fileTree('doc/tutorials') { include '**/*.html' }
delete fileTree('doc/tutorials') { include '**/bin/**/*' }
delete fileTree('.') { include '**/*~' }
delete fileTree('.') { include '**/.stop___MAS' }
delete fileTree('.') { include '**/APDescription.txt' }
delete fileTree('.') { include '**/MTPs-Main-Container.txt' }
delete fileTree('.') { include '**/bookstore.*' }
delete fileTree('examples') { include '**/bin/**' }
delete fileTree('examples') { include '**/*.log' }
delete fileTree('demos') { include '**/bin/**' }
delete fileTree('demos') { include '**/*.log' }
delete 'demos/persistent-belief-base/a.bb'
def emptyDirs = []
fileTree (dir: 'examples').visit {
def File f = it.file
if (f.isDirectory() ) {
def children = project.fileTree(f).filter { it.isFile() }.files
if (children.size() == 0) {
emptyDirs << f
}
}
}
fileTree (dir: 'demos').visit {
def File f = it.file
if (f.isDirectory() ) {
def children = project.fileTree(f).filter { it.isFile() }.files
if (children.size() == 0) {
emptyDirs << f
}
}
}
emptyDirs.reverseEach { it.delete() }
}
test << {
delete fileTree('.') { include '**/bookstore.*' }
}
task config (type: JavaExec, dependsOn: ['jar', 'plugin']) {
main = 'jason.util.Config'
classpath sourceSets.main.runtimeClasspath
workingDir project.buildDir.absolutePath + '/libs'
doFirst {
delete System.getProperty("user.home")+'/.jason'
}
doLast {
println '------'
println ''
println 'you can set the Jason home directory with the following command:'
println ' export JASON_HOME='+project.buildDir.absolutePath
println ''
println 'and also change your PATH with:'
println ' export PATH=$JASON_HOME/scripts:$PATH'
println ''
println '-----'
}
}
eclipse {
classpath {
downloadJavadoc = true
file.whenMerged { cp ->
cp.entries.add( new org.gradle.plugins.ide.eclipse.model.SourceFolder('build/generated/javacc', null) )
}
file.whenMerged { cp ->
logger.lifecycle "Removing duplicate classpath entries from eclipse for project '${project.name}'"
Map entryByPath = cp.entries.groupBy { entry -> entry.path }
entryByPath.each { key, values ->
if (values.size() > 1) {
def entry = values.first()
if (entry.kind == 'src') {
entry.includes = []
entry.excludes = []
}
int index = cp.entries.indexOf entry
logger.lifecycle "Removing ${values.collect { it.path }}"
cp.entries.removeAll values
logger.lifecycle "Adding ${entry.path}"
cp.entries.add index, entry
}
}
}
}
}
task javadoc(overwrite: true, dependsOn: compileJava) {
setDescription('Generates Javadoc API documentation with UMLGraph diagrams')
setGroup(JavaBasePlugin.DOCUMENTATION_GROUP)
doLast {
ant.javadoc(classpath: (configurations.runtime + configurations.compile).asPath,
sourcepath: file('src/main/java'),
packagenames: '*',
destdir: "${docsDir}/../../doc/api",
private: 'true',
docletpath: configurations.umljavadoc.asPath) {
doclet(name: 'org.umlgraph.doclet.UmlGraphDoc') {
//param(name: '-inferrel')
//param(name: '-inferdep')
param(name: '-qualify')
//param(name: '-T', value: 'svg')
param(name: '-postfixpackage')
param(name: '-hide', value: 'java.*')
//param(name: '-collpackages', value: 'java.util.*')
//param(name: '-nodefontsize', value: '9')
//param(name: '-nodefontpackagesize', value: '7')
//param(name: '-link', value: 'http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/doclet/spec')
//param(name: '-link', value: 'http://java.sun.com/j2se/1.5/docs/api')
}
}
}
}
publishing {
publications {
maven(MavenPublication) {
from components.java
artifact sourceJar
artifact javadocJar
artifactId 'jason'
}
}
}
// from http://central.sonatype.org/pages/gradle.html
// uncomment to produce maven jar
task javadocJar (type: Jar, dependsOn: javadoc) {
baseName 'jason'
classifier = 'javadoc'
from '${docsDir}/../../doc/api'
}
task sourceJar (type : Jar) {
baseName 'jason'
classifier = 'sources'
from sourceSets.main.allSource
}
/*
artifacts {
archives sourceJar //, javadocJar
}
signing {
sign configurations.archives
}
uploadArchives {
group = 'net.sf.jason'
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom*.whenConfigured { pom -> pom.dependencies.clear() }
pom.project {
name 'Jason'
packaging 'jar'
groupId 'net.sf.jason'
// optionally artifactId can be defined here
description 'Jason is a fully-fledged interpreter for an extended version of AgentSpeak, a BDI agent-oriented logic programming language.'
url 'http://jason.sf.net'
scm {
connection 'scm:git:https://github.com/jason-lang/jason.git'
developerConnection 'scm:git:https://github.com/jason-lang/jason.git'
url 'https://github.com/jason-lang/jason.git'
}
licenses {
license {
name 'GNU Library or Lesser General Public License version 2.0 (LGPLv2)'
url 'http://www.gnu.org/licenses/gpl-2.0.html'
}
}
developers {
developer {
id 'jomi'
name 'Jomi F. Hubner'
email 'jomifred@gmail.com'
}
developer {
id 'rafael'
name 'Rafael H. Bordini'
email 'rafael.h.bordini@gmail.com'
}
}
}
}
}
}
*/
compileJavacc {
inputDirectory = file('src/main/javacc')
outputDirectory = file(project.buildDir.absolutePath + '/generated/javacc')
}
jjdoc {
outputDirectory = file(project.projectDir.absolutePath + '/doc/tech')
//arguments = [text: 'true']
}
// Builds jEdit plugin
task plugin(type: Jar, dependsOn: 'classes') {
archiveName 'jason-jedit-plugin.jar'
destinationDir file('build/jedit/jars')
from 'build/classes/main'
from 'build/resources/main'
from 'build/resources/main/jeditPlugin'
from ( configurations.compile.collect { zipTree(it) } ) {
include 'jade/**/*.class'
}
doFirst {
ant.untar(compression: 'gzip', dest: 'build', src: 'jedit/jedit.tgz')
}
doLast {
copy {
from 'src/main/resources/jeditPlugin'
into 'build/jedit/modes'
include 'agentSpeak.xml', 'jasonProject.xml', 'catalog'
}
copy {
from 'src/main/resources/jeditPlugin'
into 'build/jedit/properties'
include 'jedit-initial.props'
}
}
}
// transfer local maven artifact to our maven2 repository at sourceforge
task publishMavenSF(dependsOn: [ 'build', 'publishToMavenLocal']) << {
def wdir = System.getProperty("user.home")+'/.m2/repository/org/jason-lang/jason'
def tdir = 'jomifred,jacamo@web.sf.net:/home/project-web/jacamo/htdocs/maven2/org/jason-lang/jason'
exec {
commandLine 'scp', '-r', project.version, tdir
workingDir wdir
}
exec {
commandLine 'cp', 'maven-metadata-local.xml', 'maven-metadata.xml'
workingDir wdir
}
exec {
commandLine 'scp', 'maven-metadata.xml', tdir
workingDir wdir
}
}
// Builds the distribution, documentation and a new release
task doc(dependsOn: [ 'jjdoc', 'javadoc', 'renderAsciiDocs']) << {
}
task renderAsciiDocs(type: Exec) {
commandLine 'find', '.', '-name', '*.adoc', '-exec', 'asciidoctor', '-r', project.buildDir.absolutePath+'/../src/main/resources/pygments_init.rb', '{}', ';'
}
task fixTab {
ant.fixcrlf(eol: 'lf', includes: '**/*.txt,**/*.bat, **/*.adoc', srcdir: '.')
ant.fixcrlf(tab: 'remove', tablength: '4', javafiles: 'true', includes: '**/*.java,**/*.xml,**/*.asl,**/*.mas2j,**/*.txt', srcdir: 'src')
ant.fixcrlf(tab: 'remove', tablength: '4', javafiles: 'true', includes: '**/*.java,**/*.xml,**/*.asl,**/*.mas2j,**/*.txt', srcdir: 'examples')
ant.fixcrlf(tab: 'remove', tablength: '4', javafiles: 'true', includes: '**/*.java,**/*.xml,**/*.asl,**/*.mas2j,**/*.txt', srcdir: 'demos')
ant.fixcrlf(tab: 'remove', tablength: '4', javafiles: 'true', includes: '**/*.java,**/*.xml,**/*.asl,**/*.mas2j,**/*.txt', srcdir: 'doc')
}
// Builds the distribution, documentation and a new release
task release(dependsOn: [ 'build', 'doc', 'fixTab', 'zipRel', 'plugin' ]) << {
}
// copy files used to build a release
task copyRel << {
copy {
from '.'
into 'build/jason-'+project.version
include '*.html'
include 'LICENSE'
include 'scripts/**'
include 'doc/**'
}
delete fileTree('build/jason-'+project.version+'/doc') { include '**/*.adoc', '**/Makefile' }
copy {
from libsDir
from configurations.runtime
into 'build/jason-'+project.version+'/'+libsDirName
include '**/*.jar'
}
copy {
from 'build/jedit'
into 'build/jason-'+project.version+'/jedit'
}
copy {
from 'examples'
into 'build/jason-'+project.version+'/examples'
}
copy {
from 'demos'
into 'build/jason-'+project.version+'/demos'
}
copy {
from 'src'
into 'build/jason-'+project.version+'/src'
}
}
// creates a zip file for a release
task zipRel(type: Zip, dependsOn: copyRel) {
from 'build/jason-'+project.version
baseName 'jason'
}