Skip to content

Commit 134c4e0

Browse files
authored
Gradle: replace build with shadowJar plugin (#68)
Gradle build compiles our source files and libraries used in the program into separate jar files, and delivers the entire package as a zip file. It is rather inconvenient as user would have to extract from the zip file to use it and also have more unnecessary files to deal with. Additionally, if we package only our own class files into the JAR file, it will not work properly unless the user has all the other JAR files (i.e. third party libraries) our classes depend on. Let's replace the gradle build with shadowJar plugin to package all dependencies into a single JAR file which enhance usability and portability.
1 parent a1e09df commit 134c4e0

3 files changed

Lines changed: 29 additions & 15 deletions

File tree

build.gradle

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
plugins {
22
id 'java'
33
id 'checkstyle'
4+
id 'com.github.johnrengelman.shadow' version '2.0.3'
45
id 'application'
56
}
6-
77
mainClassName = "frontend.RepoSense"
88

99
repositories {
@@ -26,10 +26,9 @@ dependencies {
2626
compile group: 'org.json', name: 'json', version: '20180130'
2727
}
2828

29-
jar {
30-
manifest {
31-
attributes 'Main-Class': 'frontend.RepoSense'
32-
}
29+
shadowJar {
30+
archiveName = 'RepoSense.jar'
31+
destinationDir = file("${buildDir}/jar/")
3332
}
3433

3534
task myZip(type: Zip) {
@@ -38,10 +37,9 @@ task myZip(type: Zip) {
3837
destinationDir = file("src/main/resources")
3938
}
4039

41-
tasks.build.dependsOn("myZip");
40+
tasks.shadowJar.dependsOn("myZip");
4241
tasks.run.dependsOn("myZip");
4342

44-
4543
configurations {
4644
functionalCompile.extendsFrom testCompile
4745
functionalRuntime.extendsFrom testRuntime

docs/Build.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Build from Source
2+
3+
This guide explains how to compile the executable Jar.
4+
5+
1. Download our source code by
6+
* using Git clone <br>
7+
e.g. `git clone https://github.com/reposense/RepoSense.git` <br>
8+
* or download and extract our [zip file](https://github.com/reposense/RepoSense/archive/master.zip).
9+
2. In the `RepoSense` directory, execute the below command in the terminal <br>
10+
`gradlew shadowJar`
11+
3. The executable Jar file will be generated in the folder `build` > `jar` with the name `RepoSense.jar` upon successful build.

docs/user_guide.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@
55
4. Profit!
66

77
## Dependencies
8-
1. Git
9-
2. Gradle
8+
1. **JDK `1.8.0_60`** or later
9+
* This app only works with Java 8 version.
10+
2. **Git** on the command line
11+
* Ensure that you're able to use it on the OS terminal.
12+
1013
## How to Generate Dashboard
11-
```sh
12-
$ gradle clean build
13-
```
14-
Unzip the file in build/distributions/
14+
1. Download the latest executable Jar on our [release](https://github.com/reposense/RepoSense/releases/latest).
15+
* Alternatively, you can compile the executable Jar yourself by following our [build from source guide](Build.md).
16+
2. Execute it on the OS terminal. <br>
17+
Usage: `java -jar RepoSense.jar -config CSV_CONFIG_FILE_PATH [-output OUTPUT_DIRECTORY] [-since DD/MM/YYYY] [-until DD/MM/YYYY]`
18+
3. The dashboard can be in the folder designated in OUTPUT_DIRECTORY, or current working directory otherwise, as index.html.
19+
20+
Sample usage:
1521
```
16-
$ cd build/distributions/RepoSense/bin
17-
$ ./RepoSense -config CSV_path.csv -output output_path/ -since 01/10/2017 -until 01/11/2017
22+
$ java -jar RepoSense.jar -config CSV_path.csv -output output_path/ -since 01/10/2017 -until 01/11/2017
1823
```
1924
Argument List:
2025
- config: Mandatory. The path to the CSV config file.

0 commit comments

Comments
 (0)