Subversion Repository Public Repository

litesoft

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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
<!DOCTYPE html>
<html><head>
 <link rel="icon" type="image/vnd.microsoft.icon" href="http://www.gstatic.com/codesite/ph/images/phosting.ico">


 <script type="text/javascript">




 var codesite_token = null;


 var CS_env = {"assetHostPath":"http://www.gstatic.com/codesite/ph","projectName":"scar","projectHomeUrl":"/p/scar","urlPrefix":"p","domainName":null,"relativeBaseUrl":"","profileUrl":null,"token":null,"assetVersionPath":"http://www.gstatic.com/codesite/ph/3282150342600863652","absoluteBaseUrl":"http://code.google.com","loggedInUserEmail":null};
 var _gaq = _gaq || [];
 _gaq.push(
 ['siteTracker._setAccount', 'UA-18071-1'],
 ['siteTracker._trackPageview']);

 _gaq.push(
 ['projectTracker._setAccount', 'UA-10796293-1'],
 ['projectTracker._trackPageview']);


 </script>


 <title>
 scar -  Simple Java-based build system for Java - Google Project Hosting
 </title>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

 <meta name="ROBOTS" content="NOARCHIVE">

 <link type="text/css" rel="stylesheet" href="Scar_files/ph_core.css">

 <link type="text/css" rel="stylesheet" href="Scar_files/ph_detail.css">




<!--[if IE]>
 <link type="text/css" rel="stylesheet" href="http://www.gstatic.com/codesite/ph/3282150342600863652/css/d_ie.css" >
<![endif]-->
 <style type="text/css">
 .menuIcon.off { background: no-repeat url(http://www.gstatic.com/codesite/ph/images/dropdown_sprite.gif) 0 -42px }
 .menuIcon.on { background: no-repeat url(http://www.gstatic.com/codesite/ph/images/dropdown_sprite.gif) 0 -28px }
 .menuIcon.down { background: no-repeat url(http://www.gstatic.com/codesite/ph/images/dropdown_sprite.gif) 0 0; }



 .activity-level-High {
 background:no-repeat url(http://www.gstatic.com/codesite/ph/images/activity-level.png) 0 0;
 width: 16px;
 height: 16px;
 }
 .activity-level-Low {
 background:no-repeat url(http://www.gstatic.com/codesite/ph/images/activity-level.png) 0 -16px;
 width: 16px;
 height: 16px;
 }
 .activity-level-Medium {
 background: no-repeat url(http://www.gstatic.com/codesite/ph/images/activity-level.png) -16px 0;
 width: 16px;
 height: 16px;
 }
 .activity-level-None {
 background:no-repeat url(http://www.gstatic.com/codesite/ph/images/activity-level.png) -16px -16px;
 width: 16px;
 height: 16px;
 }



 </style>
<script src="Scar_files/ga.js" async="" type="text/javascript"></script><script src="Scar_files/googleapis.js"></script></head>
<body class="t1">
<script type="text/javascript">
 (function() {
 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
 (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
 })();
</script>
<div class="headbg">

 <div id="gaia">


 <span>

 <a href="#" id="projects-dropdown" onclick="return false;"><u>My favorites</u> <small>▼</small></a>
 | <a href="https://www.google.com/accounts/ServiceLogin?service=code&amp;ltmpl=phosting&amp;continue=http%3A%2F%2Fcode.google.com%2Fp%2Fscar%2F&amp;followup=http%3A%2F%2Fcode.google.com%2Fp%2Fscar%2F" onclick="_CS_click('/gb/ph/signin');"><u>Sign in</u></a>

 </span>

 </div>

 <div class="gbh" style="left: 0pt;"></div>
 <div class="gbh" style="right: 0pt;"></div>


 <div style="height: 1px"></div>
<!--[if lte IE 7]>
<div style="text-align:center;">
Your version of Internet Explorer is not supported. Try a browser that
contributes to open source, such as <a href="http://www.firefox.com">Firefox</a>,
<a href="http://www.google.com/chrome">Google Chrome</a>, or
<a href="http://code.google.com/chrome/chromeframe/">Google Chrome Frame</a>.
</div>
<![endif]-->




 <table style="padding: 0px; margin: 0px 0px 10px; width: 100%;" cellpadding="0" cellspacing="0">
 <tbody><tr style="height: 58px;">

 <td id="plogo">
 <a href="http://code.google.com/p/scar/">


 <img src="Scar_files/logo.png" alt="Logo">

 </a>
 </td>

 <td style="padding-left: 0.5em;">

 <div id="pname">
 <a href="http://code.google.com/p/scar/">scar</a>
 </div>

 <div id="psum">
 <a id="project_summary_link" href="http://code.google.com/p/scar/">Simple Java-based build system for Java</a>

 </div>


 </td>
 <td style="white-space: nowrap; text-align: right; vertical-align: bottom;">

 <form action="/hosting/search">
 <input size="30" name="q" type="text">

 <input name="projectsearch" value="Search projects" type="submit">
 </form>

 </td></tr>
 </tbody></table>

</div>


<div id="mt" class="gtb">
 <a href="http://code.google.com/p/scar/" class="tab active">Project&nbsp;Home</a>




 <a href="http://code.google.com/p/scar/downloads/list" class="tab ">Downloads</a>







 <a href="http://code.google.com/p/scar/issues/list" class="tab ">Issues</a>





 <a href="http://code.google.com/p/scar/source/checkout" class="tab ">Source</a>





 <div class="gtbc"></div>
</div>
<table class="st" align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
 <tbody><tr>







 <td class="subt">
 <div class="st1">
 <div class="isf">
 <span class="inst1">
 <a href="http://code.google.com/p/scar/">Summary</a>
 </span>


 &nbsp;
 <span class="inst2">
 <a href="http://code.google.com/p/scar/updates/list">Updates</a>
 </span>


 &nbsp;
 <span class="inst3">
 <a href="http://code.google.com/p/scar/people/list">People</a>
 </span>


 </div>
</div>

 </td>


 <td class="bevel-right" align="right" valign="top"></td>
 </tr>
</tbody></table>


<script type="text/javascript">
 var cancelBubble = false;
 function _go(url) { document.location = url; }
</script>
<div id="maincol">


<!-- IE -->





<table width="100%">
 <tbody><tr class="pscontent">
 <td class="pscolumnl">

 <div class="phead">Project Information</div>


 <ul class="pslist">


 <li class="psmeta">
 <a href="http://code.google.com/p/scar/updates/list">Activity</a> &nbsp;
 <img src="Scar_files/cleardot.gif" class="activity-level-None">
 <span>None</span>
 </li>

 <li class="psmeta">
 <a href="http://code.google.com/p/scar/feeds">Project feeds</a>
 </li>

 <li class="psgap">




 </li><li class="psmeta"><b>Code license</b></li>
 <li class="psmeta">
 <a href="http://www.opensource.org/licenses/bsd-license.php" rel="nofollow">New BSD License</a>

 </li>
 <li class="psgap">






 </li><li class="psmeta">
 <span id="project_labels">
 <b>Labels</b><br>

 <a class="label" href="http://code.google.com/hosting/search?q=label:java">java</a>,

 <a class="label" href="http://code.google.com/hosting/search?q=label:build">build</a>,

 <a class="label" href="http://code.google.com/hosting/search?q=label:compile">compile</a>,

 <a class="label" href="http://code.google.com/hosting/search?q=label:jar">jar</a>,

 <a class="label" href="http://code.google.com/hosting/search?q=label:jws">jws</a>,

 <a class="label" href="http://code.google.com/hosting/search?q=label:javawebstart">javawebstart</a>,

 <a class="label" href="http://code.google.com/hosting/search?q=label:jnlp">jnlp</a>,

 <a class="label" href="http://code.google.com/hosting/search?q=label:war">war</a>

 </span>
 </li>
 <li class="psgap">


 </li></ul>
 <div class="psicon">
 <img src="Scar_files/people-y16.png" height="15" width="15">
 <span><b>Members</b></span>
 </div>
 <ul class="pslist">



 <a style="white-space: nowrap;" href="http://code.google.com/u/@VhlVQVZZDhZMXAZ0/">nathan.s...@gmail.com</a>




 <li class="psgap">


 </li></ul>


 <div class="phead pfeatured">Featured</div>

 <div class="psicon">
 <img src="Scar_files/filedownload-g16.png" height="15" width="15">
 <span><b>Downloads</b></span>
 </div>
 <ul class="pslist">

 <li id="downloadbox" class="psmeta">
 <a title="Download" href="http://scar.googlecode.com/files/scar-1.04.zip" onclick="_gaq.push(['siteTracker._trackEvent', 'Download - Downloaded', '//scar.googlecode.com/files/scar-1.04.zip', 'Featured, Type-Archive, OpSys-All']);_gaq.push(['projectTracker._trackEvent', 'Download - Downloaded', '//scar.googlecode.com/files/scar-1.04.zip', 'Featured, Type-Archive, OpSys-All']);">
 </a>
 <a href="http://code.google.com/p/scar/downloads/detail?name=scar-1.04.zip" title="Scar 1.04">scar-1.04.zip</a>
 </li>

 <li class="psmeta"><a href="http://code.google.com/p/scar/downloads/list">Show all »</a></li>
 <li class="psgap">
 </li></ul>





 <div class="phead">Links</div>
 <ul class="pslist" style="white-space:nowrap">


 <li class="psmeta"><b>External links</b></li>

 <li class="psmeta">
 <a href="http://scar.googlecode.com/svn/api/index.html" rel="nofollow">Javadoc</a>
 </li>

 <li class="psgap">


 </li><li class="psmeta"><b>Groups</b></li>

 <li class="psmeta">
 <a href="http://groups.google.com/group/scar-users" rel="nofollow">Scar Discussion</a>
 </li>

 <li class="psgap">

 </li></ul>

 </td>
 <td id="wikicontent" class="psdescription">
 <p><img src="Scar_files/logo_002.png"> </p><h2><a name="Overview"></a>Overview<a href="#Overview" class="section_anchor"></a></h2><p>Scar
 is a collection of utilities for building Java projects. The goal of
the project is simplicity. Simple projects should be trivial to build,
and more complex builds should be easy to customize. </p><h2><a name="Why_use_Scar?"></a>Why use Scar?<a href="#Why_use_Scar?" class="section_anchor"></a></h2><p>Because
 it is simple. Most projects can be built without writing any build
code. When needed, builds can be written in Java. This allows the build
process to be debugged and increases productivity by using familiar
tools. Scar enables builds to be written without Java's typical
verbosity. </p><p>With Scar you can never get stuck; you always know
what is going on. There is no new language to learn or XML attributes to
 look up. You already know how to write Java code to build your project.
 If you need to dive into Scar to see what is going on, each utility
method is only <a href="http://code.google.com/p/scar/source/browse/trunk/scar/src/com/esotericsoftware/scar/Scar.java#235" rel="nofollow">a few lines of code</a>. If you must do things significantly different, you can paste a few lines into your build and customize them. </p><p>Scar
 replaces Java build systems that are overly complex. Building Java
projects has been plagued with suboptimal tools that have a steep
learning curve and are difficult to customize. Scar remedies this in the
 absolute simplest manner possible. </p><h2><a name="Quickstart"></a>Quickstart<a href="#Quickstart" class="section_anchor"></a></h2><p>Scar can be run on a project directory: </p><pre class="prettyprint"><span class="pln">cd some</span><span class="pun">/</span><span class="pln">project<br>scar</span></pre><p>Note: if Scar is not on your shell's path, you will need to specify the path to the <tt>scar</tt> executable (SH or BAT file). </p><p>This runs the <a href="http://code.google.com/p/scar/#Build" rel="nofollow">`build` utility method</a> which will compile and JAR the project under a directory named <tt>target</tt> next to the project directory. The <a href="http://code.google.com/p/scar/#Utility_project_properties" rel="nofollow">default project properties</a> will be used. If a <tt>project.yaml</tt> file is found, those properties will be used. </p><p>Projects
 properties can be specified in a YAML text file or solely with Java
code. Scar can be run from the command line or through an IDE for
debugging. The default build can be used or custom builds can be written
 with Java code. Many utility methods are available for common tasks. </p><h2><a name="Paths"></a>Paths<a href="#Paths" class="section_anchor"></a></h2><p>Scar uses the <a href="http://code.google.com/p/wildcard/" rel="nofollow">Wildcard</a>
 library to collect and manipulate files. For many tasks, the majority
of the work is collecting the files to act upon, and Wildcard makes this
 easy. See the <a href="http://code.google.com/p/wildcard/" rel="nofollow">Wildcard documentation</a> for how to construct paths. </p><p>Paths used in YAML files can be either a single entry or a list. They should use the <a href="http://code.google.com/p/wildcard/#Pipe_delimited_patterns" rel="nofollow">pipe delimited patterns</a> format. Some <a href="http://code.google.com/p/scar/#YAML_examples" rel="nofollow">YAML examples</a> are provided below. </p><h2><a name="Projects"></a>Projects<a href="#Projects" class="section_anchor"></a></h2><p>A project in Scar is an object graph containing data needed for the desired tasks. The root of the object graph is always a <tt>!HashMap</tt>, but there is no restriction on the types of keys and values. The <tt>Project</tt>
 class itself is a generic data structure and doesn't know anything
about how the data will be used. The requirements for what should be
specified in the project are determined by the tasks that need to be
performed. </p><p>Projects can be defined entirely in Java: </p><pre class="prettyprint"><span class="typ">Project</span><span class="pln"> project </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">Project</span><span class="pun">();</span><span class="pln"><br>project</span><span class="pun">.</span><span class="kwd">set</span><span class="pun">(</span><span class="str">"name"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"AwesomeLib"</span><span class="pun">);</span><span class="pln"><br></span><span class="typ">ArrayList</span><span class="pln"> source </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">ArrayList</span><span class="pun">();</span><span class="pln"><br>source</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="str">"src"</span><span class="pun">);</span><span class="pln"><br>source</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="str">"other"</span><span class="pun">);</span><span class="pln"><br>project</span><span class="pun">.</span><span class="kwd">set</span><span class="pun">(</span><span class="str">"source"</span><span class="pun">,</span><span class="pln"> source</span><span class="pun">);</span></pre><p>Projects can also be loaded from a <a href="http://www.yaml.org/" rel="nofollow">YAML</a> file on disk. YAML is a human readable format that makes it easy to specify the project object graph. Scar uses the <a href="http://code.google.com/p/yamlbeans/" rel="nofollow">YamlBeans</a> library to parse YAML. </p><pre class="prettyprint"><span class="pln">name</span><span class="pun">:</span><span class="pln"> </span><span class="typ">AwesomeLib</span><span class="pln"><br>source</span><span class="pun">:</span><span class="pln"><br></span><span class="pun">-</span><span class="pln"> src<br></span><span class="pun">-</span><span class="pln"> other</span></pre><pre class="prettyprint"><span class="typ">Project</span><span class="pln"> project </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">Project</span><span class="pun">(</span><span class="str">"project.yaml"</span><span class="pun">);</span></pre><p>Separate
 from the object graph, a project can also store a "document" string.
What is done with this string is left up to the code that is actually
performing the tasks, but it is typically used to hold some code that
should be run to perform tasks. The document can be set in Java with the
 Project#setDocument(String) method. It can also be provided in YAML by
using the document separator "---": </p><pre class="prettyprint"><span class="pln">name</span><span class="pun">:</span><span class="pln"> </span><span class="typ">AwesomeLib</span><span class="pln"><br>source</span><span class="pun">:</span><span class="pln"><br></span><span class="pun">-</span><span class="pln"> src<br></span><span class="pun">-</span><span class="pln"> other<br></span><span class="pun">---</span><span class="pln"><br></span><span class="typ">System</span><span class="pun">.</span><span class="kwd">out</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="str">"The document can be any string, "</span><span class="pun">);</span><span class="pln"><br></span><span class="typ">System</span><span class="pun">.</span><span class="kwd">out</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="str">"but is a convenient place to put code."</span><span class="pun">);</span></pre><p>More <a href="http://code.google.com/p/scar/#YAML_examples" rel="nofollow">YAML examples</a> are provided below. </p><h2><a name="Scar_utilities"></a>Scar utilities<a href="#Scar_utilities" class="section_anchor"></a></h2><p>The <tt>Paths</tt> and <tt>Project</tt> classes make up the core of the Scar build system. All that remains is to actually do the work necessary. The <tt>Scar</tt>
 class has many static utility methods for common Java build tasks.
Using these utility methods is optional, but often very helpful. Most
projects can be built using only the utility methods on the <tt>Scar</tt> class. Some projects may use the <tt>Scar</tt>
 class for generic needs, and add some custom code for more specific
tasks. Very complex projects with very specific needs (eg, non-Java
projects) may choose to write custom code for all tasks, using Scar only
 as a launcher and for the powerful <tt>Paths</tt> and <tt>Project</tt> classes. </p><h3><a name="Scar_project_properties"></a>Scar project properties<a href="#Scar_project_properties" class="section_anchor"></a></h3><p>While the <tt>Project</tt>
 class has no requirements on what data must be specified, the Scar
utility methods do look for some specific properties that describe a
Java project: </p><p></p><table class="wikitable"><tbody><tr><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> <strong>Property</strong> </td><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> <strong>Description</strong> </td></tr> <tr><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> name </td><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> The name of the project. Used to name the JAR.<br>Default: The name of the directory containing the project YAML file. </td></tr> <tr><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> target </td><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> The directory to output build artifacts.<br>Default: The directory containing the project YAML file, plus "../target/<tt>name</tt>". </td></tr> <tr><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> version </td><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> The version of the project. If available, used to name the JAR.<br>Default: <i>blank</i> </td></tr> <tr><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> resources </td><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> Wildcard patterns for the files to include in the JAR.<br>Default: <tt>resources</tt> and <tt>src/main/resources</tt>. </td></tr> <tr><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> dist </td><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> Wildcard patterns for the files to include in the distribution, outside the JAR.<br>Default: <tt>dist</tt>. </td></tr> <tr><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> source </td><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> Wildcard patterns for the Java files to compile.<br>Default: <tt>src|**/*.java</tt> and <tt>src/main/java|**/*.java</tt>. </td></tr> <tr><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> classpath </td><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> Wildcard patterns for the files to include on the classpath.<br>Default: <tt>lib|**/*.jar</tt>. </td></tr> <tr><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> dependencies </td><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> Relative or absolute paths to dependency project directories or YAML files.<br>Default: <i>blank</i> </td></tr> <tr><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> include </td><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> Relative or absolute paths to project files to inherit properties from.<br>Default: <i>blank</i> </td></tr> <tr><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> main </td><td style="border: 1px solid rgb(204, 204, 204); padding: 5px;"> Name of the main class.<br>Default: <i>blank</i> </td></tr> </tbody></table><p></p><p>A <tt>Project</tt>
 instance created through one of its constructors will not have default
properties. The Scar.project(path) method creates a project with default
 properties and also handles loading other projects for the <tt>include</tt> property. It takes a path to a project YAML file or to a directory containing a <tt>project.yaml</tt> file and does the following: </p><ol><li>Creates a project loaded with the default properties listed above. </li><li>Merges each YAML file specified in the <tt>include</tt> section of the specified YAML file. This allows multiple projects to share defaults. </li><li>Merges the specified YAML file. </li></ol><h2><a name="Utility_methods"></a>Utility methods<a href="#Utility_methods" class="section_anchor"></a></h2><h3><a name="Build"></a>Build<a href="#Build" class="section_anchor"></a></h3><p>When Scar is run from the command line, the <tt>Scar</tt> class' main method runs the <tt>build</tt> method. This calls the <tt>buildDependencies</tt>, <tt>clean</tt>, <tt>compile</tt>, <tt>jar</tt>, and <tt>dist</tt>
 utility methods, which build all depenency projects (recursively),
clean the output directory, compile sources, JAR class files and
resoures, and place all distribution files in a directory. </p><p>Because
 the project describes what the files are, this is often a sufficient to
 completely build a Java project. If the build does need to be
customized, a new Java class can be created which calls Scar utility
methods and/or other Java APIs. </p><p>Developing the build in Java
increases productivity by allowing the build process to be debugged in
an IDE. However, once the build is working correctly, it may be awkward
to compile a Java source file and run it from the command line. For
convenience, the Java build code can be included in the YAML file: </p><pre class="prettyprint"><span class="pln">source</span><span class="pun">:</span><span class="pln"> tools</span><span class="pun">|**.</span><span class="pln">java<br>resources</span><span class="pun">:</span><span class="pln"><br></span><span class="pun">-</span><span class="pln"> images<br></span><span class="pun">-</span><span class="pln"> fonts</span><span class="pun">|!</span><span class="pln">arial</span><span class="pun">.</span><span class="pln">ttf<br>main</span><span class="pun">:</span><span class="pln"> com</span><span class="pun">.</span><span class="pln">example</span><span class="pun">.</span><span class="typ">MainClass</span><span class="pln"><br></span><span class="pun">---</span><span class="pln"><br>DEBUG</span><span class="pun">();</span><span class="pln"><br>compile</span><span class="pun">(</span><span class="pln">project</span><span class="pun">);</span><span class="pln"><br>jar</span><span class="pun">(</span><span class="pln">project</span><span class="pun">);</span><span class="pln"><br>dist</span><span class="pun">(</span><span class="pln">project</span><span class="pun">);</span><span class="pln"><br>keystore</span><span class="pun">(</span><span class="str">"keystore"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"alias"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"password"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"Company"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"Title"</span><span class="pun">);</span><span class="pln"><br>jws</span><span class="pun">(</span><span class="pln">project</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">,</span><span class="pln"> </span><span class="str">"keystore"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"alias"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"password"</span><span class="pun">);</span><span class="pln"><br>jnlp</span><span class="pun">(</span><span class="pln">project</span><span class="pun">,</span><span class="pln"> </span><span class="str">"http://example.com/run.jnlp"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"Company"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"Title"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"splash.png"</span><span class="pun">);</span></pre><p>If the YAML file has code, the <tt>build</tt>
 method runs the code instead of the default set of utility methods. The
 code is compiled as if it were a Java method body. The scope the code
is executed in has the predefined variable "project". </p><p>Imports can be specified at the start of the code. These imports are always automatically used: </p><pre class="prettyprint"><span class="kwd">import</span><span class="pln"> com</span><span class="pun">.</span><span class="pln">esotericsoftware</span><span class="pun">.</span><span class="pln">scar</span><span class="pun">.*;</span><span class="pln"><br></span><span class="kwd">import</span><span class="pln"> com</span><span class="pun">.</span><span class="pln">esotericsoftware</span><span class="pun">.</span><span class="pln">wildcard</span><span class="pun">.</span><span class="typ">Paths</span><span class="pun">;</span><span class="pln"><br></span><span class="kwd">import</span><span class="pln"> com</span><span class="pun">.</span><span class="pln">esotericsoftware</span><span class="pun">.</span><span class="pln">minlog</span><span class="pun">.</span><span class="typ">Log</span><span class="pun">;</span><span class="pln"><br></span><span class="kwd">import</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> com</span><span class="pun">.</span><span class="pln">esotericsoftware</span><span class="pun">.</span><span class="pln">scar</span><span class="pun">.</span><span class="typ">Scar</span><span class="pun">.*;</span><span class="pln"><br></span><span class="kwd">import</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> com</span><span class="pun">.</span><span class="pln">esotericsoftware</span><span class="pun">.</span><span class="pln">minlog</span><span class="pun">.</span><span class="typ">Log</span><span class="pun">.*;</span></pre><p>Additional
 classpath entries can be specified at the start of the code. A special,
 non-Java "classpath" statement is used to specify a classpath URL: </p><pre class="prettyprint"><span class="pln">classpath someTools</span><span class="pun">.</span><span class="pln">jar</span><span class="pun">;</span><span class="pln"><br>classpath build</span><span class="pun">/</span><span class="pln">someOtherTools</span><span class="pun">.</span><span class="pln">jar</span><span class="pun">;</span><span class="pln"><br>classpath </span><span class="pun">/</span><span class="pln">tools</span><span class="pun">/</span><span class="pln">moreTools2</span><span class="pun">.</span><span class="pln">jar</span><span class="pun">;</span><span class="pln"><br>classpath c</span><span class="pun">:</span><span class="str">/tools/</span><span class="pln">moreTools2</span><span class="pun">.</span><span class="pln">jar</span><span class="pun">;</span><span class="pln"><br>classpath http</span><span class="pun">:</span><span class="com">//example.com/tools/moreTools3.jar;</span></pre><p>Classes are always found in these classpath entries before the classloader that loaded Scar is checked. </p><h3><a name="Clean"></a>Clean<a href="#Clean" class="section_anchor"></a></h3><p>Scar.clean(project) deletes the target directory and all files and directories under it. </p><h3><a name="Compile"></a>Compile<a href="#Compile" class="section_anchor"></a></h3><p>Scar.compile(project) collects the source files using the <tt>source</tt> property and compiles them into a <tt>classes</tt> directory under the <tt>target</tt> directory. It uses <tt>classpath</tt> and <tt>dependencies</tt> to find the libraries required to compile the source. Each dependency project is automatically built. </p><h3><a name="JAR"></a>JAR<a href="#JAR" class="section_anchor"></a></h3><p>Scar.jar(project) collects the class files from the <tt>classes</tt> directory and all the resource files using the <tt>resources</tt> property and encodes them into a JAR file. </p><p>If the resources don't contain a META-INF/MANIFEST.MF file, one is generated. If the project has a <tt>main</tt>
 property, the generated manifest will include "Main-Class" and
"Class-Path" entries to allow the main class to be run with "java -jar".
 </p><h3><a name="Distribution"></a>Distribution<a href="#Distribution" class="section_anchor"></a></h3><p>Scar.dist(project) collects the distribution files using the <tt>dist</tt>
 property, the project's JAR file, and everything on the project's
classpath (including dependency project classpaths) and places them into
 a <tt>dist</tt> directory under the <tt>target</tt> directory. This is everything the application needs to be run from JAR files. </p><h3><a name="One_JAR"></a>One JAR<a href="#One_JAR" class="section_anchor"></a></h3><p>Scar.oneJAR(project) unzips all JARs in the <tt>dist</tt>
 directory and replaces them all with a single JAR. The manifest from
the project's JAR is used. Putting everything into a single JAR makes it
 harder to see what libraries are being used, but makes it easier for
end users to distribute the application. </p><p>Note: Files with the
same path in different JARs will be overwritten. Files in the project's
JAR will never be overwritten, but may overwrite other files. </p><h3><a name="Java_Web_Start"></a>Java Web Start<a href="#Java_Web_Start" class="section_anchor"></a></h3><p>Scar.jws(project, pack, keystoreFile, alias, password) copies all the JAR and JNLP files from the <tt>dist</tt> directory to a <tt>jws</tt> directory under the <tt>target</tt> directory. It then signs each JAR. If the "pack" parameter is true, it also compresses each JAR using <a href="http://en.wikipedia.org/wiki/Pack200" rel="nofollow">pack200</a> and GZIP. </p><p>Note: Scar.keystore(...) can be used to create a new keystore. </p><p>Scar.jnlp(project, url, company, title, splashImage) generates a JNLP file in the <tt>jws</tt> directory. JARs in the <tt>jws</tt>
 directory are included in the JNLP. JARs with names containing "native"
 and "win", "mac", "linux", or "solaris" are properly included in the
native section of the JNLP. The <tt>main</tt> property is used for the main class in the JNLP. </p><p>Scar.jwsHtaccess(project) generates ".htaccess" and "type map" VAR files in the <tt>jws</tt>
 directory. These files allow Apache to serve both pack200/gzipped JARs
and regular JARs, based on capability of the client requesting the JAR. <a href="http://joust.kano.net/weblog/archive/2004/10/16/pack200-on-apache-web-server/" rel="nofollow">More information</a>. </p><h3><a name="LWJGL_applets"></a>LWJGL applets<a href="#LWJGL_applets" class="section_anchor"></a></h3><p><a href="http://lwjgl.org/" rel="nofollow">LWJGL</a> is a Java library for writing commercial quality, hardware accelerated games. LWJGL has a sophisticated <a href="http://sourceforge.net/projects/java-game-lib/files/" rel="nofollow">applet loader</a>
 that supports pack200 and LZMA. Scar.lwjglApplet(project, keystoreFile,
 alias, password) will copy all the JAR and HTML files from the <tt>dist</tt> directory to a <tt>lwjgl-applet</tt> directory under the <tt>target</tt> directory. It then uses pack200 and/or LZMA on the files, as appropriate. If no HTML file is found and the project has a <tt>main</tt> property, an "applet.html" file will be generated. </p><h3><a name="FTP"></a>FTP<a href="#FTP" class="section_anchor"></a></h3><p>Scar's FTP class has utility methods that make use of <a href="http://commons.apache.org/net/" rel="nofollow">Apache's Jakarta Commons Net</a> to do FTP transfers. For example: </p><pre class="prettyprint"><span class="typ">String</span><span class="pln"> appletDir </span><span class="pun">=</span><span class="pln"> project</span><span class="pun">.</span><span class="pln">format</span><span class="pun">(</span><span class="str">"{target}/applet-lwjgl"</span><span class="pun">);</span><span class="pln"><br></span><span class="typ">Paths</span><span class="pln"> paths </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">Paths</span><span class="pun">(</span><span class="pln">appletDir</span><span class="pun">);</span><span class="pln"><br>FTP</span><span class="pun">.</span><span class="pln">upload</span><span class="pun">(</span><span class="str">"example.com"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"user"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"pass"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"/httpdocs/applet"</span><span class="pun">,</span><span class="pln"> paths</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span></pre><p>This collects all the files in the <tt>lwjgl-applet</tt> directory under the <tt>target</tt> directory and uploads them via FTP. </p><h3><a name="Other_utilities"></a>Other utilities<a href="#Other_utilities" class="section_anchor"></a></h3><p>The <a href="http://scar.googlecode.com/svn/api/index.html?com/esotericsoftware/scar/Scar.html" rel="nofollow">Scar class</a> has many other utility methods. </p><h2><a name="Logging"></a>Logging<a href="#Logging" class="section_anchor"></a></h2><p>Scar uses the <a href="http://code.google.com/p/minlog/" rel="nofollow">MinLog</a> library for logging. Little is logged at the <tt>INFO</tt> level, which is the default. The <tt>DEBUG</tt> and <tt>TRACE</tt> levels can be enabled for increasingly more information: </p><pre class="prettyprint"><span class="typ">Log</span><span class="pun">.</span><span class="pln">DEBUG</span><span class="pun">();</span></pre><pre class="prettyprint"><span class="typ">Log</span><span class="pun">.</span><span class="pln">TRACE</span><span class="pun">();</span></pre><p>Besides logging, since Scar is simply Java code, a build can be run through a debugger to quickly figure out problems. </p><h2><a name="YAML_examples"></a>YAML examples<a href="#YAML_examples" class="section_anchor"></a></h2><p>Wildcard properties can be specified as a single item: </p><pre class="prettyprint"><span class="pln">source</span><span class="pun">:</span><span class="pln"> src</span><span class="pun">|**</span><span class="com">/*.java<br>resources: resources<br>classpath: lib|**/</span><span class="pun">*.</span><span class="pln">jar<br>dist</span><span class="pun">:</span><span class="pln"> dist</span></pre><p>Or as a list: </p><pre class="prettyprint"><span class="pln">source</span><span class="pun">:</span><span class="pln"><br></span><span class="pun">-</span><span class="pln"> src</span><span class="pun">|**</span><span class="com">/*.java<br>- tools|**/</span><span class="pun">*.</span><span class="pln">java<br>resources</span><span class="pun">:</span><span class="pln"><br></span><span class="pun">-</span><span class="pln"> resources</span><span class="pun">/</span><span class="pln">main</span><span class="pun">|!**/</span><span class="pln">test</span><span class="com">/**<br>- resources/images|*.png|*.jpg<br>classpath: lib|**/</span><span class="pun">*.</span><span class="pln">jar<br>dist</span><span class="pun">:</span><span class="pln"> dist</span></pre><p>A more complex example that uses all the properties: </p><pre class="prettyprint"><span class="pln">include</span><span class="pun">:</span><span class="pln"> </span><span class="pun">../</span><span class="pln">common</span><span class="pun">.</span><span class="pln">yaml<br>version</span><span class="pun">:</span><span class="pln"> </span><span class="lit">1.2</span><span class="pun">-</span><span class="pln">alpha3<br>source</span><span class="pun">:</span><span class="pln"><br></span><span class="pun">-</span><span class="pln"> src</span><span class="pun">/</span><span class="pln">main</span><span class="pun">|**</span><span class="com">/*.java|!**Test.java<br>- src/tools|**/</span><span class="pun">*.</span><span class="pln">java<br>resources</span><span class="pun">:</span><span class="pln"><br></span><span class="pun">-</span><span class="pln"> resources</span><span class="pun">/</span><span class="pln">main</span><span class="pun">|!**/</span><span class="pln">test</span><span class="com">/**<br>- resources/images|*.png|*.jpg<br>classpath:<br>- lib|**/</span><span class="pun">*.</span><span class="pln">jar<br></span><span class="pun">-</span><span class="pln"> some</span><span class="pun">/</span><span class="kwd">class</span><span class="pun">/</span><span class="pln">dir</span><span class="pun">|**</span><span class="com">/*.class<br>dist: dist<br>dependencies:<br>- ../common-tools<br>- ../supporting-lib/special.yaml<br>- /some/absolute/project/path<br>main: com.example.SomeClass<br>target: build<br>---<br>classpath build/tools.jar;<br>import java.io.File;<br>DEBUG();<br>compile(project);<br>jar(project);<br>dist(project);<br>keystore("keystore", "alias", "password", "Company", "Title");<br>jws(project, true, "keystore", "alias", "password");<br>jwsHtaccess(project);<br>jnlp(project, "http://example.com/run.jnlp", "Company", "Title", "splash.png");</span></pre>
 </td>
 </tr>
</tbody></table>
<script type="text/javascript" src="Scar_files/plusone.js"></script>
<script src="Scar_files/prettify_core_compiled.js"></script>
<script type="text/javascript">
 prettyPrint();
</script>




 <script type="text/javascript" src="Scar_files/ph_core.js"></script>




 <script type="text/javascript" src="Scar_files/codesite_product_dictionary_ph.js"></script>
</div>
<div id="footer" dir="ltr">
 <div class="text">
 ©2011 Google -
 <a href="http://code.google.com/projecthosting/terms.html">Terms</a> -
 <a href="http://www.google.com/privacy.html">Privacy</a> -
 <a href="http://code.google.com/p/support/">Project Hosting Help</a>
 </div>
</div>
 <div class="hostedBy" style="margin-top: -20px;">
 <span style="vertical-align: top;">Powered by <a href="http://code.google.com/projecthosting/">Google Project Hosting</a></span>
 </div>








<div style="position: absolute; top: 19px; left: 897px; display: none;" id="menuDiv-projects-dropdown" class="menuDiv instance0"><div class="menuCategory controls first"><a href="http://www.google.com/accounts/ServiceLogin?service=code&amp;ltmpl=phosting&amp;continue=http%3A%2F%2Fcode.google.com%2Fp%2Fscar%2F&amp;amp;followup=http%3A%2F%2Fcode.google.com%2Fp%2Fscar%2F" style="display: block;" class="menuItem">Sign in to see your favorites</a><hr class="menuSeparator"><a href="http://code.google.com/more/" style="display: block;" class="menuItem">Find developer products...</a><a href="http://code.google.com/hosting/" style="display: block;" class="menuItem">Find open source projects...</a></div></div></body></html>

Commits for litesoft/trunk/Documents/ScarVersioningCaching/02.html

Diff revisions: vs.
Revision Author Commited Message
417 Diff Diff GeorgeS picture GeorgeS Thu 18 Aug, 2011 20:03:16 +0000
414 GeorgeS picture GeorgeS Thu 18 Aug, 2011 05:03:45 +0000