Maven #02 ~ pom.xml
Last updated: August 20, 2017
pom.xml is the main element of our project. In file are defined all of the dependencies for example:
- a way of building a project
- testing
- running a project
- generating documentation
- creating a release
After generating project pom.xml file looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<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>com.energy.billing.system</groupId>
<artifactId>ebs</artifactId>
<version>1.0-SNAPSHOT</version>
</project>It looks very raw. Only groupId, artifactId, modelVersion, version. This information on this step is not very important for us. First, change that we will make will be adding JUnit library.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>Now we can compile our project:
mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ebs 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ebs ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ ebs ---
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.646 s
[INFO] Finished at: 2017-03-12T16:16:46+01:00
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------As we can see project build successfully. For now, we should look at three commands:
mvn– this command runs maven and proper pom.xml fileclean– delete target catalog and old files versioncompile– runs java compiler
My site is free of ads and trackers. Was this post helpful to you? Why not