forked from dotCMS/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
293 lines (235 loc) · 11 KB
/
justfile
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
set positional-arguments := true
home_dir := env_var('HOME')
# Introduction and Setup
# If homebrew is not installed, run the following command:
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)";
# If git is not installed run:
# brew install git
# clone this repository with
# git clone https://github.com/dotcms/core.git
# cd core
# just a tool for running commands defined in this file and provides useful aliases for common tasks
# you can also just use the commands listed below directly in your terminal
# To install "just", use "brew install just". Optionally, install the IntelliJ Plugin from https://plugins.jetbrains.com/plugin/18658-just. A cheatsheet is available at https://cheatography.com/linux-china/cheat-sheets/justfile/.
# You can then check the remaining dependencies with "just install-all-mac-deps"
# For all tests to run you need a license key. You can drop the license.dat file into ~/.dotcms/license/license.dat
# Test everything builds and reset your environment with "just build"
###########################################################
# Core Commands
###########################################################
# Lists all available commands in this justfile
default:
@just --list --unsorted --justfile {{ justfile() }}
# Builds the project without running tests, useful for quick iterations
build:
./mvnw -DskipTests clean install
# Builds the project without running tests, skip using docker or creating image
build-no-docker:
./mvnw -DskipTests clean install -Ddocker.skip
# Builds the project and runs the default test suite
build-test:
./mvnw clean install
# Performs a quick build, installing all modules to the local repository without running tests
build-quick:
./mvnw -DskipTests install
# Builds the project for production, skipping tests
build-prod:
./mvnw -DskipTests clean install -Pprod
# Runs a comprehensive test suite including core integration and postman tests, suitable for final validation
build-test-full:
./mvnw clean install -Dcoreit.test.skip=false -Dpostman.test.skip=false
# Builds a specified module without its dependencies, defaulting to the core server (dotcms-core)
build-select-module module="dotcms-core":
./mvnw install -pl :{{ module }} -DskipTests=true
# Builds a specified module along with its required dependencies
build-select-module-deps module=":dotcms-core":
./mvnw install -pl {{ module }} --am -DskipTests=true
# Development Commands
# Starts the dotCMS application in a Docker container on a dynamic port, running in the foreground
dev-run:
./mvnw -pl :dotcms-core -Pdocker-start,debug-suspend
# Maps paths in the docker container to local paths, useful for development
dev-run-map-dev-paths:
./mvnw -pl :dotcms-core -Pdocker-start -Pmap-dev-paths
# Starts the dotCMS application in debug mode with suspension, useful for troubleshooting
dev-run-debug-suspend port="8082":
./mvnw -pl :dotcms-core -Pdocker-start,debug-suspend -Dtomcat.port={{ port }}
# Starts the dotCMS Docker container in the background, running on random port
dev-start:
./mvnw -pl :dotcms-core -Pdocker-start
# Starts the dotCMS Docker container in the background
dev-start-on-port port="8082":
./mvnw -pl :dotcms-core -Pdocker-start -Dtomcat.port={{ port }}
# Stops the development Docker container
dev-stop:
./mvnw -pl :dotcms-core -Pdocker-stop
# Cleans up Docker volumes associated with the development environment
dev-clean-volumes:
./mvnw -pl :dotcms-core -Pdocker-clean-volumes
# Starts the dotCMS application in a Tomcat container on port 8080, running in the foreground
dev-tomcat-run port="8087":
./mvnw -pl :dotcms-core -Ptomcat-run -Pdebug -Dservlet.port={{ port }}
dev-tomcat-stop:
./mvnw -pl :dotcms-core -Ptomcat-stop -Dcontext.name=local-tomcat
# Testing Commands
# Executes a specified set of Postman tests
test-postman collections='page':
./mvnw -pl :dotcms-postman verify -Dpostman.test.skip=false -Pdebug -Dpostman.collections={{ collections }}
# Stops Postman-related Docker containers
postman-stop:
./mvnw -pl :dotcms-postman -Pdocker-stop -Dpostman.test.skip=false
# Runs all integration tests
test-integration:
./mvnw -pl :dotcms-integration verify -Dcoreit.test.skip=false
# Suspends execution for debugging integration tests
test-integration-debug-suspend:
./mvnw -pl :dotcms-integration verify -Dcoreit.test.skip=false -Pdebug-suspend
# Just rebuild core and its deps without docker, e.g. pickup changes for it tests
build-core-with-deps:
./mvnw install -pl :dotcms-core --am -DskipTests -Ddocker.skip=true
# Just rebuild core without docker, e.g. pickup changes for it tests
build-core-only:
./mvnw install -pl :dotcms-core -DskipTests -Ddocker.skip=true
# Prepares the environment for running integration tests in an IDE
test-integration-ide:
./mvnw -pl :dotcms-integration pre-integration-test -Dcoreit.test.skip=false
# Stops integration test services
test-integration-stop:
./mvnw -pl :dotcms-integration -Pdocker-stop -Dcoreit.test.skip=false
# Executes Java E2E tests
test-e2e-java:
./mvnw -pl :dotcms-e2e-java verify -De2e.test.skip=false
# Suspends execution for debugging Java E2E tests
test-e2e-java-debug-suspend:
./mvnw -pl :dotcms-e2e-java verify -De2e.test.skip=false -Pdebug-suspend-e2e-tests
# Executes Node E2E tests
test-e2e-node:
./mvnw -pl :dotcms-e2e-node verify -De2e.test.skip=false
# Stops E2E test services
test-e2e-stop:
./mvnw -pl :dotcms-e2e-java,:dotcms-e2e-node -Pdocker-stop -De2e.test.skip=false
# Docker Commands
# Runs a published dotCMS Docker image on a dynamic port
docker-ext-run tag='latest':
./mvnw -pl :dotcms-core -Pdocker-start -Dcontext.name=ext-{{ tag }} -Ddotcms.image.name=dotcms/dotcms:{{ tag }}
# Runs a Docker image from a specific build for testing
docker-test-ext-run tag='main':
./mvnw -pl :dotcms-core -Pdocker-start -Dcontext.name=test-ext-{{ tag }} -Ddotcms.image.name=ghcr.io/dotcms/dotcms_test:{{ tag }}
# Stops a running Docker container based on the specified tag
docker-ext-stop tag='latest':
./mvnw -pl :dotcms-core -Pdocker-stop -Dcontext.name=ext-{{ tag }}
# Generate a cli uber-jar
cli-build-uber-jar:
./mvnw -pl :dotcms-cli package -DskipTests=true
cli-build-native: check-native-deps
#!/usr/bin/env bash
set -eo pipefail # Exit on error
source ${HOME}/.sdkman/bin/sdkman-init.sh # Load SDKMAN normally in you .bashrc or .zshrc
# The above is not required when running from your shell if you have SDKMAN in your .bashrc or .zshrc
sdk env install # ensure right version of java is downloaded and used for the branch
sdk install java 21.0.2-graalce # Does nothing if already installed
export GRAALVM_HOME=$(sdk home java 21.0.2-graalce) # Could be added to your .bashrc or .zshrc
./mvnw -pl :dotcms-cli -DskipTests -Pnative package
cli-build-test-native: check-native-deps
#!/usr/bin/env bash
set -eo pipefail
source ${HOME}/.sdkman/bin/sdkman-init.sh
# The above is not required when running from your shell if you have SDKMAN in your .bashrc or .zshrc
sdk env install # ensure right version of java is downloaded and used for the branch
sdk install java 21.0.2-graalce # Does nothing if already installed
export GRAALVM_HOME=$(sdk home java 21.0.2-graalce) # Env var Could be added to your .bashrc or .zshrc
./mvnw -pl :dotcms-cli -Pnative verify
run-built-cli *ARGS:
java -jar tools/dotcms-cli/cli/target/dotcms-cli-1.0.0-SNAPSHOT-runner.jar {{ARGS}}
run-java-cli-native *ARGS:
tools/dotcms-cli/cli/target/dotcms-cli-1.0.0-SNAPSHOT-runner {{ARGS}}
###########################################################
# Useful Maven Helper Commands
###########################################################
# Generates a dependency tree for the compile scope and saves it to a file
maven-dependencies:
./mvnw dependency:tree -Dscope=compile > dependencies.txt
# Displays updates for project dependencies in a text file
maven-updates:
./mvnw versions:display-dependency-updates > updates.txt
# Checks for updates to project dependencies and prints to console
maven-check-updates:
./mvnw versions:display-dependency-updates
# Checks for updates to Maven plugins used in the project
maven-check-plugin-updates:
./mvnw versions:display-plugin-updates
# Checks for updates to properties defined in the pom.xml that control dependency versions
maven-property-updates:
./mvnw versions:display-property-updates
# Check if xcode is installed if on a mac. Only required for native builds
check-native-deps:
#!/usr/bin/env bash
set -eo pipefail
# Determine the operating system
OS=$(uname)
# Install dependencies based on the package manager
if [ "$OS" = "Linux" ]; then
if command -v apt-get >/dev/null; then
sudo apt-get update
sudo apt-get install -y build-essential libz-dev zlib1g-dev
elif command -v dnf >/dev/null; then
sudo dnf install -y gcc glibc-devel zlib-devel libstdc++-static
else
echo "Unsupported package manager. Please install the required packages manually. See https://quarkus.io/guides/building-native-image"
exit 1
fi
elif [ "$OS" = "Darwin" ]; then
if ! command -v xcode-select >/dev/null; then
echo "Xcode is not installed. Installing Xcode...";
xcode-select --install;
else
echo "Xcode is already installed.";
fi
else
echo "Unsupported operating system. Please install the required packages manually."
exit 1
fi
###########################################################
# Dependency Commands
###########################################################
# Installs all dependencies for the current project
install-all-mac-deps: install-jdk-mac check-docker-mac check-git-mac
# Installs SDKMAN for managing Java JDK versions
install-sdkman-mac:
@if [ -d "${HOME}/.sdkman/bin" ]; then \
echo "SDKMAN is already installed."; \
else \
echo "SDKMAN is not installed, installing now..."; \
curl -s "https://get.sdkman.io" | bash; \
source "${HOME}/.sdkman/bin/sdkman-init.sh"; \
fi
# Installs the latest version of Java JDK using SDKMAN
install-jdk-mac: install-sdkman-mac
#!/usr/bin/env bash
set -eo pipefail
source ~/.sdkman/bin/sdkman-init.sh
sdk env install java
# Checks if Docker is installed and running
check-docker-mac:
@if ! command -v docker >/dev/null; then \
echo "Docker is not installed."; \
echo "Install docker with : brew install docker --cask"; \
echo " or download from : https://docs.docker.com/get-docker/"; \
exit 1; \
else \
echo "Docker is installed."; \
if ! docker info >/dev/null 2>&1; then \
echo "Docker is not running ..."; \
exit 1; \
else \
echo "Docker is running."; \
fi; \
fi
check-git-mac:
@if ! command -v git >/dev/null; then \
echo "Git is not installed. Installing Git..."; \
brew install git; \
else \
git --version; \
echo "Git is already installed."; \
fi