Managing Java projects using Gradle or Maven

Are you tired with downloading and managing dozens of jar files in your Java projects? Or you are confused by running and reading a large project source code built by Gradle or Maven. You are not alone.

Maven

Maven was born for solving such problems by making jar files management automatically. Let’s first install it by

1
sudo pacman -Syu maven

Then we create a simple Java project.

To configure the proxy, create a settings.xml file under the folder ~/.m2/ and add the following:

1
2
3
4
5
6
7
8
9
10
11
12
<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<username><username-optional></username>
<password><password-optional></password>
<host><hostname></host>
<port><port></port>
</proxy>
</proxies>
</settings>

Managing modules with parent pom

parent project pom example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<packaging>pom</packaging>

<modules>
<module>module-A</module>
<module>module-B</module>
<module>module-C</module>
</modules>

<groupId>edu.ustb</groupId>
<artifactId>SPESC-contract-execution-service</artifactId>
<version>${revision}</version>
<description>Spring Boot service project for executing SPESC Contract</description>

<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<revision>0.0.7-SNAPSHOT</revision>
</properties>

One of the module’s pom file

1
2
3
4
5
6
7
8
<parent>
<artifactId>SPESC-contract-execution-service</artifactId>
<groupId>edu.ustb</groupId>
<version>${revision}</version>
</parent>

<groupId>edu.ustb.springbootcontract</groupId>
<artifactId>module-A</artifactId>

Caution that the module must be set as ${revision}. An error will be thrown if one of the module set the accurate version like 0.0.7-SNAPSHOT.

Gradle

Build the project: under the project root, gradlew exsits, run

1
./gradlew build
Serving Web Content with Spring MVC Raspberry Pi parallel computing and cluster computing experiment

Comments

You forgot to set the shortname for Disqus. Please set it in _config.yml.
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×