-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.bsh
executable file
·259 lines (215 loc) · 8.32 KB
/
build.bsh
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
/*
* Copyright (c) 2009, Brian Hawkins
* Permission is granted to use this code without restriction as long
* as this copyright notice appears in all source files.
*/
import tablesaw.*;
import tablesaw.rules.*;
import tablesaw.addons.junit.*;
import tablesaw.addons.java.*;
//import tablesaw.java.*;
print("========================================================");
saw.setProperty("tablesaw.multiThreadOutput", "true");
blddir = "build";
docsDir = "docs";
classdir = blddir+"/classes";
//testclassdir = blddir+"/test/classes";
gensrcdir = blddir +"/gensrc";
srcdir = "src/main/java";
tstsrc = "test/src";
extdir = "lib";
etcdir = "etc";
intdir = extdir+"/interpreters";
tempdir = "temp";
jardir = blddir+"/jar";
buildVersion = "1.2.8";
versionSrcFile = "tablesaw/Version.java";
javaDocDir = "docs";
/*
tstClassFiles = saw.substitute("(.*)\\.java", classdir+"/$1.class", tstSourceFiles);
tstClassFiles.addAll(classFiles);
*/
new DirectoryRule(blddir);
extJarFiles = new RegExFileSet(extdir, ".*\\.jar").recurse().getFullFilePaths();
distList = new String[]
{
"beanshell",
"jython",
"groovy",
"rhino"
};
etcFiles = new RegExFileSet(etcdir, ".*").getFullFilePaths();
templateFiles = new RegExFileSet(srcdir, ".*")
.setStartDir("tablesaw/templates")
.recurse().getFilePaths();
classpath = new Classpath(extJarFiles);
saw.addSearchPath(".*\\.java", gensrcdir);
saw.addSearchPath(".*\\.java", tstsrc);
//saw.createPatternDependency(".*", "build.bsh");
//-------------------------------------------------------------------
//==-- DIRECTORY RULES --==
docDirRule = new DirectoryRule(javaDocDir);
new DirectoryRule(tempdir);
genDirRule = new DirectoryRule(gensrcdir+"/tablesaw");
//-------------------------------------------------------------------
//Override the clean rule to only remove the build directory
cleanRule = new SimpleRule("clean").setDescription("Removes the build directory")
.setMakeAction("doClean");
void doClean(Rule rule)
{
saw.deltree(blddir);
}
//-------------------------------------------------------------------
//==-- VERSION RULE --==
versionRule = new SimpleRule().setMakeAction("createVersionClass")
.addTarget(gensrcdir+"/"+versionSrcFile)
.addDepend(genDirRule)
.addDepend("build.bsh");
void createVersionClass(Rule rule)
{
print("Creating version class");
dateFormat = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
verClass = new PrintWriter(new FileWriter(gensrcdir+"/"+versionSrcFile));
verClass.println("//This file is generated in the build script");
verClass.println("package tablesaw;");
verClass.println("class Version");
verClass.println("\t{");
verClass.println("\tpublic static String getVersion() { return (\""+
buildVersion+"\");}");
verClass.println("\tpublic static String getBuild() { return (\""+
dateFormat.format(new Date())+"\");}");
verClass.println("\t}");
verClass.close();
}
//-------------------------------------------------------------------
//==-- COMPILE --==
saw.setProperty("tablesaw.java.program.source_directory", srcdir);
saw.setProperty("tablesaw.java.program.class_directory", classdir);
saw.setProperty("tablesaw.java.program.test_source_directory", tstsrc);
jp = new JavaProgram().setProgramName("tablesaw-"+buildVersion).setup();
jc = jp.getCompileRule();
jc.addClasspath(classpath);
jc.addSource(versionSrcFile);
jc.addDepend(versionRule);
jc.getDefinition().set("source", "1.6");
jc.getDefinition().set("target", "1.6");
jp.getTestCompileRule().addClasspath(classpath);
jp.getJarRule().setManifest("manifest.txt")
.addFile("license.txt")
.addFiles(srcdir, templateFiles)
.addFiles(etcFiles)
.addFile(srcdir, "tablesaw/addons/ivy/pom.xsl")
.addFile(srcdir, "tablesaw/tablesaw.properties");
saw.setDefaultTarget("jar");
//------------------------------------------------------------------------------
//==-- COMPILE TEST CODE --==
/* compileTestRule = new JavaCRule("compile-tests", testclassdir)
.addSourceDir("test/src")
.addClasspath(classpath)
.addClasspath(jp.getClassOutDir())
.addDepend(jp); */
//-------------------------------------------------------------------
//==-- UNIT TESTS --==
testSources = new RegExFileSet("test/src", ".*Tests\\.java").recurse()
.addFile("test/src", "tablesaw/TablesawTest.java").getFullFilePaths();
testClasspath = new Classpath(classpath.getPaths()).addPath(jp.getJarRule().getTarget())
.addPath(jp.getTestCompileRule().getBuildDirectory());
testRule = new JUnitRule("test")
.addDepend(jp.getTestCompileRule())
.addDepend(tempdir)
.addDepend("jar")
.addSources(testSources)
.setClasspath(testClasspath);
//-------------------------------------------------------------------
//==-- JAVADOC DOCUMENTATION --==
new SimpleRule("javadoc").setMakeAction("doJavadoc").override()
.addDepend(docDirRule);
void doJavadoc(Rule rule)
{
//cmd = "javadoc -classpath "+classpath+" -sourcepath src -public -d doc tablesaw";
cmd = "javadoc -classpath "+classpath+" -sourcepath src -public -d "+javaDocDir+" "+
"tablesaw tablesaw.rules tablesaw.ant tablesaw.definitions tablesaw.addons.c "+
"tablesaw.addons tablesaw.addons.java tablesaw.java tablesaw.addons.csharp "+
"tablesaw.addons.ivy tablesaw.addons.junit";
saw.exec(cmd);
}
//------------------------------------------------------------------------------
//Build Docs
new SimpleRule("docs").setDescription("Build Sphinx Documentation")
.setMakeAction("doDocs")
.addSources(new RegExFileSet("src/docs", ".*").recurse().getFullFilePaths())
.setProperty("all", false);
new SimpleRule("docs-rebuild").setDescription("Rebuild Sphinx Documentation. All docs are built even if not changed.")
.setMakeAction("doDocs")
.addSources(new RegExFileSet("src/docs", ".*").recurse().getFullFilePaths())
.setProperty("all", true);
void doDocs(Rule rule)
{
command = "sphinx-build";
if (rule.getProperty("all"))
command += " -a";
sudo = saw.createAsyncProcess(".", command+" -b html src/docs "+docsDir);
sudo.run();
sudo.waitForProcess();
if (sudo.getExitCode() != 0)
throw new TablesawException("Unable to run sphinx-build");
}
//------------------------------------------------------------------------------
//==-- BUILD SLICK XML PARSER --==
new SimpleRule("slickxml").setDescription("Build slickxml parser")
.setMakeAction("doSlickXML");
void doSlickXML(Rule rule)
{
cmd = "java -cp "+classpath+" slickxml.SlickParser etc/slick_config.xml";
saw.exec(cmd);
}
//-------------------------------------------------------------------
//==-- CREATE DISTRIBUTION JAR FILES --==
/* saw.createPhonyRule("dist", jarfile, null);
for (dist : distList)
{
saw.createDirectoryRule(tempdir+"/"+dist, null, true);
saw.createPhonyRule(dist, tempdir+"/"+dist, "extractJars");
saw.createRecursiveCopyRule("copytablesawTo"+dist, new String[] {"compile"},
blddir, ".*", tempdir+"/"+dist);
distjar = jardir+"/tablesaw_"+dist+".jar";
saw.createExplicitRule(distjar, new String[]
{
dist,
jardir,
"compile",
"copytablesawTo"+dist,
}, "createDistJar", true);
saw.createExplicitDependency("dist", distjar);
}
extractJars(String target, String[] prereqs)
{
print("Extracting "+target);
extractList = saw.createFileList(intdir+"/"+target, ".*\\.jar",
saw.INCLUDE_PATH);
for (jar : extractList)
saw.exec(prereqs[0], "jar -xf ../../"+jar, true);
}
createDistJar(String target, String[] prereqs)
{
print("Creating "+target);
rm(target);
String cmd = "jar -cfm "+target+" manifest.txt license.txt -C "+
tempdir+"/"+prereqs[0]+" .";
saw.exec(cmd);
} */
//-------------------------------------------------------------------
//==-- COMPILE TEST CODE --==
/*saw.createPhonyRule("test", "onejar", "test");
void test(String target, String[] prereqs)
{
print("running test");
cwd = "test/c++";
saw.exec(cwd, "java -cp ../../jar/tablesaw.jar tablesaw.Tablesaw -f build.bsh clean test", true);
saw.exec(cwd, "java -cp ../../jar/tablesaw.jar tablesaw.Tablesaw -f build.py clean test clean", true);
//saw.exec(cwd, "java -cp ../../jar/tablesaw.jar tablesaw.Tablesaw -f build.groovy clean test clean", true);
cwd = "test/java";
saw.exec(cwd, "java -cp ../../jar/tablesaw.jar tablesaw.Tablesaw -f build.bsh clean test", true);
saw.exec(cwd, "java -cp ../../jar/tablesaw.jar tablesaw.Tablesaw -f build.py clean test clean", true);
//saw.exec(cwd, "java -cp ../../jar/tablesaw.jar tablesaw.Tablesaw -f build.groovy clean test clean", true);
}*/