Skip to content

Commit 29cbe6f

Browse files
committed
#12074 Shell Scripts for common dev use cases
Developer documentation rewritten from Ant to new scripts
1 parent 7ab6649 commit 29cbe6f

13 files changed

+324
-19
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*.coffee text
2525
*.css text
2626
gradlew text eol=lf
27+
.env text eol=lf
28+
.env.example text eol=lf
2729
*.htm text
2830
*.html text
2931
*.inc text

.github/dependabot.yml

-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ updates:
4242
- dependency-name: org.yaml:snakeyaml
4343
# Vaadin 8.14.3 is the last free version - https://vaadin.com/vaadin-8-extended-maintenance-releases
4444
- dependency-name: com.vaadin:vaadin-*
45-
# Newer version breaks sormas-base/build.xml -> collect-serverlibs (remove after #12074)
46-
- dependency-name: commons-io:commons-io
4745

4846
# Maintain gradle dependencies for sormas-app
4947
- package-ecosystem: "gradle"

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/sormas-widgetset/bin
1515
/deploy/bundles
1616
deploy
17-
/sormas-base/build.properties
17+
/sormas-base/dev.env
1818
/sormas-base/bin
1919
/sormas-ui/bin
2020

docs/DEVELOPMENT_ENVIRONMENT.md

+12-16
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ Note: To work with the Android app JDK 17 is needed for the gradle build. The ne
1919

2020
The SORMAS CI is using JDK 17 to build all modules. The only known difference though are slight differences in the Java time API that affect unit tests, so again there is no need to setup two JDKs on your local system.
2121

22-
## Step 3: Install Maven & Ant
23-
Download and install Maven for your operating system, see [binaries](https://dlcdn.apache.org/maven/maven-3/3.6.3/binaries/)
24-
*IMPORTANT*: M2_HOME environment variable needs to be set. By default, for newer version, it is set to MAVEN_HOME. But Ant script is looking for M2_HOME, please refer to the [official documentation](https://maven.apache.org/install.html)
25-
26-
Download and install Ant, it can be done from [Ant site](https://ant.apache.org/bindownload.cgi) or with packages from your Linux distribution.
22+
## Step 3: Install Maven
23+
The scripts in `sormas-base/dev` expect `mvn` as command-line tool.
24+
Download and install Maven for your operating system, see [binaries](https://dlcdn.apache.org/maven/maven-3/3.6.3/binaries/).
2725

2826
## Step 4: Install a Local SORMAS Server
2927
Please follow the [Server Installation Instructions](../docs/SERVER_SETUP.md#sormas-installation) to set up a local SORMAS instance that you will use to test your code. Alternatively, you can also use [Maven Cargo](../sormas-cargoserver/README.md), or a [Docker installation](SERVER_DOCKER_SETUP.md) (not recommended at this time).
@@ -36,8 +34,8 @@ Please follow the [Server Installation Instructions](../docs/SERVER_SETUP.md#sor
3634
- *Optional:* Clone the SORMAS-Project repository if you haven't done so already
3735
- Open the project in IntelliJ. Make sure the project is recognized by IntelliJ as a `maven project`; if not, right-click the `pom.xml` file in `sormas-base` and select `Add as maven project`.
3836
- Make sure that under `File -> Project Structure -> Modules` all modules EXCEPT sormas-app are recognized; if not, add the missing modules with the `+` button
39-
- Navigate to `File -> Settings -> Plugins` and make sure that Glassfish & Ant integrations are enabled
40-
- Make a copy of `sormas-base/build.properties.example`, rename it to `build.properties` and set `glassfish.domain.root` to the location of the SORMAS domain inside your Payara installation
37+
- Navigate to `File -> Settings -> Plugins` and make sure that Glassfish integration is enabled
38+
- Make a copy of `sormas-base/dev.env.example`, rename it to `dev.env` and set `GLASSFISH_DOMAIN_ROOT` to the location of the SORMAS domain inside your Payara installation
4139
- Run `mvn install` on the `sormas-base` project (e.g. by opening the Maven view and executing `sormas-base -> Lifecycle -> install`)
4240
- Add a Payara server to IntelliJ:
4341
- Open `Run -> Edit Configurations`, add a new configuration and choose the Glassfish server template
@@ -50,8 +48,7 @@ Please follow the [Server Installation Instructions](../docs/SERVER_SETUP.md#sor
5048
- Open the `Logs` tab and add a new log file pointing to the `logs/server.log` file in your SORMAS domain
5149
- Open the `Startup/Connection` tab and make sure that `Pass environment variables` is NOT checked; ignore warnings about the debug configuration not being correct
5250
- Open the `config/domain.xml` file in your domain directory and make sure that the `java-config` node contains the following code: `<java-config classpath-suffix="" debug-enabled="true" debug-options="-agentlib:jdwp=transport=dt_socket,address=6009,server=n,suspend=y" ...`
53-
- Open the Ant window, click on the `+` icon and select the `sormas-base/build.xml` file
54-
- Execute the `install` and `deploy-serverlibs` Ant scripts
51+
- Execute the `dev/build.sh` and `dev/deploy-serverlibs.sh` scripts
5552
- Set the default working directory for run configurations by navigating to `Run -> Edit Configurations -> Templates -> Application` and setting `Working directory` to `$MODULE_WORKING_DIR$`
5653
- *Optional:* Setup database access from Intellij: Open View -> Tool View -> Database, click on + icon and select DataSource -> PostgreSQL and configure the database (set user and password and download the missing driver files if needed)
5754

@@ -66,10 +63,9 @@ Please follow the [Server Installation Instructions](../docs/SERVER_SETUP.md#sor
6663
- Install the [Payara Tools plugin](https://marketplace.eclipse.org/content/payara-tools)
6764
- Install the [Vaadin Plugin for Eclipse](https://marketplace.eclipse.org/content/vaadin-plugin-eclipse); the commercial UI designer is not needed
6865
- Add a Payara server to Eclipse and enter the credentials you specified when setting up the local SORMAS server
69-
- Make a copy of `sormas-base/build.properties.example`, rename it to `build.properties` and set `glassfish.domain.root` to the location of the SORMAS domain inside your Payara installation
70-
- Drag the `sormas-base/build.xml` file into the Ant view in Eclipse
71-
- Either run `mvn install` on the `sormas-base` project or execute the `install [default]` Ant script (this needs a Maven installation on your system with the M2_HOME variable set)
72-
- Execute the `deploy-serverlibs` Ant script
66+
- Make a copy of `sormas-base/dev.env.example`, rename it to `dev.env` and set `GLASSFISH_DOMAIN_ROOT` to the location of the SORMAS domain inside your Payara installation
67+
- Either run `mvn install` on the `sormas-base` project or execute the `dev/build.sh` script (for example with Git Bash)
68+
- Execute `dev/deploy-serverlibs.sh` script
7369
- Highlight all Eclipse projects and choose `Maven -> Update Project` from the right-click menu; perform the update for all projects
7470
- Start the Glassfish server and deploy `sormas-ear`, `sormas-rest` and `sormas-ui` by dragging the respective projects onto it, or use the `Add and Remove...` function by right-clicking on the server (make sure to respect this order as there are depdendencies between artifacts at startup)
7571
- Open your browser and type in `http://localhost:6080/sormas-ui` to test whether the server and IDE have been set up correctly
@@ -87,7 +83,7 @@ Please follow the [Server Installation Instructions](../docs/SERVER_SETUP.md#sor
8783
- Add an emulator and set the SDK version to the `minSdkVersion` or `targetSdkVersion` from `build.gradle`; we suggest to test your code on both, but `minSdkVersion` should be preferred to ensure compatibility to the minimum supported SDK
8884
- Click on `Run 'app'` to install and run the app on your emulator; enter `http://10.0.2.2:6080/sormas-rest` as the server URL when you start the newly installed app for the first time
8985

90-
**Important:** Whenever you do or pull changes in the `sormas-api` project that you want to use in the mobile app or that are referenced there already, you need to execute the `install` Ant script to notify the `sormas-app` project of the changes.
86+
**Important:** Whenever you do or pull changes in the `sormas-api` project that you want to use in the mobile app or that are referenced there already, you need to execute the `dev/build.sh` script to notify the `sormas-app` project of the changes.
9187

9288
## Step 6: Configure Code Formatting and Import Settings
9389
In order to ensure a consistent code style and prevent so-called edit wars, we have set up custom configuration files for automatic code formatting and import ordering. Please make sure to adhere to the following steps for your IDE(s) before you start developing.
@@ -132,12 +128,12 @@ Optional, but strongly recommended:
132128
-> For every installation, kill all Java/javaw processes and check the availability of 6048 port number.
133129
-> Delete files with generated domain folders and payara. In order to have a clean installation of each next ./server-setup.sh run.
134130

135-
6. M2_HOME need to be set. By default, for newer version, it is set to MAVEN_HOME. But Ant script is looking for M2_HOME
131+
6. For the `sormas-base/dev` scripts Maven needs to be installed as command-line tool or defined in `sormas-base/dev.env` as `MVN_BIN` which Maven to be used.
136132

137133
7. For eclipse formatted plugin, there is an issue for Idea: <https://plugins.jetbrains.com/plugin/6546-eclipse-code-formatter> - `cannot save settings Path to custom eclipse folder is not valid` - it works only when settings were saved from down to up. And not vice versa.
138134

139135
If something is still not working:
140-
-> Stop the payara domain, run Ant deploy-serverlibs to update libs
136+
-> Stop the payara domain, run `dev/deploy-serverlibs.sh` to update libs
141137
-> clean up (delete all from domains/sormas/autodeploy, domains/sormas/applications, domains/sormas/generated, and domains/sormas/osgi-cache) try to build again by executing `mvn clean install -DskipTests` on the `sormas-base` module
142138
-> start the domain and deploy again
143139

sormas-base/dev.env.example

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#*******************************************************************************
2+
# SORMAS® - Surveillance Outbreak Response Management & Analysis System
3+
# Copyright © 2016-2023 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
4+
#
5+
# This program is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
#*******************************************************************************
18+
19+
### Settings for developer scripts in dev/ directory ###
20+
21+
# 0. Examples
22+
23+
#MVN_BIN="C:\\Program Files\\apache-maven-3.6.3\\bin\\mvn"
24+
#JAVA_HOME="C:\\Program Files\\Java\\zulu17.42.19-ca-jdk17.0.7"
25+
26+
#BUILD_SKIP_TESTS=false
27+
#MVN_OPTIONS=--debug --errors
28+
29+
#GLASSFISH_DOMAIN_ROOT=/opt/domains/sormas
30+
#GLASSFISH_DOMAIN_ROOT="/C/srv/payara-domains/sormas"
31+
32+
# 1. Your settings
33+
34+
GLASSFISH_DOMAIN_ROOT=?

sormas-base/dev/apply-settings.sh

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
#*******************************************************************************
4+
# SORMAS® - Surveillance Outbreak Response Management & Analysis System
5+
# Copyright © 2016-2023 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
#*******************************************************************************
20+
21+
### Apply settings for script, enable configuration via dev.env by developer ###
22+
23+
# Don't read settings multiple times when scripts are combined
24+
if [[ "$DEV_SETTINGS_APPLIED" != "true" ]]; then
25+
26+
# 0. Default settings
27+
MVN_BIN=mvn
28+
BUILD_SKIP_TESTS=true
29+
COLLECT_ROOT_PATH=../../deploy
30+
COLLECT_APPS_PATH=$COLLECT_ROOT_PATH/apps
31+
32+
# 1. Read user settings
33+
source ../dev.env
34+
35+
# 2. Apply other derived settings
36+
DEPLOY_SERVERLIBS_PATH=$GLASSFISH_DOMAIN_ROOT/lib
37+
38+
# 3. Print used toolchain
39+
echo "Java: $JAVA_HOME"
40+
echo "Maven: $MVN_BIN"
41+
42+
# 4. Avoid repeated read of settings
43+
DEV_SETTINGS_APPLIED=true
44+
fi

sormas-base/dev/build-with-app.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
#*******************************************************************************
4+
# SORMAS® - Surveillance Outbreak Response Management & Analysis System
5+
# Copyright © 2016-2023 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
#*******************************************************************************
20+
21+
### Compile and package all artifacts of SORMAS server stack ###
22+
### mvn -Pwith-app clean install ###
23+
24+
# 0. Initialize settings
25+
source apply-settings.sh
26+
PROFILES=-Pwith-app
27+
28+
# 1. Command chain
29+
source build.sh

sormas-base/dev/build.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
#*******************************************************************************
4+
# SORMAS® - Surveillance Outbreak Response Management & Analysis System
5+
# Copyright © 2016-2023 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
#*******************************************************************************
20+
21+
### Compile and package all artifacts of SORMAS server stack ###
22+
### mvn clean install ###
23+
24+
# 0. Initialize settings
25+
source apply-settings.sh
26+
27+
# 1. Command chain
28+
$MVN_BIN -f ../pom.xml -Dmaven.test.skip=$BUILD_SKIP_TESTS $MVN_OPTIONS $PROFILES clean install

sormas-base/dev/collect-all.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
#*******************************************************************************
4+
# SORMAS® - Surveillance Outbreak Response Management & Analysis System
5+
# Copyright © 2016-2023 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
#*******************************************************************************
20+
21+
### Collects all serverlibs, bundles and so on for the setup-script ###
22+
23+
24+
# 0. Initialize settings
25+
source apply-settings.sh
26+
27+
# 1. Command chain
28+
29+
echo "Collecting config und scripts"
30+
source collect-setup.sh
31+
32+
echo "Collecting serverlibs"
33+
source collect-serverlibs.sh
34+
35+
echo "Collecting SORMAS artifacts"
36+
source collect-artifacts.sh

sormas-base/dev/collect-artifacts.sh

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
#*******************************************************************************
4+
# SORMAS® - Surveillance Outbreak Response Management & Analysis System
5+
# Copyright © 2016-2023 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
#*******************************************************************************
20+
21+
### Collects artifacts to be deployed as apps in the Payara domain ###
22+
23+
24+
# 0. Initialize settings
25+
source apply-settings.sh
26+
27+
# 1. Command chain
28+
mkdir -p $COLLECT_ROOT_PATH
29+
30+
mkdir -p $COLLECT_APPS_PATH
31+
cp ../../sormas-ear/target/sormas-ear.ear $COLLECT_APPS_PATH/
32+
cp ../../sormas-ui/target/sormas-ui.war $COLLECT_APPS_PATH/
33+
cp ../../sormas-rest/target/sormas-rest.war $COLLECT_APPS_PATH/
34+
35+
mkdir -p $COLLECT_ROOT_PATH/openapi
36+
cp ../../sormas-rest/target/swagger.json $COLLECT_ROOT_PATH/openapi/sormas-rest.json
37+
cp ../../sormas-rest/target/swagger.yaml $COLLECT_ROOT_PATH/openapi/sormas-rest.yaml
38+
39+
mkdir -p $COLLECT_ROOT_PATH/keycloak
40+
cp ../../sormas-keycloak-service-provider/target/*.jar $COLLECT_ROOT_PATH/keycloak/
41+
cp -R ../../sormas-keycloak-service-provider/target/dependency $COLLECT_ROOT_PATH/keycloak/
42+
43+
mkdir -p $COLLECT_ROOT_PATH/android
44+
cp -R ../../sormas-app/app/build/outputs/apk/* $COLLECT_ROOT_PATH/android

sormas-base/dev/collect-serverlibs.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
#*******************************************************************************
4+
# SORMAS® - Surveillance Outbreak Response Management & Analysis System
5+
# Copyright © 2016-2023 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
#*******************************************************************************
20+
21+
### Collect serverlibs to be later copied into the Payara domain ###
22+
23+
24+
# 0. Initialize settings
25+
source apply-settings.sh
26+
# Decoupled from COLLECT_ROOT_PATH because Maven runs in another directory
27+
COLLECT_SERVERLIBS_PATH=../deploy/serverlibs
28+
29+
# 1. Command chain
30+
rm ../$COLLECT_SERVERLIBS_PATH/*.jar
31+
$MVN_BIN -f ../../sormas-serverlibs/pom.xml -DincludeScope=compile -DoutputDirectory=$COLLECT_SERVERLIBS_PATH $MVN_OPTIONS dependency:copy-dependencies

0 commit comments

Comments
 (0)