Gradle
- Make sure you have Gradle installed by running
gradle -version
.
- Create a directory for your project and navigate into it. Open a terminal.
- Execute
gradle wrapper
. You'll see gradlew
and gradlew.bat
files and gradle
and .gradle
directories created. From now on, you can forget about global Gradle installation as you can use wrapper. Wrapper can be used even when Gradle is not installed.
Create a file named build.gradle
. It's a project descriptor in Gradle:
plugins {
id 'java'
}
repositories {
jcenter()
}
dependencies {
implementation("com.github.javafaker:javafaker:0.16")
}
Import the project in Eclipse.
Maven
- Make sure you have Maven installed by running
mvn -version
.
- Create a directory for your project and navigate into it.
Create a file named pom.xml
or build.gradle
. It's a project descriptor in Maven:
<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.your.company</groupId>
<artifactId>app</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>0.16</version>
</dependency>
</dependencies>
</project>
Import the project in Eclipse.
Is this actually that complicated?
As you see, no, it's not complex at all!
Why can I not just download and add the library to my build path?
You can. This approach just don't scale when you have dozens and hundreds of dependencies (with their own dependencies). Plus, modern software needs not only to be compiled, but tested, packaged, released & distributed. Though you can do most of that from your IDE, but… This appriach just don't scale. Just because people use different IDEs. Because there is no IDE on a build server. Because when you know Gradle or Maven a little bit better, you'll see that it's even faster to accomplish tasks via build tool then via menu items.
Happy hacking!