{"id":32115342,"url":"https://github.com/ebpro/maven-archetypes","last_synced_at":"2026-05-17T02:35:36.896Z","repository":{"id":167628363,"uuid":"643250495","full_name":"ebpro/maven-archetypes","owner":"ebpro","description":"Best practices Maven archetype","archived":false,"fork":false,"pushed_at":"2024-08-26T20:47:29.000Z","size":866,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2025-10-20T15:54:15.589Z","etag":null,"topics":["archetype","java","maven"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ebpro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-05-20T15:12:14.000Z","updated_at":"2024-08-26T20:47:33.000Z","dependencies_parsed_at":"2024-08-16T11:31:27.036Z","dependency_job_id":"0a7b72e6-8f64-4c9a-8cb5-1a64b24313a6","html_url":"https://github.com/ebpro/maven-archetypes","commit_stats":null,"previous_names":["ebpro/maven-archetypes"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/ebpro/maven-archetypes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebpro%2Fmaven-archetypes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebpro%2Fmaven-archetypes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebpro%2Fmaven-archetypes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebpro%2Fmaven-archetypes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ebpro","download_url":"https://codeload.github.com/ebpro/maven-archetypes/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebpro%2Fmaven-archetypes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280118752,"owners_count":26275307,"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","status":"online","status_checked_at":"2025-10-20T02:00:06.978Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["archetype","java","maven"],"created_at":"2025-10-20T15:54:29.633Z","updated_at":"2025-10-20T15:54:30.439Z","avatar_url":"https://github.com/ebpro.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Best practices Maven archetypes\n\nThis project maintains some Maven archetypes.\n\n* `fr.ebruno.maven.archetypes:simple` a simple standalone Java project.\n* `fr.ebruno.maven.archetypes:simple-withparent`a CI ready one with a complete parent POM.\n\n## fr.ebruno.maven.archetypes:simple\n\nAn archetype to generate a simple standalone maven project.\n\n### Usage\n\nTo generate from the archetype :\n\n```bash\nmvn archetype:generate \\\n    -DarchetypeGroupId=fr.ebruno.maven.archetypes \\\n    -DarchetypeArtifactId=maven-archetype-simple\n```\n\nparameters can be passed directly :\n\n```bash\nmvn archetype:generate \\\n    -DarchetypeGroupId=fr.ebruno.maven.archetypes \\\n    -DarchetypeArtifactId=maven-archetype-simple \\\n    -DgroupId=demo.pkg \\\n    -DartifactId=MyApp \\\n    -Dversion=0.1.0-SNAPSHOT\n```\n\nThe result can be compiled with maven\n\n```console\ncd MyApp\nmvn verify\n```\n\nand executed with maven :\n\n```console\nmvn exec:java -Dexec.mainClass=\"demo.pkg.App\"\n```\n\nor with java (beware no dependencies in the slim jar)\n\n```console\ncd MyAppHelloWorld\njava -cp target/MyAppHelloWorld-1.0-SNAPSHOT.jar demo.pkg.App\n```\n\n### Web site\n\na web site can be generated in `target/site/index.html` with :\n\n```console\nmvn site\n```\n\n## fr.ebruno.maven.archetypes:simple-withparent\n\n```bash\nmvn  archetype:generate \\\n    -DarchetypeGroupId=fr.ebruno.maven.archetypes \\\n    -DarchetypeArtifactId=maven-archetype-withparent \\\n    -DgroupId=demo.pkg \\\n    -DartifactId=MyApp \\\n    -Dversion=0.1.0-SNAPSHOT\n```\n\nA parent pom is defined.\nBy default the jar is \"runnable\" (see `app.main.class` in `pom.xml`)\n\n```bash\ncd Myapp\nmvn verify\njava -jar target/MyApp-0.1.0-SNAPSHOT.jar\n```\n\n## A full git+maven+docker example\n\n\u003e **WARNING**: STILL WORK IN PROGESS\n\nThis project generates a complete Java+Maven project ready for Continuous Integration (CI).\nIt is ready for GitFlow, SonarQube (tests, code coverage, ...).\nIt can produce signed artifacts, fat jars, slim runtime with jLink, native executables with GraalVM\nand container images. The build itself can also be done in a container.\n\n### Configuration (Once)\n\nThe configuration is done with environment variables.\nFor GitHub : GITHUBORG (GitHub account or organisation), GITHUBACTOR, GITHUBTOKEN, GITHUBORG (org or account)\nand optionally for SonarQube SONAR_URL and SONAR_TOKEN (Needs an instance of [SonarQube](https://github.com/ebpro/sonarqube))\n\nFor GitHub the [CLI](https://cli.github.com/) is needed.\n\nThose variables have to be stored on the CI server (see [GitHub Encrypted secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets)).\nThe script below transforms the local variables in GitHub secrets.\n\n```bash\nbash -c 'for secret in GITHUBACTOR GITHUBTOKEN SONAR_URL SONAR_TOKEN; do \\\neval gh secret set $secret --app actions  \\\n                           --body ${!secret} \\\n                           --org ${GITHUBORG} \\\n                           --visibility all; \\\ndone'\n```\n\n## Each new project\n\n\u003e **NOTE**: Short version, a wrapper script is provided (READ IT BEFORE USE).\n\n```bash\nsource \u003c(curl -s https://raw.githubusercontent.com/ebpro/demomavenarchetype/develop/src/main/resources/archetype-resources/ci-wrappers.sh)\nnew-java-project \u003cprojectName\u003e \u003cgroupId\u003e\n```\n\n### Creation\n\nGenerate each new project with this maven archetype (adapt at least the bold parameters).\n\n```bash\nmvn --batch-mode archetype:generate \\\n    -DarchetypeGroupId=fr.ebruno.maven.archetypes \\\n    -DarchetypeArtifactId=maven-archetype-withparent \\\n    -DgithubAccount=\u003cb\u003e$GITHUBORG\u003c/b\u003e \\\n    -DgroupId=\u003cb\u003edemo.pkg\u003c/b\u003e \\\n    -DartifactId=\u003cb\u003eMyApp\u003c/b\u003e \\\n    -Dversion=0.1.0-SNAPSHOT\n```\n\nTo enable deployment in the repo during the CI a deployment key is needed for each repository.\n\n```bash\ntmpKeydir=$(mktemp --directory /tmp/ci-wrappers.XXXXXX)\nssh-keygen -q -t ed25519 -C \"An autogenerated deploy key\" -N \"\" -f ${tmpKeydir}/key\ngh repo deploy-key add --allow-write \"${tmpKeydir}/key.pub\"\ngh secret set SECRET_DEPLOY_KEY \u003c \"${tmpKeydir}/key\"\nrm -rf tmpKeydir\n```\n\n### GitFlow\n\n1. Initialize git environment for GitFlow (develop and master branches).\n2. Make a first commit.\n3. Create the GitHub repository with the [GitHub Command line Interface](https://cli.github.com/).\n4. Create an orphan gh-pages branch for the website.\n5. Open the repository in a web browser.\n\n```bash\ngit flow init -d \u0026\u0026 touch README.md \u0026\u0026 git add . \u0026\u0026 git commit -m \"sets initial release.\" \u0026\u0026\\\n  gh repo create ${GITHUBORG}/${PWD##*/} --disable-wiki --private  --source=. --push \u0026\u0026\\\n    git checkout --orphan gh-pages \u0026\u0026 \\\n      git rm -rf . \u0026\u0026 touch index.html \u0026\u0026  \\\n      git add index.html \u0026\u0026 \\\n      git commit -m \"sets initial empty site.\" \u0026\u0026 \\\n      git push --all \\\n    \u0026\u0026 git checkout develop \u0026\u0026\\\n  gh repo view --web\n```\n\nThe project uses the [gitflow-maven-plugin](https://aleksandr-m.github.io/gitflow-maven-plugin) to manage GitFlow for java+Maven projet (branches and artifact version).\n\nIt is possible to easily start and finish a feature (see version in pom.xml).\n\n```bash\nmvn -B gitflow:feature-start  -DpushRemote=true -DfeatureName=UI\nmvn -B gitflow:feature-start  -DpushRemote=true -DfeatureName=DB\n\nmvn -B gitflow:feature-finish  -DpushRemote=true -DfeatureName=DB\nmvn -B gitflow:feature-finish  -DpushRemote=true -DfeatureName=UI \n```\n\n```bash\nmvn -B gitflow:release-start -DpushRemote=true -DallowSnapshots=true -DuseSnapshotInRelease=true\nmvn -B gitflow:release-finish -DpushRemote=true -DallowSnapshots=true\n```\n\n## Artefact packaging\n\n### Compilation and execution\n\nYou can compile and package with unit tests.\n\n```bash\nmvn package\n```\n\nYou can compile and package with unit tests and integration tests.\n\n```bash\nmvn verify\n```\n\nYou can execute with maven (see app.mainClass property in pom.xml).\n\n```bash\nmvn exec:java\n```\n\n### Shaded Jar (close to FatJar or UberJar)\n\nThe profile `shadedjar` generates a fat jar with all the classes from the transitive dependencies.\n\n```bash\nmvn -Pshadedjar clean verify\nls -lh target/*.jar\n```\n\n```console\n-rw-r--r--@ 1 bruno  wheel   3.1K May 20 16:09 target/MyApp-0.1.0-UI-SNAPSHOT-sources.jar\n-rw-r--r--@ 1 bruno  wheel   2.6K May 20 16:09 target/MyApp-0.1.0-UI-SNAPSHOT-test-sources.jar\n-rw-r--r--@ 1 bruno  wheel    38K May 20 16:09 target/MyApp-0.1.0-UI-SNAPSHOT-withdependencies.jar\n-rw-r--r--@ 1 bruno  wheel   4.2K May 20 16:09 target/MyApp-0.1.0-UI-SNAPSHOT.jar\n```\n\nThe application can then be executed without maven :\n\n```bash\njava -jar target/*-withdependencies.jar\n```\n\n### Jlink\n\nThanks to Jlink and a modular java project (jigsaw), it is possible to generate a minimal JRE with needed modules and dependencies.\n\n```bash\nmvn -Pjlink clean verify\ndu -hs target/image\n```\n\n```console\n 44M    target/image\n ```\n\nThe application can then be launched without a JRE installed.\n\n```bash\n./target/image/bin/myapp\n```\n\n```console\nDec 02, 2022 11:18:56 PM fr.univtln.bruno.demos.App main\nINFOS: Hello World! []\n```\n\n### GraalVM\n\nIt is also possible to generate a native binary with [GraalVM](https://www.graalvm.org/). An installation of GraalVM is needed and the package build-essential libz-dev and zlib1g-dev (zlib-devel, zlib-static et glibc-static). Only tested in linux.\n\n```bash\nsdk install java 22.3.r19-grl\nsdk use java 22.3.r19-grl\n```\n\n```bash\nmvn -Pnative clean verify\nls -lh target/testci\n```\n\n```console\n-rwxr-xr-x 1 bruno users 13M  3 déc.  00:12 target/testci\n```\n\n```console\n./target/testci\ndéc. 03, 2022 12:15:25 AM fr.univtln.bruno.demos.App main\nINFO: Hello World! []\n```\n\n### Building with Maven in docker\n\nIt is possible to build and run the project with just docker installed. A wrapper to run maven and java\nin a container but to work with the current directory is proposed. ~/.m2, ~/.ssh, ~/.gitconfig and the src directories are mounted.\nThe environment variables needed for the project are also transmitted. The UID and GID are the one of the current user.\n\n```bash\ndocker-mvn clean -P shadedjar package\ndocker run --rm \\\n  --mount type=bind,source=\"$(PWD)\"/target/,target=/app,readonly \\\n  eclipse-temurin:17-jre-alpine \\\n    sh -c \"java -jar /app/*-withdependencies.jar\"\n```\n\n### Docker Multistage build\n\nThe file `docker\\Dockerfile` is a multistage Dockerfile to build and deliver the application with several strategies (shaded jar, jlink, GraalVM) on several distributions (debian and alpine). To ease the use a wrapper for docker commands is provided in dockerw.sh\n\n```bash\n. ./ci-wrappers.sh\ndocker-wrapper-build\ndocker-wrapper-run\n```\n\nIt is also possible to build all final target (Warning graalvm takes a long time to compile).\n\n```bash\ndocker-wrapper-build-all\n```\n\nthe result show the images and their size.\n\n```bash\nebpro/testci   develop-finalShadedjarDebian   af3e072b35f7   2 hours ago   266MB\nebpro/testci   develop-finalShadedjarAlpine   38973a2aa588   2 hours ago   170MB\nebpro/testci   develop-finaljLinkDebian       db847ca5b281   2 hours ago   133MB\nebpro/testci   develop-finalJLinkAlpine       0cba42a81a33   2 hours ago   58.2MB\nebpro/testci   develop-finalGraalvmDebian     f5607a1e055f   2 hours ago   93.7MB\nebpro/testci   develop-finalGraalvmAlpine     d9c0573e4750   2 hours ago   18.8MB\n```\n\nIt is also possible to run all the images :\n\n```bash\ndocker-wrapper-run-all\n```\n\n```log\nINFO: Hello World! []\n  0,06s user 0,04s system 6% cpu 1,529 total\nRunning ebpro/testci:develop-finalShadedjarAlpine\nDec 05, 2022 4:37:06 PM fr.univtln.bruno.demos.App main\nINFO: Hello World! []\n  0,05s user 0,05s system 5% cpu 1,724 total\nRunning ebpro/testci:develop-finaljLinkDebian\nDec 05, 2022 4:37:07 PM fr.univtln.bruno.demos.App main\nINFO: Hello World! []\n  0,05s user 0,05s system 5% cpu 1,690 total\nRunning ebpro/testci:develop-finalJLinkAlpine\nDec 05, 2022 4:37:09 PM fr.univtln.bruno.demos.App main\nINFO: Hello World! []\n  0,04s user 0,05s system 5% cpu 1,723 total\nRunning ebpro/testci:develop-finalGraalvmDebian\nDec 05, 2022 4:37:10 PM fr.univtln.bruno.demos.App main\nINFO: Hello World! []\n  0,05s user 0,03s system 7% cpu 1,161 total\nRunning ebpro/testci:develop-finalGraalvmAlpine\nDec 05, 2022 4:37:12 PM fr.univtln.bruno.demos.App main\nINFO: Hello World! []\n```\n\n### Quality\n\nIf a sonarqube server is available (i.e with https://github.com/ebpro/sonarqube).\nSet the variable SONAR_URL and SONAR_TOKEN\n\n```bash\nmvn -P jacoco,sonar \\\n  -Dsonar.branch.name=$(git rev-parse --abbrev-ref HEAD | tr / _) \\\n  verify sonar:sonar \n```\n\n### TODO: FIX LOST CODE COVERAGE\n\n```bash\nmvn clean verify\nmvn -DskipTests=true \\\n    -Dsonar.branch.name=$(git rev-parse --abbrev-ref HEAD | tr / _) \\\n    -P jacoco,sonar \\\n    sonar:sonar\n```\n\n### Web site\n\n```bash\nmvn site:site\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febpro%2Fmaven-archetypes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Febpro%2Fmaven-archetypes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febpro%2Fmaven-archetypes/lists"}