This is a complete working Maven project that demonstrates the concepts from the Maven tutorial.
maven-example/
├── pom.xml
├── src/
│ ├── main/
│ │ └── java/
│ │ └── com/
│ │ └── example/
│ │ └── app/
│ │ ├── App.java
│ │ └── MathUtils.java
│ └── test/
│ └── java/
│ └── com/
│ └── example/
│ └── app/
│ └── MathUtilsTest.java
└── target/ (generated after build)
-
Navigate to the project directory:
cd maven-example -
Build the project:
mvn clean package
-
Run the application:
java -jar target/my-app-1.0.0.jar
Hello Maven World!
Original: ' maven tutorial '
Processed: 'Maven tutorial'
5 + 3 = 8
- No empty JAR warning: The project includes actual source code in the correct directory structure
- External dependencies: Uses Apache Commons Lang3 for string utilities
- Unit tests: Includes JUnit 5 tests that run during the build
- Proper packaging: Configured with a main class for easy execution
# Clean previous builds
mvn clean
# Compile only
mvn compile
# Run tests
mvn test
# Package into JAR
mvn package
# Full build with verification
mvn clean verify
# Install to local repository
mvn installThis example demonstrates all the concepts covered in the Maven tutorial and provides a solid foundation for understanding Maven builds.
When running mvn clean verify, the compiled JARs will be placed into the target directory.
The results needs to include two sets of lines that indicate success. First is the overall success mesage as follows.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Additionally, the output must not include the following warning indicating that no code was included.
[WARNING] JAR will be empty - no content was marked for inclusion!