aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/docs/src/develop/contributing/commands.md
blob: abfea70410128b8b6615bd7d9b11824352c58df2 (plain) (blame)
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
---
SPDX-FileCopyrightText: 2024 The Refinery Authors
SPDX-License-Identifier: EPL-2.0
sidebar_position: 1
title: Build commands
---

# Building from the command line

## Gradle commands

We use [Gradle](https://gradle.org/) to manage the compilation and tests of Refinery.

Java code is built directly by Gradle.
We use the [frontend-gradle-plugin](https://siouan.github.io/frontend-gradle-plugin/) to manage a [Node.js](https://nodejs.org/en) and [Yarn](https://yarnpkg.com/) installation, which in turn is used to build TypeScript code (including this documentation website).
Typically, Yarn commands are issued by Gradle and you don't need to work with the TypeScript build system directly if you're only working on the Java parts of Refinery.

### `build`

```bash posix2windows
./gradlew build
```

Compile all code, run all tests, and produce all build artifacts.

You should run this command before submitting a [Pull request](https://github.com/graphs4value/refinery/pulls) to make sure that all code builds and tests pass on your local machine.
This will also be run by GitHub Actions for each commit or pull requests.

### `publishToMavenLocal`


```bash posix2windows
./gradlew publishToMavenLocal
```

Publishes the Refinery Java artifacts to the [Maven local repository](https://www.baeldung.com/maven-local-repository).

Build tools, such as Gradle, will be able to consume such artifacts, which enables you to use the latest version of Refinery -- possibly including your own modification -- in other Java projects.

For example, in Gradle, you may set

```kotlin title="build.gradle.kts"
repositories {
  mavenLocal()
}

dependencies {
  implementation("tools.refinery:refinery-generator:0.0.0-SNAPSHOT")
}
```

to add a dependency on Refinery to your Java project.

### `serve`

```bash posix2windows
./gradlew serve
```

Starts the Refinery backend and web interface on port 1312.

This task is ideal for running the Refinery backend if you don't intend to work on the frontend.
The Refinery frontend TypeScript projects is automatically built before the server starts.
The server will use the latest build output of the frontend as static assets.

The behavior of this task is influenced by the same [environmental variables](/learn/docker#environmental-variables) as the Refinery [Docker container](/learn/docker).
However, the default value of `REFINERY_LISTEN_PORT` is `1312`.

### `serveBackend`

```bash posix2windows
./gradlew serveBackend
```

Starts the Refinery backend on port 1312.

This task is ideal for running the Refinery backend if you're working on the frontend.
No static assets will be build.
You'll need to use [`yarnw frontend dev`](#frontend-dev)

Like [`gradlew serve`](#serve), the behavior of this task is influenced by the same [environmental variables](/learn/docker#environmental-variables) as the Refinery [Docker container](/learn/docker).
However, the default value of `REFINERY_LISTEN_PORT` is `1312`.

## Yarn commands

We provide a `yarnw` wrapper script to invoke the Yarn distribution installed by frontend-gradle-plugin directly.
The following commands can only be run once [`gradlew build`](#build) has installed the necessary Node.js and Yarn packages.

### `docs dev`

```bash posix2windows
./yarn docs dev
```

Builds and serves this documentation in development mode on port 3000.
Saved changes to most documentation sources are immediately reflected in the browse without reloading.

You can set the port with the `-p` option, e.g. to use port 1313, use

```bash posix2windows
./yarn docs dev -p 1313
```

:::note

Running this command for the first time may generate error messages like
```
ERROR  failed to read input source map: failed to parse inline source map url
```
which can be safely ignored.

:::

### `frontend dev`

```bash posix2windows
./yarn frontend dev
```

Builds and serves the refinery frontend on port 1313.
Saved changes to most source files are immediately reflected in the browser without reload.

Before running this command, you need to start [`gradlew serveBackend`](#servebackend) to provide a backend for the frontend to connect to.
The development server of the frontend will proxy all WebSocket connections to the backend.

The following environmental variables influence the behavior of this command:

#### `REFINERY_LISTEN_HOST`

Hostname to listen at for incoming HTTP connections.

**Default value:** `localhost`

#### `REFINERY_LISTEN_PORT`

TCP port to listen at for incoming HTTP connections.

**Default value:** `1313`

#### `REFINERY_BACKEND_HOST`

Hostname of the Refinery backend.

This should match the `REFINERY_LISTEN_HOST` passed to [`gradlew serveBackend`](#servebackend).

**Default value:** `127.0.0.1` (connect to `localhost` over IPv4 only)

#### `REFINERY_LISTEN_PORT`

TCP port of the Refinery backend.

This should match the `REFINERY_LISTEN_PORT` passed to [`gradlew serveBackend`](#servebackend).

**Default value:** `1312`

#### `REFINERY_PUBLIC_HOST`

Publicly visible hostname of the Refinery instance.

If you use a reverse proxy in front of the development server, you must set this variable.
Otherwise, connections to the development server will fail due to cross-origin protection.

**Default value:** equal to `REFINERY_LISTEN_HOST`

#### `REFINERY_PUBLIC_PORT`

Publicly visible port of the Refinery instance.

If you use a reverse proxy in front of the development server, you must set this variable.
Otherwise, connections to the development server will fail due to cross-origin protection.

**Default value:** equal to `REFINERY_LISTEN_PORT`