a-t-0 / mastersofjava

Practice Java through mastersofjava challenges.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Java Template

License: AGPL v3 Contains strict PMD linting and pre-commit settings, can be used as a starting template for a Java project.

Usage

Please ensure the prerequisites are satisfied before proceeding. In Java, you can first compile the main code, and then run it with CLI arguments.

clear && ./gradlew build shadowJar && \
java -jar build/libs/template-java-project-all.jar

Or, after building:

java -jar fat.jar

Testing

Put your unit test files (with extension .bats) in folder: /test/

./gradlew test

Then, in browser open: build/reports/tests/test/classes/com.doctestbot.TestCommandLineParser.html and browse to related section.

Run Single Test File

To run 1 test file specifically, for example the /test/java/com/doctestbot/cli/TestLogArg.java test file:

clear && ./gradlew test --tests com.doctestbot.TestSourceDirArg

Note that the /cli drops out.

Prerequisites

(Re)-install the Java with:

sudo apt install openjdk-21-jdk-headless
sudo curl -s "https://get.sdkman.io" | bash
source ~/.sdkman/bin/sdkman-init.sh
sdk --version
sdk install gradle
sdk install java 19.0.2-open

Install:

# Java hooks require docker
sudo apt install docker.io
# Ensure docker can be ran without sudo.
sudo groupadd docker
sudo gpasswd -a $USER docker
newgrp docker

# Install pre-commit
pre-commit install
pre-commit autoupdate

Update gradle.build

Auto update of gradle.build file is not a standard practice. Instead, get the list of latest versions of the things that can be updated:

./gradlew dependencyUpdates

and manually apply the updates.

Pre-commit

Run pre-commit with:

pre-commit run --all

Documentation

To generate the documentation, run:

./gradlew javadoc

That produces the documentation in build/docs/javadoc/index.html,

Code coverage

Still has to be implemented.

About

Practice Java through mastersofjava challenges.

License:GNU Affero General Public License v3.0


Languages

Language:Java 63.3%Language:Shell 36.7%