1
6
Fork
You've already forked new-java-project
0
This is a Maven Archetype for creating new Maven based Java projects with a set of opinionated plugins and a fully configured source formatter.
2026年04月06日 10:24:07 +02:00
.mvn refactor: Avoid failing on invalid JVM flags until the Maven enforcer plugin can scream about an unsupported Java version. 2025年11月20日 14:24:02 +01:00
src Update dependencies in archetype. 2026年04月06日 10:24:07 +02:00
.gitattributes Create new-java-project project. 2025年10月02日 18:09:30 +02:00
.gitignore Create new-java-project project. 2025年10月02日 18:09:30 +02:00
LICENSE.txt Create new-java-project project. 2025年10月02日 18:09:30 +02:00
pom.xml Update dependencies. 2026年03月15日 20:29:07 +01:00
README.md Update readme. 2026年01月06日 13:25:51 +01:00

new-java-project

This is a Maven Archetype for creating new Maven based Java projects. While I am quite aware of various generators, such as start.spring.io or code.quarkus.io that many people, including me, use regularly, either via the websites or through an IDE integration, there's also a need for "plain" Java projects: Stuff without dependencies, just to get you started in a Maven project.

Intention

I have been asked several times what I do like in my Maven projects and in the past 5 years, a couple of things stood out:

  • I want build files in all projects that I can easily navigate, that are ordered identically and especially, make dependency resolution deterministic through a defined order (read through Andres' pop-quiz or that post at baeldung.com why this is important)
  • I want some things enforced, such as convergence of dependencies and defined plugin versions
  • I want my source code identically formatted and I find that of the many approaches the spring-javaformat works best for me. It's not dependent on Spring at all and while being based on the Eclipse formatter, it comes with great defaults and lets you use standard Checkstyle rules to adapt validation to your needs
  • I want to have defined license checks (going with the Apache License 2.0 here, as with all my private projects)
  • I want to make sure that I can build the project on the latest Java targeting an older release (hence, I want a pom that is able to require Java version X to be run targeting Java version Y)
  • I want an easy way to update all dependencies and I use mvn versions:update-properties for that

The artifact does include a CONTRIBUTING.md that explains how each of the plugins is configured and how they are used. Additionally, the generated project offers a profile named fast that is activated through the property of the same name, which skips all checks and just builds your code.

Further opinions

I don't want to generate any package structure or even Java files for you, not even a module-info.java, despite me being a fan of Javas module system. The generator does provide the standard Maven directories, that's it. I also refrained from adding the Maven wrapper, which can easily be added by through mvn wrapper:wrapper in various forms.

For convenience and because I usually copy and paste those as well, I included .gitignore and .gitattributes.

If you don't like the intentions or my opinions, don't use that generator and don't complain. I essentially wrote it for me after creating one-to-many skeleton-project by hand.

Configuration options

  • javaBuildVersion: The Java version required to run the build (defaults to 25)
  • javaReleaseVersion: The Java version the binaries target (defaults to 17)
  • projectName: A name from the project (defaults to the value of $artifactId)

The archetype has not been tested with Java prior to 17.

Usage

mvn archetype:generate \
 -DarchetypeGroupId=eu.michael-simons.maven.archetypes \
 -DarchetypeArtifactId=new-java-project \
 -DarchetypeVersion=1.0.3 \
 -DgroupId=org.test \
 -DartifactId=example \
 -DprojectName=My\ Example\ Project \
 -DjavaReleaseVersion=17 \
 -DinteractiveMode=false 

The generator will prompt you to confirm all options if you omit -DinteractiveMode=false.

Acknowledgement

Cheers to Gunnar and his oss-quickstart archetype for inspiration. Same idea, slightly different opinions, hence I created my own.