Gradle
Ok, I skipped from make to ant to scons to maven to gradle, but I have to say it is probably the way to go now. Gradle is not XML which is a delight by itself, but it also borrows the good stuff from other tools.
installation
Gradle requires java JRE version7 or higher, so I assume that is available.
sdkman
Since you rarely get the latest version on linux, this is the preferred way of installing the exactly version you like. Download the binary package from : https://gradle.org/install/#manually_
| reinstall | |
|---|---|
Then add this to your startup file :
zero installation
If you have projects like from android studio that come with a gradle wrapper you don't need to install anything up front. Just run the gradlew script from the project directory
| wrapper | |
|---|---|
introduction
I needed this multiple times, so let's point to the best tutorial for this : gradle_tut It has a lot of links to the original docs, but explains between the lines.
cheatsheet
In lack of any useful :
List all tasks :
| list tasks | |
|---|---|
Run the default task quietly
| silent | |
|---|---|
proxy
Add these to gradle.properties
| proxy | |
|---|---|
template
I found this on some forum :
This does work, the current build.gradle for Stocker is now :
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
mainClassName = "org.klopt.tools.Stocker"
defaultTasks 'clean', 'fatJar', 'tags'
version = '1.0'
sourceCompatibility = 1.8
jar {
manifest {
attributes 'Implementation-Title' : 'Gradle Stocker',
'Implementation-Version': version,
'Main-Class' : 'org.klopt.tools.Stocker'
}
}
//create a single Jar with all dependencies
task fatJar(type: Jar) {
manifest.from jar.manifest
baseName = project.name + '-all'
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
} {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
with jar
}
task tags {
exec {
executable= "ctags";
args = ["-R", "--extra=+q", "src"];
}
}
troubleshooting
Could not determine java version
when running gradlew :
./gradlew
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '11.0.18'.
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
This is purely because you wrapper script (gradlew) is running an older version. Look in the wrapper properties what version is used.
#Fri Jan 24 09:36:43 CET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-bin.zip
So it is using gradlew 2.4, and if you check your current gradle version.
------------------------------------------------------------
Gradle 8.0.2
------------------------------------------------------------
Build time: 2023-03-03 16:41:37 UTC
Revision: 7d6581558e226a580d91d399f7dfb9e3095c2b1d
Kotlin: 1.8.10
Groovy: 3.0.13
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 11.0.18 (Debian 11.0.18+10-post-Debian-1deb11u1)
OS: Linux 5.10.0-21-amd64 amd64
So by all means just update the zip file :
Now when you run gradlew commands it will start downloading that version first.