Skip to content

Commit c69a374

Browse files
authored
Fix make commands and instructions (#208)
1 parent 7544e27 commit c69a374

File tree

4 files changed

+65
-16
lines changed

4 files changed

+65
-16
lines changed

Makefile

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,56 @@
1+
SHELL=/bin/zsh
2+
MVN_AVAILABLE := $(shell command -v mvn 2> /dev/null)
3+
SDK_AVAILABLE := $(shell [[ -s "${HOME}/.sdkman/bin/sdkman-init.sh" ]] && source "${HOME}/.sdkman/bin/sdkman-init.sh" && command -v sdk)
4+
sdk = source "${HOME}/.sdkman/bin/sdkman-init.sh" && sdk
5+
6+
.PHONY: check
7+
check:
8+
ifndef MVN_AVAILABLE
9+
$(error "Maven is not available. Please install it before continuing.")
10+
endif
11+
ifndef SDK_AVAILABLE
12+
$(error "Sdkman is not available. Please install it before continuing.")
13+
endif
14+
@echo "Tools installed and ready"
15+
16+
117
.PHONY: default
218
default: | help
319

420
.PHONY: help
521
help:
622
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
723

8-
.PHONY: build-all
9-
build-all:
10-
mvn -B clean install --settings=.maven.settings.xml --file pom.xml -DskipTests -P nexus
24+
.PHONY: build-klass-forvaltning
25+
build-klass-forvaltning:
26+
pushd klass-forvaltning && \
27+
${sdk} env && \
28+
mvn -B install -P nexus; \
29+
popd; \
30+
${sdk} env clear
31+
32+
.PHONY: build-klass-api
33+
build-klass-api:
34+
pushd klass-api && \
35+
mvn -B install -P nexus; \
36+
popd
1137

1238
.PHONY: run-klass-forvaltning-local
1339
run-klass-forvaltning-local:
14-
pushd klass-forvaltning && mvn spring-boot\:run --settings=../.maven.settings.xml -P nexus && popd
40+
pushd klass-forvaltning && \
41+
mvn spring-boot\:run --settings=../.maven.settings.xml -P nexus; \
42+
popd
1543

1644
.PHONY: run-klass-forvaltning-local-mariadb
1745
# Requires that a MariaDB instance is already running with a database called klass and a user called klass.
1846
# The environment variable KLASS_ENV_MARIADB_PASSWORD must be specified with the password for the klass user.
1947
run-klass-forvaltning-local-mariadb:
2048
pushd klass-forvaltning && \
21-
mvn spring-boot\:run -Dspring.profiles.active=mariadb,embedded-solr,frontend,skip-indexing,small-import,ad-offline -P nexus && \
49+
mvn spring-boot\:run -Dspring.profiles.active=mariadb,embedded-solr,frontend,skip-indexing,small-import,ad-offline -P nexus; \
2250
popd
2351

2452
# The environment variable KLASS_ENV_SECURITY_IGNORED must be set to "/**" in order to skip authentication
2553
run-klass-api-local-mariadb:
2654
pushd klass-api && \
27-
mvn spring-boot\:run -Dspring.profiles.active=mariadb,embedded-solr,mock-mailserver,skip-indexing,small-import,ad-offline -P nexus && \
55+
mvn spring-boot\:run -Dspring.profiles.active=mariadb,embedded-solr,mock-mailserver,skip-indexing,small-import,ad-offline -P nexus; \
2856
popd

README.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Klass consists of 4 maven modules
1515
- Klass Shared (Classes shared between API and Forvaltning. primary database and search components)
1616
- Klass Solr (Solr Core configuration and configuration for embedded solr for test/development)
1717

18-
### Build and Deploy
18+
## Build and Deploy
1919

2020
Building the project will output war files for **Klass API** & **Klass Forvaltning** and a zip file (WiP) for **Klass Solr**.
2121

@@ -27,7 +27,7 @@ klass-forvaltning/target/klass-forvaltning-{Version}.war
2727
klass-solr/klass-solr-{Version}.zip (WiP)
2828
```
2929

30-
#### Server configuration
30+
## Server configuration
3131

3232
Klass was made with Tomcat in mind and configuration on servers are done in `tomcat.conf` (usually found in ~tomcat/conf)
3333
variables in `application properties` will be overridden/replaced with properties found in `tomcat.conf`
@@ -44,7 +44,7 @@ KLASS_ENV_MARIADB_PASSWORD=Password
4444
KLASS_ENV_LOGGING_PATH=/var/log/tomcat
4545
```
4646

47-
### Database
47+
## Database
4848

4949
Klass is configured to use Flyway for database initialising and migration.
5050
You can find the collection of SQL scripts in the Klass-shared module under `src/main/resources/db/migration`
@@ -54,15 +54,30 @@ This process can take quite some time as there is a lot of data and its also sen
5454

5555
Tips: If you are only setting up Klass for testing/development purposes you can use the `small-import` spring profile to reduce the amount of data being imported.
5656

57-
### Development
57+
## Development
5858

59-
its recommended to build with maven before starting development as some classes are generated as part of the build process.
59+
### Requirements
6060

61-
```shell
62-
make build-all
63-
```
61+
- Maven: <https://maven.apache.org/install.html>
62+
- Sdkman: <https://sdkman.io/install>
63+
- Java 17: `sdk install java 17.0.11-zulu`
64+
- Java 8 (for Klass Forvaltning): `sdk install java 8.0.372-zulu`
65+
66+
### Introduction
67+
68+
It's recommended to build with maven before starting development as some classes are generated as part of the build process.
69+
70+
Each app has an `.sdkmanrc` file which may be used to configure the Java version to use. This may be activated by entering the directory and running the `sdk env` command. A `Makefile` is also provided with relevant commands for building each app. See <https://sdkman.io/usage#env-command> for more details
71+
72+
### Klass API
73+
74+
Build the app: `make build-klass-api`
75+
76+
### Klass Forvaltning
77+
78+
Build the app: `make build-klass-forvaltning`
6479

65-
#### Spring profiles
80+
### Spring profiles
6681

6782
Klass API and Klass Forvaltning utilize Spring boot and heavily rely on Spring Profiles to make development and debugging easier.
6883
below is a quick summary of the profiles available (see _application.properties_ for more details)
@@ -84,7 +99,7 @@ below is a quick summary of the profiles available (see _application.properties_
8499
# embedded-solr = run an instance of solr as part of the application (no need to run a separate solr application)
85100
```
86101

87-
#### Build profiles
102+
### Build profiles
88103

89104
we have created custom profiles for time consuming tests that can be toggled on and off to help speed up compile time during development.
90105
The profile named `documentation` will generate API documentation with AsciiDoc (default: enabled)

klass-api/.sdkmanrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Enable auto-env through the sdkman_auto_env config
2+
# Add key=value pairs of SDKs to use below
3+
java=17.0.11-zulu

klass-forvaltning/.sdkmanrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Enable auto-env through the sdkman_auto_env config
2+
# Add key=value pairs of SDKs to use below
3+
java=8.0.372-zulu

0 commit comments

Comments
 (0)