The pom that is not run here
A Maven build is a description of a build, and the description of this project is nine lines. The build itself does not run in this container: Maven downloads its plugins on the first run, the image has no network, and the offline mode stops with a message that names the missing plugin. The page shows the pom and the real failure, and then the two commands that built the jar instead.
The pom
The coordinates, a version and one property that tells the compiler the release. That is the smallest pom that compiles a Java 21 project; a real one adds the test dependency, the jar plugin and the three checkers of the previous page:
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>library</groupId>
<artifactId>desk</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.release>21</maven.compiler.release>
</properties>
</project>
The offline failure
mvn -o is the offline flag and -q hides the progress. Maven still has to resolve the plugins of the default lifecycle, and the first of them is not in the local repository, so the build stops before it reads a source file:
mvn -o -q package
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:3.4.0 or one of its dependencies could not be resolved:
[ERROR] Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-resources-plugin:jar:3.4.0 has not been downloaded from it before.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
The message names the plugin, its version and the repository it could not reach, so the limit is the environment and not the project. A machine with a network would download the plugin once and build the jar; this page would then show a different output, and the note would change with it.
What a real build adds
A pom that builds this project would add three things. The compiler plugin with release 21, which the property already asks for. The surefire plugin to run the JUnit tests of the previous page, with the launcher as a test dependency. And the jar plugin, or the shade plugin, to write the manifest with the main class. The package phase would then do what three commands did by hand.
The wrapper is the other half of a Maven project: a mvnw script and a properties file that pin the Maven version, so a machine builds with the version the project expects. None of that changes the failure here, because the wrapper downloads Maven itself on the first run.
The build by hand
The build that did run is the one of the previous page: javac into classes and jar with a main class. The two commands are the ones Maven would run, with the class path spelled out instead of resolved. The jar of desk.jar is the result, and the checks are the three tools run on the same files.
What this means for the project
The project is buildable with the JDK alone, which is the point of the group: a service of one file, a test class and three checkers needs no build tool to be understood. Maven earns its place when there are dependencies to resolve and several modules to order, and the page says what it would add rather than pretending the build ran. The Java course makes the same choice in lesson 128 and shows the offline failure there as well.
The next page
The last page is the container: a Dockerfile that copies the jar, exposes the port and starts the serve mode. It is shown and not built, because this container has no Docker daemon; the page says what each line does and what a build would produce.
The pom was written for this page and the Maven command was run with Maven 3.9.16 on OpenJDK 21.0.13 in this container; it failed exactly as the block shows. The jar of the project was built with javac and jar, not with Maven.
Article author: Arthur Isaev