{"id":22064520,"url":"https://github.com/josef-friedrich/java-boilerplate","last_synced_at":"2025-03-23T18:13:26.932Z","repository":{"id":208299171,"uuid":"721293375","full_name":"Josef-Friedrich/java-boilerplate","owner":"Josef-Friedrich","description":"Boilerplate code snippets for my java projects","archived":false,"fork":false,"pushed_at":"2024-05-14T12:33:26.000Z","size":1494,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-14T13:45:27.053Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://josef-friedrich.github.io/java-project-boilerplate/","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Josef-Friedrich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-20T18:57:07.000Z","updated_at":"2024-05-14T13:45:27.359Z","dependencies_parsed_at":"2023-11-20T20:27:31.270Z","dependency_job_id":"461e17d5-afe5-4f84-8139-d68f55aaf155","html_url":"https://github.com/Josef-Friedrich/java-boilerplate","commit_stats":null,"previous_names":["josef-friedrich/java-project-boilerplate","josef-friedrich/java-boilerplate"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Josef-Friedrich%2Fjava-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Josef-Friedrich%2Fjava-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Josef-Friedrich%2Fjava-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Josef-Friedrich%2Fjava-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Josef-Friedrich","download_url":"https://codeload.github.com/Josef-Friedrich/java-boilerplate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245144973,"owners_count":20568056,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T19:12:25.268Z","updated_at":"2025-03-23T18:13:26.910Z","avatar_url":"https://github.com/Josef-Friedrich.png","language":"Makefile","readme":"[![Maven Central](https://img.shields.io/maven-central/v/de.pirckheimer-gymnasium/engine-pi.svg?style=flat)](https://central.sonatype.com/artifact/de.pirckheimer-gymnasium/engine-pi)\n[![javadoc](https://javadoc.io/badge2/de.pirckheimer-gymnasium/engine-pi/javadoc.svg)](https://javadoc.io/doc/de.pirckheimer-gymnasium/engine-pi)\n\n# java-project-boilerplate\n\nBoilerplate code snippets for my java projects\n\n## Maven Standard Directory Layout\n\n`src/main/java` Application/Library sources\u003cbr\u003e\n`src/main/resources` Application/Library resources\u003cbr\u003e\n`src/test/java` Test sources\u003cbr\u003e\n`src/test/resources` Test resources\n\n\u003csmall\u003e\n[Source](https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html)\u003c/small\u003e\n\n## pom.xml\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cproject xmlns=\"http://maven.apache.org/POM/4.0.0\"\n    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n    xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\u003e\n  \u003cmodelVersion\u003e4.0.0\u003c/modelVersion\u003e\n\n  \u003cgroupId\u003erocks.friedrich\u003c/groupId\u003e\n  \u003cartifactId\u003eboilerplate\u003c/artifactId\u003e\n  \u003cversion\u003e0.1.0\u003c/version\u003e\n\n  \u003cproperties\u003e\n    \u003cmaven.compiler.source\u003e17\u003c/maven.compiler.source\u003e\n    \u003cmaven.compiler.target\u003e17\u003c/maven.compiler.target\u003e\n    \u003cproject.build.sourceEncoding\u003eUTF-8\u003c/project.build.sourceEncoding\u003e\n  \u003c/properties\u003e\n\u003c/project\u003e\n```\n\n\u003csmall\u003e\n[Source](https://maven.apache.org/guides/introduction/introduction-to-the-pom.html)\u003c/small\u003e\n\n## naming conventions on groupId, artifactId, and version\n\n### groupId\n\nuniquely identifies your project across all projects. A group ID should follow\nJava's package name rules. This means it starts with a reversed domain name you\ncontrol. For example\n\n    org.apache.maven, org.apache.commons, de.pirckheimer-gymnasium\n\n## artifactId\n\nis the **name of the jar** without version. If you created it, then you can\nchoose whatever name you want with **lowercase letters** and no strange symbols.\n\n    eg. maven, commons-math\n\n## version\n\nif you distribute it, then you can choose any typical version with numbers and dots (1.0, 1.1, 1.0.1, ...). For example,\n\n    2.0, 2.0.1, 1.3.1\n\n\u003csmall\u003e[Source](https://maven.apache.org/guides/mini/guide-naming-conventions.html)\u003c/small\u003e\n\n## format\n\n`make format` or `mvn formatter:format`\n\nhttps://github.com/revelc/formatter-maven-plugin\n\n[DefaultCodeFormatterConstants](https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tree/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java)\n\nhttps://code.revelc.net/formatter-maven-plugin/examples.html#custom-configuration-file\n\nIt is best to make or edit the XML formatter files in Eclipse: Window \u003e Preferences \u003e Java \u003e Code Style \u003e Formatter\n\n```xml\n\n\u003cbuild\u003e\n  \u003cplugins\u003e\n    \u003c!-- https://code.revelc.net/formatter-maven-plugin/ --\u003e\n    \u003cplugin\u003e\n      \u003cgroupId\u003enet.revelc.code.formatter\u003c/groupId\u003e\n      \u003cartifactId\u003eformatter-maven-plugin\u003c/artifactId\u003e\n      \u003cversion\u003e2.23.0\u003c/version\u003e\n      \u003cconfiguration\u003e\n        \u003cconfigFile\u003e${project.basedir}/.eclipse-formatter/school.xml\u003c/configFile\u003e\n      \u003c/configuration\u003e\n    \u003c/plugin\u003e\n  \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\n```xml\n\u003cbuild\u003e\n  \u003cplugins\u003e\n    \u003c!--\n    https://code.revelc.net/formatter-maven-plugin/\n    https://code.revelc.net/formatter-maven-plugin/examples.html#basic-configuration-using-external-resource --\u003e\n    \u003cplugin\u003e\n        \u003cgroupId\u003enet.revelc.code.formatter\u003c/groupId\u003e\n        \u003cartifactId\u003eformatter-maven-plugin\u003c/artifactId\u003e\n        \u003cversion\u003e2.24.1\u003c/version\u003e\n        \u003cexecutions\u003e\n            \u003cexecution\u003e\n                \u003cgoals\u003e\n                    \u003cgoal\u003eformat\u003c/goal\u003e\n                \u003c/goals\u003e\n                \u003cconfiguration\u003e\n                    \u003cconfigFile\u003eeclipse-formatter.xml\u003c/configFile\u003e\n                \u003c/configuration\u003e\n            \u003c/execution\u003e\n        \u003c/executions\u003e\n        \u003cdependencies\u003e\n            \u003cdependency\u003e\n                \u003cgroupId\u003ede.pirckheimer-gymnasium\u003c/groupId\u003e\n                \u003cartifactId\u003eengine-pi\u003c/artifactId\u003e\n                \u003cversion\u003e0.28.0\u003c/version\u003e\n            \u003c/dependency\u003e\n        \u003c/dependencies\u003e\n    \u003c/plugin\u003e\n  \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\n`.vscode/settings.json`\n\n```json\n{\n  \"java.format.settings.url\": \".eclipse-formatter/school.xml\",\n  \"editor.tabSize\": 4,\n  \"editor.insertSpaces\": true\n}\n```\n\n## Maven (JAR files) repository inside a project\n\n```xml\nwget -O commons-lang3-sources.jar https://repo1.maven.org/maven2/org/apache/commons/commons-lang3/3.14.0/commons-lang3-3.14.0-sources.jar\nwget -O commons-lang3.jar https://repo1.maven.org/maven2/org/apache/commons/commons-lang3/3.14.0/commons-lang3-3.14.0.jar\n\nmvn install:install-file \\\n    -Dfile=commons-lang3.jar \\\n    -Dsources=commons-lang3-sources.jar \\\n    -DgroupId=org.apache.commons \\\n    -DartifactId=commons-lang3 \\\n    -Dversion=3.14.0 \\\n    -Dpackaging=jar \\\n    -DlocalRepositoryPath=repository \\\n    -DcreateChecksum=true\n```\n\n`pom.xml`\n\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003eproject-repository\u003c/id\u003e\n        \u003curl\u003efile://${project.basedir}/repository\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.apache.commons\u003c/groupId\u003e\n  \u003cartifactId\u003ecommons-lang3\u003c/artifactId\u003e\n  \u003cversion\u003e3.14.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Remove unused imports\n\nNot working?\n\nmvn site\n\n```xml\n\u003creporting\u003e\n    \u003cplugins\u003e\n        \u003cplugin\u003e\n            \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n            \u003cartifactId\u003emaven-pmd-plugin\u003c/artifactId\u003e\n            \u003cversion\u003e3.21.0\u003c/version\u003e\n        \u003c/plugin\u003e\n    \u003c/plugins\u003e\n\u003c/reporting\u003e\n```\n\nmvn com.xenoamess:remove-unused-imports-maven-plugin:0.0.6:process\n\n```xml\n\u003cbuild\u003e\n  \u003cpluginManagement\u003e\n    \u003cplugin\u003e\n        \u003cgroupId\u003ecom.xenoamess\u003c/groupId\u003e\n        \u003cartifactId\u003eremove-unused-imports-maven-plugin\u003c/artifactId\u003e\n        \u003cversion\u003e0.0.6\u003c/version\u003e\n        \u003cexecutions\u003e\n            \u003cexecution\u003e\n                \u003cgoals\u003e\n                    \u003cgoal\u003eprocess\u003c/goal\u003e\n                \u003c/goals\u003e\n                \u003cconfiguration\u003e\n                    \u003cruleNames\u003e\n                        \u003cruleName\u003eUnusedImports\u003c/ruleName\u003e\n                        \u003cruleName\u003eDuplicateImports\u003c/ruleName\u003e\n                        \u003cruleName\u003eUnnecessaryReturn\u003c/ruleName\u003e\n                        \u003cruleName\u003eImportFromSamePackage\u003c/ruleName\u003e\n                        \u003cruleName\u003eDontImportJavaLang\u003c/ruleName\u003e\n                    \u003c/ruleNames\u003e\n                    \u003cpmdXmlPath\u003e${basedir}/target/pmd.xml\u003c/pmdXmlPath\u003e\n                    \u003cbreakBuildIfHaveViolationRemains\u003efalse\u003c/breakBuildIfHaveViolationRemains\u003e\n                \u003c/configuration\u003e\n            \u003c/execution\u003e\n        \u003c/executions\u003e\n    \u003c/plugin\u003e\n  \u003c/pluginManagement\u003e\n\u003c/build\u003e\n```\n\n## Reference JAR lib in VScode\n\n```json\n{\n  \"java.project.referencedLibraries\": [\"+libs/**/*.jar\"]\n}\n```\n\n## Publish to Maven Central\n\nhttps://central.sonatype.org/publish-ea/publish-ea-guide/#introduction\n\nhttps://github.com/simpligility/ossrh-demo\n\n`~/.m2/settings.xml`\n\n```xml\n\u003csettings\u003e\n  \u003cservers\u003e\n    \u003cserver\u003e\n      \u003c!-- https://central.sonatype.com/account --\u003e\n      \u003cid\u003eossrh\u003c/id\u003e\n      \u003cusername\u003exxx\u003c/username\u003e\n      \u003cpassword\u003exxx\u003c/password\u003e\n    \u003c/server\u003e\n  \u003c/servers\u003e\n  \u003cprofiles\u003e\n    \u003cprofile\u003e\n      \u003cid\u003eossrh\u003c/id\u003e\n      \u003cactivation\u003e\n        \u003cactiveByDefault\u003etrue\u003c/activeByDefault\u003e\n      \u003c/activation\u003e\n      \u003cproperties\u003e\n        \u003cgpg.executable\u003egpg2\u003c/gpg.executable\u003e\n        \u003c!-- \u003cgpg.passphrase\u003exxx\u003c/gpg.passphrase\u003e --\u003e\n      \u003c/properties\u003e\n    \u003c/profile\u003e\n  \u003c/profiles\u003e\n\u003c/settings\u003e\n```\n\n`pom.xml`\n\n```xml\n\u003cproject\u003e\n    \u003cbuild\u003e\n        \u003cplugins\u003e\n            \u003c!-- https://maven.apache.org/plugins/maven-gpg-plugin/usage.html --\u003e\n            \u003cplugin\u003e\n                \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n                \u003cartifactId\u003emaven-gpg-plugin\u003c/artifactId\u003e\n                \u003cversion\u003e3.2.4\u003c/version\u003e\n                \u003cexecutions\u003e\n                \u003cexecution\u003e\n                    \u003cid\u003esign-artifacts\u003c/id\u003e\n                    \u003cphase\u003everify\u003c/phase\u003e\n                    \u003cgoals\u003e\n                    \u003cgoal\u003esign\u003c/goal\u003e\n                    \u003c/goals\u003e\n                    \u003cconfiguration\u003e\n                    \u003c!-- This is necessary for gpg to not try to use the pinentry programs --\u003e\n                    \u003cgpgArguments\u003e\n                        \u003carg\u003e--pinentry-mode\u003c/arg\u003e\n                        \u003carg\u003eloopback\u003c/arg\u003e\n                    \u003c/gpgArguments\u003e\n                    \u003c/configuration\u003e\n                \u003c/execution\u003e\n                \u003c/executions\u003e\n            \u003c/plugin\u003e\n            \u003c!-- https://central.sonatype.org/publish/publish-portal-maven/ --\u003e\n            \u003cplugin\u003e\n                \u003cgroupId\u003eorg.sonatype.central\u003c/groupId\u003e\n                \u003cartifactId\u003ecentral-publishing-maven-plugin\u003c/artifactId\u003e\n                \u003cversion\u003e0.5.0\u003c/version\u003e\n                \u003cextensions\u003etrue\u003c/extensions\u003e\n                \u003cconfiguration\u003e\n                    \u003c!-- see ~/.m2/settings.xml --\u003e\n                    \u003cpublishingServerId\u003ecentral\u003c/publishingServerId\u003e\n                    \u003ctokenAuth\u003etrue\u003c/tokenAuth\u003e\n                    \u003cautoPublish\u003etrue\u003c/autoPublish\u003e\n                \u003c/configuration\u003e\n            \u003c/plugin\u003e\n        \u003c/plugins\u003e\n    \u003c/build\u003e\n\u003c/project\u003e\n```\n\n`mvn deploy`\n\n## javadoc\n\nMultiline code snippets\n\nhttps://reflectoring.io/howto-format-code-snippets-in-javadoc/\n\n## versioning\n\n```xml\n\u003cproject\u003e\n    \u003cbuild\u003e\n        \u003cplugins\u003e\n            \u003c!-- https://www.mojohaus.org/versions/versions-maven-plugin/--\u003e\n            \u003cplugin\u003e\n                \u003cgroupId\u003eorg.codehaus.mojo\u003c/groupId\u003e\n                \u003cartifactId\u003eversions-maven-plugin\u003c/artifactId\u003e\n                \u003cversion\u003e2.17.1\u003c/version\u003e\n            \u003c/plugin\u003e\n        \u003c/plugins\u003e\n    \u003c/build\u003e\n\u003c/project\u003e\n```\n\n`mvn versions:set`\n\n`mvn versions:set -DnewVersion=1.0.1-SNAPSHOT`\n\n`mvn versions:commit`\n\n## junit\n\nfrom the [junit5-jupiter-starter-maven project](https://github.com/junit-team/junit5-samples/blob/main/junit5-jupiter-starter-maven/pom.xml):\n\n`pom.xml`\n\n```xml\n\u003cdependencyManagement\u003e\n    \u003cdependencies\u003e\n        \u003cdependency\u003e\n        \u003cgroupId\u003eorg.junit\u003c/groupId\u003e\n        \u003cartifactId\u003ejunit-bom\u003c/artifactId\u003e\n        \u003cversion\u003e5.11.1\u003c/version\u003e\n        \u003ctype\u003epom\u003c/type\u003e\n        \u003cscope\u003eimport\u003c/scope\u003e\n        \u003c/dependency\u003e\n    \u003c/dependencies\u003e\n\u003c/dependencyManagement\u003e\n\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.junit.jupiter\u003c/groupId\u003e\n        \u003cartifactId\u003ejunit-jupiter\u003c/artifactId\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n\n\u003cbuild\u003e\n    \u003cplugins\u003e\n        \u003cplugin\u003e\n        \u003cartifactId\u003emaven-surefire-plugin\u003c/artifactId\u003e\n        \u003cversion\u003e3.5.0\u003c/version\u003e\n        \u003c/plugin\u003e\n    \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\n## Copyright\n\n```\n/*\n * Copyright (c) 2024 Josef Friedrich.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n */\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosef-friedrich%2Fjava-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosef-friedrich%2Fjava-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosef-friedrich%2Fjava-boilerplate/lists"}