Maven
This is a README.adoc file. The original repository is located here.
Task Maven
Fenrir ID:
maven
Branch:maven
Points:90
Task submission
Put all the files in the maven directory:
...
├─ maven
│ ├─ javadoc
│ │ ├─ ...
│ │ ├─ repo.xml
│ │ └─ pom.xml
│ ├─ meeting
│ │ ├─ ...
│ │ └─ pom.xml
│ ├─ profiles
│ │ ├─ ...
│ │ └─ pom.xml
│ ├─ server
│ │ ├─ ...
│ │ └─ pom.xml
│ └─ simple
│ ├─ ...
│ └─ pom.xml
└─ .git
| All sources use java 25. The resulting bytecode must target java 25 too. |
Simple app (10 points)
Subdirectory: simple
You are provided with two files: Main.java and Deps.java:
...
├─ simple
│ └─ Deps.java
└─ Main.java
Transform them into a maven project. Its coordinates are:
-
artifactID:simple -
groupID:com.github.devtoolscourse -
version:0.1-SNAPSHOT
The generated jar must have Main class as the entrypoint and its name must be simple.jar.
Version conflict (20 points)
Subdirectory: meeting
The project uses dependencies from the Maven repository of the https://gitlab.com/lBAH/dt-mvn-repo GitLab project.
However, when trying to compile the project, the build fails due to the incompatible versions of the dependencies. Update the pom.xml so that the project builds successfully.
See the dependency tree (use maven-dependency-plugin) and download the dependencies. Use JDK tools to study the dependencies.
|
If you’re using IntelliJ IDEA, you can study the dependencies in the Project window (where fs tree is shown). Expand External Libraries section and you’ll see Maven:….
|
Dependency duplication (20 points)
Subdirectory: server
This time you have to work with a modularised project. It consists of three modules: core, server-a and server-b. Both servers depend on the core module. Create pom.xml files to build the project.
Maven will be invoked with mvn package -Dinstall.prefix=DIR from the server directory. After the project is built, the created jars must be placed into the ${install.prefix} directory: servers into services subdirectory, their dependencies into deps subdirectory.
| You must avoid duplicating the shared dependencies. Do not use fat jars! |
${install.prefix}
├─ services
│ ├─ server-a-1.0.0.jar
│ └─ server-b-1.0.0.jar
└─ deps
└─ ...
Profiles (20 points)
Subdirectory: profiles
Create a multi-module maven project. Module core depends on provider which has two implementations: dev and prod. The implementation is defined by the chosen profile: either dev or prod. The dev profile is the default one.
Moreover, the project uses properties files:
db.url = db://${credentials.username}:${credentials.password}/db
When dev is selected, you must pass user and pass. When prod is selected, the credentials are passed as environment variables: USERNAME and PASSWORD.
The core module must be compiled into a fat jar.
Plugin (20 points)
Subdirectory: javadoc
You have to implement the maven-javadoc-plugin plugin. It must generate a site with doc pages for the project (recall the javadoc command). The plugin must provide a goal javadoc which is executed on the process-sources phase.
<plugin>
<groupId>com.github.devtoolscourse</groupId>
<artifactId>javadoc-plugin</artifactId>
<version>0.1.0</version>
<executions>
<execution>
<goals>
<goal>javadoc</goal>
</goals>
</execution>
</executions>
</plugin>
Deploy the plugin to the GitLab Maven Repository of your project. Create a repo.xml file, which contains the code that allows to use your plugin.
Use gl-repo id. The credentials are automatically passed during the tests in GitLab.
|
<project>
<!-- ... -->
HERE repo.xml IS INJECTED
<!-- ... -->
</project>
Use Files utility class to work with the FS through Java code.
|
Questions
-
What is the difference between a fat and a slim jars?
-
How to generate Javadoc for the project?
-
Which version is chosen when multiple versions are present in the dependencies tree?
-
How to access an environment variable in
pom.xml? -
How to declare additional repositories for the dependencies/plugins?
-
What is the difference between plugins and dependencies?
Copyright
The project is licensed under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
© 2026-present Iwan Kalinin <koefic.cien@gmail.com>