Java and Technology weblog
There is no easy way, or simple archetype, to create a maven multi module project. The approach below is the best way I’ve found so far.
mvn -Dtest=com.your.package.YourTest test
Run from within the folder that contains the src (as in src/test/java) folder, which will likely be either be the root of your maven project, or in one of your modules.
This is covered maven surefire plugin docs but the example always confuses me slightly since it omits the packages names, which are required.
This post shows how to run all the tests in IntelliJ for a multi module maven project.
The maven Quickweb archetype allow you to create a new project with a layout that is essentially a combination of what you get with the standard maven archetypes of quickstart and webapp. The readme on Github contains more details: https://github.com/sabram/maven-archetype-quickweb
If you are interested in the underlying workings, the ‘recipe’ for the archetype is the archetype descriptor, archetype.xml, which is located in the src/main/resources/META-INF/maven/ directory. It specifies what files the generated project will be made up of, in addition to the prototype pom, all of which are located in the archetype-resources folder.
- Apache source code for maven-archetype-quickstart and maven-archetype-webapp
- Apache guide to creating archetypes; Wiki on creating an archetype
- How is metadata about an archetype stored?
- Stackoverflow question on how to create the src/main/resources folder with the quickstart folder. I posted a link to my maven-archetype-quickweb archetype there.
- Stackoverflow question on how to use a custom maven archetype
I recently started trying out the early access version of Java8. When I tried using it with maven in IntelliJ however, I got the following error when I ran the maven install command:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project xyz:
Fatal error compiling: invalid target release: 1.8\
Although I saw some suggestions on stackoverflow here about hardcoded JAVA_HOME paths, the solution was just changing the maven specific version of Java that IntelliJ uses. This can be done via:
File > Settings > Project Settings > Maven > Runner
and selecting the 1.8 version of the JRE.
Maven archetypes are useful for many things, including creating a folder structure to start with, even if you aren’t planning to use maven as your build tool. See a list of available archetypes here.
Following my introductory rant on the subject, this post is a working example of using Swing and Webstart with a multi-module maven project.
I have spent the last few weeks struggling with a Swing app that I wanted to deploy via Webstart and build using Maven, via the the Webstart Maven Plugin. It has been a hugely painful process. I found the plugin documentation difficult to follow, struggled to understand the subtle config differences in jnlp, took longer than I expected to get jar signing working, had problems with webstart caching and suffered through a plethora of vague error messages. I found this posting where the author vowed to never use Webstart again, and I can empathize. Postings of people asking for help with Webstart problems certainly aren’t difficult to find. Using maven to build the jnlp provides some conveniences, but introduces new problems too. Overall, I’d prefer to avoid using a Swing/Webstart/Maven solution again.