-
Notifications
You must be signed in to change notification settings - Fork 292
Getting started Development ‐ Linux
Technology | Version | Description |
---|---|---|
Java | 11 | Base programic language |
Gradle | 7.6.3 | Tool for building the application |
Tomcat | 9.0.75 | Servlet server for application |
MySQL Server | 8.0.33 | Database server for data persistence |
MySQL Client | DBeaver 23.1.2 or newer |
Database client |
Node.js | 22.9.0 | JavaScript runtime for New UI |
Git | 2.17.1 | Version control for source code |
Linux | Ubuntu-based | Operating system |
1. Scada-LTS ↑↑↑
1.1 Installation ↑↑↑
To install Scada-LTS go to the linux-installer website and follow the instructions in the README.
In the development environment it is important to set the default parameters for the database:
- Database port: 3306;
- Database user: root;
- Database password: root;
- Database root password: root;
1.2 Configuration ↑↑↑
Environment variables ↑↑↑
-
You will have to add PATH for Java and Catalina in
~/.bashrc
file using any available text editor e.g.:nano ~/.bashrc
or
vim ~/.bashrc
-
On the bottom of this text file add two lines from below:
export CATALINA_HOME="/absolute_path_to_installer/linux-installer/tomcat64/server"
export JAVA_HOME="/absolute_path_to_installer/linux-installer/java/jdk"
-
After all that type in terminal:
source ~/.bashrc
This will reload Enviroment variables.
jSerialComm - Configuration ↑↑↑
More information about jSerialComm: https://fazecast.github.io/jSerialComm/
However, on linux system configuration is necessary as long as we are not running on root:
sudo usermod -a -G uucp username
sudo usermod -a -G dialout username
sudo usermod -a -G lock username
sudo usermod -a -G tty username
2. Database ↑↑↑
2.1 MySQL Client ↑↑↑
Installation ↑↑↑
Download Linux DBeaver Installer, run it and wait for it to finish. To launch it type dbeaver
in console.
Configuration ↑↑↑
NOTE: Before configurating DBeaver make sure that your MySQL Server is turned on.
- In top left corner of DBeaver window click on icon to add "New database connection".
- Select MySQL and press 'Next' button.
- Set port 3306 password root and click on 'Finish'. If the drivers have not been installed before, the program will suggest downloading and installing, click ok:
- If you have set password for root, you have to enable allowPublicKeyRetrieval in Connection Settings window in Driver properties tab.
- Press Test connection button on the bottom left corner of the window. If everything is set up correctly the following window should pop up.
3. IntelliJ ↑↑↑
-
Download desired version of IntelliJ here. If you do not have a license, download the "IntelliJ IDEA Community Edition".
-
Put it in freshly made folder and extract it.
-
Install git with command below:
sudo apt-get install git-all
You can confirm if git setup finished correctly by running
git version
in terminal. -
Go inside extracted folder, then to
bin
folder and run./idea.sh
script. -
After installation is completed, on welcome screen select "Create New Project" and select "Get from VCS".
-
Choose repository URL and use Git Version Control. Paste the URL of the Scada-LTS project from below and click "Clone" button.
https://github.com/SCADA-LTS/Scada-LTS.git
If there is a privilege dialog, click "Trust this project" button to load the gradle configuration.
Gradle will load the dependencies and prepare project for development. (It may take a while)
-
After everything loads, in Project tab, go to gradle > wrapper > gradle-wrapper.properties and change version of your gradle to 7.1.
-
Make sure to change your indent settings to be same as on Github repository, so code will be clean and easy to read. First, locate a indent configuration button in bottom right corner of your IDE.
Tabs and Indents window should pop up, make sure to uncheck "Use tab character", your configuration should look like this:
3.1 Node.js ↑↑↑
- You can check if you have any nvm or node.js installed on your PC using these commands:
nvm --version node --version
- You will need
nvm
which is Node Version Manager. You can install it running this command in terminal:curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
- You can check if nvm has installed correctly by typing:
nvm --verison
- When everything went succesfull we can install chosen version of Node.js with command below:
nvm install v14.20.1
- To make sure that correct version of node is installed type:
node --version
NOTE: If you want to uninstall node or change version of it, you have to use nvm from now on.
3.2 Troubleshoot ↑↑↑
-
In IntelliJ project in top left corner, go to File > Settings.
-
Type Gradle in search bar.
- In the Gradle JVM dropdown list select correct version of JDK and press OK.
e.g.:
-
In IntelliJ, in Project bar right-click on Scada-LTS and select Open Module Settings.
-
In Project Structure window on left side select Project.
- Select correct version of SDK from dropdown list marked on image above and press OK.
4. Docker Compose ↑↑↑
4.1 Installation ↑↑↑
To check if you have any version of docker installed, run command from below in terminal.
dpkg -l | grep -i docker
Installing Docker Compose ↑↑↑
- Start with commands below to update the
apt
package index:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
- Run these commands to add docker’s official GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
- Use command below to set up repository:
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- Install Docker engine and all necessary docker plugins.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Add non-admin user to docker group use command below:
sudo usermod -aG docker user_name
user_name
is the username of user you want to be able to launch docker-compose.
4.2 Launching ↑↑↑
-
Download docker-compose.yml file to desired folder.
-
Go inside docker-compose.yml location using terminal and run:
docker-compose up database
- In second terminal and same location:
docker-compose up scadalts
NOTE: You have to wait for
docker-compose up database
to finish, otherwise errors may appear.
4.3 Uninstall ↑↑↑
To uninstall all files related to docker use these two commands below:
sudo apt-get purge -y `dpkg-query -W -f='${binary:Package}\t' '*docker*'`
sudo apt-get autoremove -y --purge `dpkg-query -W -f='${binary:Package}\t' '*docker*'`
To delete all files that docker created e.g. groups, sockets etc. use commands below:
sudo rm -rf /var/lib/docker /etc/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock
sudo rm /etc/apt/keyrings/docker.gpg
If you deleted everything correctly command below should return nothing.
dpkg -l | grep -i docker
5. Tips for developers ↑↑↑
To build the application on your own environment you can use Gradle. We provide example scripts that can be used inside Scada-LTS project to perform specific operations. Commands with their explanations are listed below.
5.1 Gradle Tasks ↑↑↑
To run Gradle Task you have to use gradle version 7.1 with Java version 11. It should also work on other versions but you have to change the targetVersion in build.gradle file.
Command | Explanation |
---|---|
gradle war |
Build Scada-LTS war file |
gradle run |
Launch Tomcat instance |
gradle runDebug |
Launch Tomcat instance in debug mode, ability to plug debugger into the Tomcat port and use it |
gradle buildRunDebug |
Build and start production version of Scada-LTS application min tasks (recommended) |
gradle buildRunDebugProd |
Build and start production version of Scada-LTS application |
gradle buildRunDebugDev |
Build and start developer version of Scada-LTS application |
gradle buildRunDebugProdTestUi |
Build and start production version of Scada-LTS application with Test UI |
gradle buildRunDebugDevTestUi |
Build and start developer version of Scada-LTS application with Test UI |
gradle test |
Launch Backend Unit Tests |
gradle scadalts-ui::testUi |
Launch Frontend Unit Tests |
Logging JVM parameters ↑↑↑
If you want to see what parameters is your JVM using you can add these three lines of code to build.gradle file:
Process ipProcess = new Runtime().exec("jps -lvm");
int exitValue = ipProcess.waitFor();
println "JAVA__:" + ipProcess.getText()
5.2 IntelliJ plugins ↑↑↑
-
In any IntelliJ project go to: File > Settings > Plugins and select Marketplace.
-
In search bar type Sonarlint an press Install next to it.
-
IntelliJ will ask you to restart it.
-
After restart your plugin is set and ready to go.
6. SeroUtils library license ↑↑↑
Matthew Lohbihler [email protected] has granted us permission to use the SeroUtils.jar library for ScadaLTS team. ScadaLTS team can use the code seroUtils without limitation.
Fragement with the correspondence of Grzegorz Bylica and Matthew Lohbihler:
"(...) The good news is that you may hereby and without limitation use the seroUtils code as you like. (...)"