Gradle tasks from build.gradle are not getting listed - gradle

The gradle task that I have added to my build.gradle is not getting listed.
This is how my build.gradle looks
task helloWorld {
doLast {
println 'Hello world from gradle.'
}
}
However when I run gradle tasks the task helloWorld is not listed. Please help.
The gradle version is the following.
$ gradle -v
------------------------------------------------------------
Gradle 3.4.1
------------------------------------------------------------
Build time: 2017-03-03 19:45:41 UTC
Revision: 9eb76efdd3d034dc506c719dac2955efb5ff9a93
Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_31 (Oracle Corporation 25.31-b07)
OS: Mac OS X 10.11.6 x86_64

Looks like we need to use --all switch. The following works.
$ gradle tasks --all

Related

Convert build.gradle wrapper / distributionUrl settings to build.gradle.kts

How do I convert this build.gradle code to build.gradle.kts?
// run ./gradlew wrapper whenever you change this
wrapper {
distributionUrl("https://globochem.jfrog.io/artifactory/globochem-gradle/globochem-6.6.6.zip")
}
For this setup:
$ gradle -v
------------------------------------------------------------
Gradle 7.6
------------------------------------------------------------
Build time: 2022-11-25 13:35:10 UTC
Revision: daece9dbc5b79370cc8e4fd6fe4b2cd400e150a8
Kotlin: 1.7.10
Groovy: 3.0.13
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 11.0.18 (Homebrew 11.0.18+0)
OS: Mac OS X 12.6.2 aarch64
This works for build.gradle.kts:
// run ./gradlew wrapper whenever you change this
tasks.withType<Wrapper> {
distributionUrl = "https://globochem.jfrog.io/artifactory/globochem-gradle/globochem-6.6.6.zip"
}

Gradle build fails with "org/eclipse/jgit/storage/file/FileRepositoryBuilder has been compiled by a more recent version of the Java"

Starting from today I cannot build my project anymore. There are no changes in it.
Looks like some Gradle dependency is recompiled with Java 11.
I'm using Java 8 and Gradle 4.10.
org/eclipse/jgit/storage/file/FileRepositoryBuilder has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Does anyone have the same problem?
./gradlew --version
------------------------------------------------------------
Gradle 4.10.3
------------------------------------------------------------
Build time: 2018-12-05 00:50:54 UTC
Revision: e76905e3a1034e6f724566aeb985621347ff43bc
Kotlin DSL: 1.0-rc-6
Kotlin: 1.2.61
Groovy: 2.4.15
Ant: Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM: 1.8.0_292 (Private Build 25.292-b10)
OS: Linux 4.15.0-142-generic amd64
echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64/
./gradlew clean
FAILURE: Build failed with an exception.
* What went wrong:
org/eclipse/jgit/storage/file/FileRepositoryBuilder has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
I've changed the version of Gradle plug-in org.ajoberstar.grgit in build.gradle and it is working. The version before was 4.1.0. Now: 4.1.1
plugins {
id 'java'
id "org.ajoberstar.grgit" version "4.1.1"
}

Gradle JVM Version vs JDK

I want to use JDK11 in Gradle for compiling my project without modifying JDK_HOME, which points to JDK10. I'm using JDK10 for most projects, but testing an upgrade to JDK11 in Gradle.
JAVA_HOME=C:\Program Files\Java\jdk-10.0.2
In /.gradle/gradle.properties I set the following property:
org.gradle.java.home=C:/Program Files/Java/jdk-11.0.3
when I run the command: gradle properties, I see the following line:
org.gradle.java.home: C:/Program Files/Java/jdk-11.0.3
but when I run the command: gradle -version, I see this, showing JVM is version 10:
------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------
Build time: 2019-04-26 08:14:42 UTC
Revision: 261d171646b36a6a28d5a19a69676cd098a4c19d
Kotlin: 1.3.21
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 10.0.2 ("Oracle Corporation" 10.0.2+13)
OS: Windows 10 10.0 amd64
Despite is saying JDK10 above, is it still compiling in JDK11 and JVM only means the Java version used to run the Gradle Daemon?
The version reported by gradle -version is the one of the client VM executing that command.
Normally, Gradle will otherwise use a daemon process to execute your build. That process will respect the org.gradle.java.home setting.
Note that you can also have a finer control on which Java executable is used for the different tasks in Gradle. See the documentation for details.

Gradle-plugins : how can i know Gradle supported plugins version

I am trying to install sonarqube plugin in my gradle project.
I am using
Gradle 3.5
Groovy: 2.4.10
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_171 (Oracle Corporation 25.171-b11)
OS: Linux 4.4.0-128-generic amd64
And in build.gradle I added:
plugins {
id "org.sonarqube" version "2.0.1"
}
I run gradle sonarqube command
I am getting error like this,
* What went wrong:
org.gradle.internal.jvm.Jvm.getRuntimeJar()Ljava/io/File;
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
java.lang.NoSuchMethodError: org.gradle.internal.jvm.Jvm.getRuntimeJar()Ljava/io/File;
at org.sonarqube.gradle.SonarQubePlugin.getLibraries(SonarQubePlugin.java:363)
How can I know which version of sonarqube I should mention for Gradle 3.5?

Cannot run gradle commands terminal

I am having an issue with gradle in my Android Studio project. Whenever i run any tasks on the command line: clean,assemble etc the only task that gets run is build. I am using the latest version of android studio. I also have a gradlew executable file. The same thing happens when i attempt to run tasks using that. I have tried re-installing gradle locally on my machine but the issue keeps persisting. Does anyone have any ideas?
operating system = Ubuntu 13.04
gradle -v
------------------------------------------------------------
Gradle 1.10
------------------------------------------------------------
Build time: 2013-12-17 09:28:15 UTC
Build number: none
Revision: 36ced393628875ff15575fa03d16c1349ffe8bb6
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy: 2.2.0
JVM: 1.7.0_51 (Oracle Corporation 24.45-b08)
OS: Linux 3.8.0-35-generic amd64
examples commands i am executing are 'gradle clean' 'gradle check' 'gradle compileLint' 'gradle compileLint'
I have also tried using the gradle wrapper './gradlew clean' etc
I am using openJdk as my java platform.

Resources