| .mvn | refactor: Avoid failing on invalid JVM flags until the Maven enforcer plugin can scream about an unsupported Java version. | |
| src | Update dependencies in archetype. | |
| .gitattributes |
Create new-java-project project.
|
|
| .gitignore |
Create new-java-project project.
|
|
| LICENSE.txt |
Create new-java-project project.
|
|
| pom.xml | Update dependencies. | |
| README.md | Update readme. | |
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-propertiesfor 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 to25)javaReleaseVersion: The Java version the binaries target (defaults to17)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.