Just a place for me to store handy bits and pieces. Having not used it for awhile to remind of things, I’ll likely to forget !
How to compile to different versions of Java ( see also https://mkyong.com/maven/maven-error-invalid-target-release-1-11/ )
<plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>11</source> <target>11</target> </configuration> </plugin>
In the <build> section
How to change the output/target dir
Handy if you want to drop a war straight into tomcat deploy directory for example.
In the <build> section
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.0</version> <configuration> <outputDirectory>/Users/someuser/mydockerdir/java_tomcat/built_war_files/</outputDirectory> </configuration> </plugin>
Change the name of war file thats outputedĀ
In the <build> section
<finalName>SpanishGames</finalName>
An full example that does the 3 things above (in a web app using JavaEE not Spring):
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>greenbox.spanish</groupId> <artifactId>SpanishGames</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>SpanishGames Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> </dependencies> <build> <finalName>SpanishGames</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>11</source> <target>11</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.0</version> <configuration> <outputDirectory>/Users/bob/docker/java_tomcat/built_war_files/</outputDirectory> </configuration> </plugin> </plugins> </build> </project>