Skip to content

mklwong/java_maven_tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This section contains tutorial notes for building Java packages with Maven.

Directory Structure

Maven creates a directory tree that looks like the following:

root
|--src
|   |--main
|   |   |--java
|   |       |--<package_name>
|   |             |--App.java
|   |
|   |--test
|       |--java
|           |--<package_name>
|                 |--AppTest.java
|
|--target
|   |--<package_jar_name>.jar
|   |--...{bunch of extra output folders}
|
|--pom.xml

All source codes goes in root/src/main/java/<package_name> with the package hierachy beginning at <package_name>

All unit tests goes into root/src/test/java/<package_name> with packages importable from <package_name>

The .jar file in the target folder contains the output that the maven package command generates (in Visual Studio Code).

pom.xml controls the way the maven compiles the output and how it runs etc.

Jar entry point

To set the entry point of the output jar, you need to find the maven-jar-plugin plugin in pom.xml and adding the following:

<configuration>
  <archive>
    <manifest>
      <mainClass>{package_name}.App</mainClass>
    </manifest>
  </archive>
</configuration>

About

Boilerplate and explanation of Maven struction

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages