-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.joe
140 lines (117 loc) · 3.4 KB
/
build.joe
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
/*
* JOE Build script
* It requires Java 7 or newer.
* Note that Windows doesn't allow you to rewrite the jar you are using.
*/
:args.
build := !new "samples/builder.jol".
pathSep := build pathSep.
srcDir := "src/com/veryant/joe".
@compileRaw := {
!if (build anythingNew srcDir,".java",srcDir,".class"), {
rc := build system ("javac -g -cp src "+srcDir+"/*.java").
!if (rc <> 0), {
!throw "Compilation failed!".
}.
}.
}.
compileJoe := {
!if (build anythingNew srcDir,".java",srcDir,".class"), {
revision := "\$Revision: " +
(build systemGetOut "git describe --tag") + " " +
(!newInstance "java.text.SimpleDateFormat","dd-MM-yyyy"
format (!newInstance "java.util.Date")) + "\$".
build replaceFirstInFile (srcDir + "/Revision.java"),
"\$Revision.*\$",revision.
rc := build system ("javac -g -cp src "+srcDir+"/*.java").
!if (rc <> 0), {
!throw "Compilation failed!".
}.
}.
}.
@compileJoe := {
build depends compileJoe.
}.
makeJoeJar := {
build depends compileJoe.
thisJar := build file "jar/joe.jar".
!if (thisJar olderThanAny "src/com/veryant/joe",".class"),{
thisJar delete.
rc := build system ("jar cvfm "+thisJar+" jar/Manifest.txt -C src dummy"
+ " src/com/veryant/joe/*.class").
}.
}.
@makeJoeJar := {
build depends makeJoeJar.
}.
compileIn := {:dir.
build depends makeJoeJar.
!if (build anythingNew dir,".java",dir,".class"), {
rc := build system ("javac -g -cp ""jar/joe.jar"+pathSep+dir+""" "+dir+"/*.java").
!if (rc <> 0), {
!throw ("Compilation in "+ dir + " failed!").
}.
}.
}.
compileLogo := {
compileIn exec "samples/logojoe".
}.
compileForm := {
compileIn exec "samples/form".
}.
makeLogoJar := {
build depends makeJoeJar
depends compileLogo.
thisJar := build file "samples/logojoe/logojoe.jar".
!if ( thisJar olderThan "jar/joe.jar" or (thisJar olderThanAny "samples/logojoe",".class")),{
build copy "jar/joe.jar", (thisJar toString).
rc := build system ("jar uvf " + thisJar + " -C samples/logojoe dummy samples/logojoe/Logo*.class samples/logojoe/joe.png").
}.
}.
@makeLogoJar := {
build depends makeLogoJar.
}.
makeFormJar := {
build depends makeJoeJar
depends compileForm.
thisJar := build file "samples/form/formjoe.jar".
!if ( thisJar olderThan "jar/joe.jar" or
(thisJar olderThanAny "samples/form",".class")),{
build copy "jar/joe.jar",(thisJar toString).
rc := build system ("jar uvf " + thisJar +" -C samples/form dummy samples/form/*.class samples/form/joe.png").
}.
}.
@makeFormJar := {
build depends makeFormJar.
}.
@all := {
!foreach (!! getVariablesNames), {:tag.
!if (tag startsWith "@" and (tag <> "@all")),{
!println "executing: ",tag.
!! getVariable tag exec.
}.
}.
}.
help := {
!println "Usage: joe ",(args get 0)," <tag>".
!println "Available tags:".
!foreach (!! getVariablesNames), {:tag.
!if (tag startsWith "@"),{
!println " ",tag.
}.
}
}.
toExec := .
!if ((args length) > 1),{
toExec := !!getVariable (args get 1).
!if (!isNull toExec),{
!println "Tag ",(args get 1), " is not present!".
help exec.
!systemExit 2.
}.
}.
!if (!isNull toExec),{
help exec.
},{
toExec exec.
}.