Generating PlantUML Class Diagrams from a Java Project

As technical documentation for my Java software projects often makes use of technologies like AsciiDoctor and PlantUML, having a tool to analyze existing structures and generating class diagrams from it, is a nice thing. Luckily, the Maven plugin from the Living Documentation Project does all the work for me here. Setup We just need to add the following Maven plugin to our project’s pom.xml: <plugin> <groupId>ch.ifocusit.livingdoc</groupId> <artifactId>livingdoc-maven-plugin</artifactId> <version>1.2</version> <executions> <execution> <id>class-diagram</id> <phase>package</phase> <goals> <goal>diagram</goal> <goal>glossary</goal> </goals> </execution> </executions> <configuration> <packageRoot>com.hascode</packageRoot> <interactive>true</interactive> </configuration> </plugin> ...

January 7, 2022 · 1 min · 117 words · Micha Kops

Logback and Spring Boot - Change Log Level to custom format

Create a custom converter This class converts the well known log levels to a custom format CustomLogLevelConverter.java package com.hascode; public class CustomLogLevelConverter extends ClassicConverter { @Override public String convert(ILoggingEvent event) { switch (event.getLevel().toInt()) { case Level.ERROR_INT: return "ERROR!!!"; case Level.WARN_INT: return "WARN!!"; case Level.INFO_INT: return "INFO!"; case Level.TRACE_INT: return "DEBUG"; default: return event.getLevel().toString(); } } } Register the converter The following Logback config includes some defaults and registers our custom converter. ...

August 19, 2021 · 1 min · 166 words · Micha Kops

Factory Reset for Google Pixel-C Android Tablet

Steps Reboot the system by pressing "Power" and "Volume down" simultaneously Boot menu should appear, use "Volume up/down" to select the menu item "Android Recovery", "Power" to confirm System reboots, a screen appears with a message "No command" - this is no error though it looks like one Press "Power" and "Volume up" together and a menu "Android Recovery" appears Use "Volume up/down" to select the menu item "Wipe data/factory reset", "Power" to confirm User data on the device is deleted and the original meu is shown Select the menu item "Reboot system now" and confirm by pressing the "Power" Button The device reboots and you may configure the Android system …​ ...

June 13, 2021 · 1 min · 112 words · Micha Kops

Writing a React Component Test with Jest and Testing Library

Goals render a React component in a test mock HTTP/REST calls to the backend verify results achieve the above using typescript, jest and testing-library Application under Test This is our application’s shortened package.json, generated by create-react-app, adding dependencies for …​ jest testing-library typescript react dom implementations (jest-dom/react-dom) axios (for the HTTP/REST call) package.json { [..] "dependencies": { "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", "@types/jest": "^26.0.15", "@types/node": "^12.0.0", "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-scripts": "4.0.3", "typescript": "^4.1.2", "web-vitals": "^1.0.1", "axios": "^0.19.0" }, [..] "eslintConfig": { "extends": [ "react-app", "react-app/jest" ] }, [..] } ...

June 4, 2021 · 3 min · 553 words · Micha Kops

Configure HP Printer for Linux

Goals Installation We just need to install hplibs thats all .. sudo apt install hplip hplip-gui xsane hp-setup (1) hp-plugin Fastest way is to enter the printer’s IP address, for network scans it might be necessary to disable/modify the firewall. Resources HP Linux Imaging and Printing Detailed article from Linuxmint forums

May 14, 2021 · 1 min · 51 words · Micha Kops

GitHub Pipeline / Actions for Java Releases

Goals Set up Maven build pipeline for a Java 11 app Release Maven artifact on GitHub using GitHub actions Setup Maven Assuming that we have a project named sample-app released for my hascode GitHub account: We’re adding some release information to our project’s pom.xml: pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.hascode</groupId> <artifactId>sample-app</artifactId> <version>1.0.0-SNAPSHOT</version>bookmark-manager <name>sample-app</name> <description>hasCode.com Bookmark Manager</description> <scm> <developerConnection>scm:git:https://github.com/hascode/sample-app.git </developerConnection> </scm> <distributionManagement> <repository> <id>github</id> <name>GitHub</name> <url>https://maven.pkg.github.com/hascode/sample-app</url> </repository> </distributionManagement> <properties> <java.version>11</java.version> <project.scm.id>github</project.scm.id> </properties> [..] </project> ...

May 14, 2021 · 2 min · 393 words · Micha Kops

Install Docker on Linux

Goals Installing a specific Docker version on (Debian-based) Linux Freeze the version to avoid automatic updates Installation curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - (1) sudo add-apt-repository \ (2) "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" sudo apt-get update (3) sudo apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu (4) sudo apt-mark hold docker-ce (5) Add the Docker GPG key Add the Docker repository Update the index Install docker Freeze the version to avoid unwanted automatic updates ...

May 14, 2021 · 1 min · 81 words · Micha Kops

Install Kubernetes Components - Kubeadm, Kubectl, Kubelet

Goals Install kubeadm, kubectl and kubelet on Debian-based Linux Freeze their versions to avoid automatic updates Installation curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - (1) cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list (2) deb https://apt.kubernetes.io/ kubernetes-xenial main EOF sudo apt-get update (3) sudo apt-get install -y kubelet=1.15.7-00 kubeadm=1.15.7-00 kubectl=1.15.7-00 (4) sudo apt-mark hold kubelet kubeadm kubectl (5) Add the GPG key Add the kubernetes repo to the sources list Update the index Install kubelet, kubeadm and kubectl Warning...

May 14, 2021 · 1 min · 113 words · Micha Kops

JUnit5 Java Maven Snippet

Goals Use JUnit Maven BOM for version alignment Add minimal dependencies for JUnit5 Java Projekt Setup Excerpt from the Maven project’s pom.xml: <dependencyManagement> <dependencies> <dependency> <groupId>org.junit</groupId> <artifactId>junit-bom</artifactId> <version>5.7.1</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <scope>test</scope> </dependency> </dependencies> Tip JUnit5 does not work with older versions of the Maven Compiler Plugin and the Surefire Plugin used for test execution. Setting their versions in the pom.xml is done like this: ...

May 14, 2021 · 1 min · 86 words · Micha Kops

MySQL and phpMyAdmin Setup with Docker-Compose

Goals Setup mySQL with phpMyAdmin connected using docker-compose Prerequisites docker-compose installed Setup This is our docker-compose.yml: version: '3.2' services: db: image: mysql:8.0 container_name: mysql-container restart: always ports: - '6603:3306' environment: MYSQL_ROOT_PASSWORD: 12345678 app: depends_on: - db image: phpmyadmin/phpmyadmin container_name: phpmyadmin restart: always ports: - '8080:80' environment: PMA_HOST: db Running docker-compose up Starting mysql-container ... done Starting phpmyadmin ... done Attaching to mysql-container, phpmyadmin [..] Tip We may no login using the following ultra-secure credentials ;) User: root, Password: 12345678 ...

May 14, 2021 · 1 min · 79 words · Micha Kops