Blame view

README.md 2.82 KB
5ddde321   Sergey Reymerov   Initial commit.
1
2
3
4
  # JavaPoly
  
  ## Building
  
5ddde321   Sergey Reymerov   Initial commit.
5
  There is a Grunt script for building JavaPoly. So for building you have to install `grunt-cli`. Just type command:
d8f78e07   Sergey Reymerov   Mocha testing for...
6
  ```sh
5ddde321   Sergey Reymerov   Initial commit.
7
8
9
  $ npm install -g grunt-cli
  ```
  
f0b8597f   Harshad RJ   Improve the gramm...
10
  Now install all required packages by typing:
d8f78e07   Sergey Reymerov   Mocha testing for...
11
  ```sh
5ddde321   Sergey Reymerov   Initial commit.
12
13
14
  $ npm install
  ```
  
f0b8597f   Harshad RJ   Improve the gramm...
15
  For building JavaPoly "browser version" the command is:
d8f78e07   Sergey Reymerov   Mocha testing for...
16
  ```sh
af486cec   Rooftrellen   add build:browser...
17
  $ grunt build:browser
5ddde321   Sergey Reymerov   Initial commit.
18
19
  ```
  
f0b8597f   Harshad RJ   Improve the gramm...
20
21
  This creates `build/javapoly.js` file. This file when included in a web-page, will auto-load some js libraries
  (browserjs.js, doppio lib and so on) from external site(eg, www.javapoly.com).
5ddde321   Sergey Reymerov   Initial commit.
22
  
b7557cc8   Анатолий Русских   Update Gruntfile....
23
  You can create complete package (including JavaPoly-Node-Doppio, JavaPoly-Node-SystemJVM) by running command:
035765eb   Harshad RJ   Added building an...
24
  ```sh
b7557cc8   Анатолий Русских   Update Gruntfile....
25
  $ grunt build
035765eb   Harshad RJ   Added building an...
26
27
  ```
  
b7557cc8   Анатолий Русских   Update Gruntfile....
28
  For testing JavaPoly-Node-Doppio or JavaPoly-Node-SystemJVM you can run:
035765eb   Harshad RJ   Added building an...
29
  ```sh
b7557cc8   Анатолий Русских   Update Gruntfile....
30
31
  $ ./node_modules/mocha/bin/mocha test/TestJavaPolyNodeDoppio.js
  or
ce7a7787   Harshad RJ   Build and test in...
32
  $ ./node_modules/mocha/bin/mocha test/TestJavaPolyNodeSystem.js
035765eb   Harshad RJ   Added building an...
33
34
  ```
  
f0b8597f   Harshad RJ   Improve the gramm...
35
  ### Developing JavaPoly
035765eb   Harshad RJ   Added building an...
36
  
f0b8597f   Harshad RJ   Improve the gramm...
37
  When developing JavaPoly, you can compile the code with:
d8f78e07   Sergey Reymerov   Mocha testing for...
38
  ```sh
5ddde321   Sergey Reymerov   Initial commit.
39
40
41
  $ grunt watch
  ```
  
f0b8597f   Harshad RJ   Improve the gramm...
42
  This command starts a watching process that updates the build when you change any js-file in src-folder.
5ddde321   Sergey Reymerov   Initial commit.
43
44
45
  
  ### Testing JavaPoly
  
931ceb16   Harshad RJ   Mention Firefox a...
46
47
  Tests need to be run in atleast the following two browsers: Firefox and Chromium. (different
  browser capabilities affect the number and kind of tests that are run).
5ddde321   Sergey Reymerov   Initial commit.
48
  
931ceb16   Harshad RJ   Mention Firefox a...
49
  There is a folder `test` which should contain a simple build of Doppio and JavaPoly.
5ddde321   Sergey Reymerov   Initial commit.
50
  
931ceb16   Harshad RJ   Mention Firefox a...
51
  Make a build of Doppio and copy / link it into the `test/doppio` folder.
5ddde321   Sergey Reymerov   Initial commit.
52
  
931ceb16   Harshad RJ   Mention Firefox a...
53
54
55
  Note that **watch**ing-process updates JavaPoly build in `test` folder.
  
  You can also rebuild JavaPoly for testing without watching by command:
d8f78e07   Sergey Reymerov   Mocha testing for...
56
  ```sh
5ddde321   Sergey Reymerov   Initial commit.
57
58
59
  $ grunt build:test
  ```
  
f0b8597f   Harshad RJ   Improve the gramm...
60
61
62
  **note, the final javapoly.js file which build:test task generates is a little different from the file which build:browser task generate.
  the javapoly.js which build:test task generates will load the doppio and browserjs library in local folders.
  and the javapoly.js which build:browser(or build) task generates will load the doppio and browserjs library from external web site.** 
af486cec   Rooftrellen   add build:browser...
63
  
d8f78e07   Sergey Reymerov   Mocha testing for...
64
  To test JavaPoly you should run HTTP server for folder `test` and open `index.html` in browser.
5ddde321   Sergey Reymerov   Initial commit.
65
  
f3d363b7   Harshad RJ   Important: Added ...
66
  We use a custom http server for this. To run it:
d8f78e07   Sergey Reymerov   Mocha testing for...
67
  ```sh
931ceb16   Harshad RJ   Mention Firefox a...
68
  $ cd test
f3d363b7   Harshad RJ   Important: Added ...
69
  $ node server.js
5ddde321   Sergey Reymerov   Initial commit.
70
71
  ```
  
931ceb16   Harshad RJ   Mention Firefox a...
72
  After this, open browser and navigate to http://localhost:8080/index.html. The page contains tests written in Mocha environment.
d8f78e07   Sergey Reymerov   Mocha testing for...
73
  
931ceb16   Harshad RJ   Mention Firefox a...
74
  You can also test JavaPoly via Mocha in nodejs. Install it by typing:
d8f78e07   Sergey Reymerov   Mocha testing for...
75
76
77
78
  ```sh
  $ npm install -g mocha
  ```
  
a1e8acf0   Harshad RJ   added ant build i...
79
  And type `mocha` in projects directory.
99f30f21   Rooftrellen   add webworkers su...
80
  
f0b8597f   Harshad RJ   Improve the gramm...
81
82
83
  ### Using JavaPoly Core(including JVM) in WebWorker
  
  To avoid blocking the browser's main thread we can use webworkers if the browser supports it (most current browsers do).
99f30f21   Rooftrellen   add webworkers su...
84
  
f0b8597f   Harshad RJ   Improve the gramm...
85
  This can be enabled by adding a `worker` option in javapoly. 
99f30f21   Rooftrellen   add webworkers su...
86
  
f0b8597f   Harshad RJ   Improve the gramm...
87
  The value should be set to the url that points to the `javapoly_worker.js`. (default value is null which disables webworkers)
99f30f21   Rooftrellen   add webworkers su...
88
89
90
91
92
  
  eg.
  
  ```js
  new JavaPoly(worker : 'build/javapoly_worker.js');
035765eb   Harshad RJ   Added building an...
93
  ```