The project object model pom.xml
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.hdm_stuttgart.mi</groupId>
<artifactId>first</artifactId>
<version>0.9</version>
</project>
mkdir -p src/main/java ❶ vim src/main/java/Hello.java ❷ first> mvn compile ... [WARNING] File encoding has not been set, using platform encoding UTF-8, ❸ i.e. build is platform dependent! ... [ERROR] error: Source option 5 is no longer supported. ❹ Use 6 or later. [ERROR] error: Target option 1.5 is no longer supported. ❺ Use 1.6 or later.
Create an empty folder designated for hosting Java™ sources. See Figure 634, “Maven project layout ” for reference. |
|
Create an executable «Hello,world ...» class:
|
|
Ask Maven for execution of the «compile» phase. |
|
We have not yet specified an encoding on project level. Thus two platforms using different encoding may provide different artifact outcomes. |
|
The world has moved: Java™ 1.5 compilers are outdated. |
Figure 640. Examining the Java™ version
culprit
>mvn help:effective-pom <project ...> ... <plugin> <artifactId>maven-compiler-plugin</artifactId> ... > find ~/.m2/repository/ -name maven-compiler-plugin\* ... >jar -xf ~/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/3.7.0/maven-compiler-plugin-3.7.0.jar >cat META-INF/maven/plugin.xml
<encoding implementation="java.lang.String" default-value="${project.build.sourceEncoding}">${encoding}</encoding>
<source implementation="java.lang.String" default-value="1.5">${maven.compiler.source}</source>
<target implementation="java.lang.String" default-value="1.5">${maven.compiler.target}</target>
Figure 641. Resolving encoding / Java™ version
issues
<project ... xsd/maven-4.0.0.xsd"> ... <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> ...
rm -rf ~/.m2/repository/
mvn compile; find ~/.m2/repository/ -type f|wc -l
220
jar -tf /usr/share/apache-maven-3.0.5/lib/maven-model-builder-3.0.5.jar
...
org/apache/maven/model/plugin/ReportingConverter.class
org/apache/maven/model/pom-4.0.0.xml
org/apache/maven/model/profile/activation/FileProfileActivator$1.class
...
... <!-- Does this ring a (security related?) bell? -->
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
...
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
...
<settings ... settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>central-secure</id>
<mirrorOf>central</mirrorOf>
<name>Maven Central: Favour https over http.</name>
<url>https://repo.maven.apache.org/maven2</url>
</mirror>
</mirrors>
...
first> mvn help:effective-pom
... Effective POMs, after inheritance, interpolation, and profiles are applied:
<project xmlns="http://maven.apache.org/POM/4.0.0" ...>
<modelVersion>4.0.0</modelVersion>
...
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-jar</id>
...