UNPKG

1.63 kBMarkdownView Raw
1---
2layout: default
3---
4
5## Tutorial
6
7### help
8
9You can have a quick look at the following commands.
10
11```
121c help
13```
14
15### env
16
17Check everything you need before using 1c to build your project.
18
19```
201c env
21```
22
23### install
24
25Add the NPM and Maven libraries you need to `package.json`.
26
27```bash
28$ cat package.json
29{
30 "dependencies": {
31 "mockxhr": "^1.3.0"
32 },
33 "mvnDependencies": [
34 "org.tinylog:tinylog:1.2"
35 ]
36}
37
38$ 1c install
39npm WARN wizawu.com No repository field.
40npm WARN wizawu.com No license field.
41up to date in 0.4s
42
43BUILD SUCCESSFUL
44
45Total time: 4.019 secs
46Disassembling lib/tinylog-1.2.jar: 83 classes
47Generated lib/@types/tinylog-1.2.d.ts
48```
49
50Now you have installed both NPM and Maven dependencies. We will only use `tinylog` in this tutorial.
51
52`tsconfig.json` will be also generated after running `1c install`. So you can import the directory to IDE (VS Code, WebStorm, etc) now.
53
54### build
55
56Edit `main.ts` as follow.
57
58```typescript
59const JAVA_VERSION = java.lang.System.getProperty("java.version")
60org.pmw.tinylog.Logger.info(`Java version ${JAVA_VERSION}`)
61```
62
63Build the entry.
64
65```bash
66$ 1c build main.ts
67ts-loader: Using typescript@2.3.4 and /home/wizawu/new/tsconfig.json
68Hash: a224cd98aa0291534c77
69Time: 6514ms
70 Asset Size Chunks Chunk Names
71 main.js 703 bytes 0 [emitted] main.js
72main.js.map 839 bytes 0 [emitted] main.js
73```
74
75### run
76
77Now you are ready to run your first program with 1c.
78
79```bash
80$ 1c run main.js
812017-04-27 02:35:57 [main] jdk.nashorn.internal.scripts.Script$Recompilation.L:71()
82INFO: Java version 1.8.0_77-Debian
83```