Can't change Gradle wrapper version unless the build succeeds - gradle

I have a Gradle project that uses the wrapper. The project does not build because the wrapper currently uses Gradle version 7. I know the project will build if I downgrade to version 6.
The problem:
When I run ./gradlew wrapper --gradle-version 6.8, I get a build error. I checked with ./gradlew --version to confirm it's still on 7. That's ironic. That's exactly why I want to downgrade to version 6!
How can I downgrade in this situation.

Related

Found Gradle version Gradle 7.4. Versions Gradle 6.0.0 and newer are not supported in FG3, FG4 however supports Versions 6.8.1 and newer

I have a problem with Gradle. I'm trying to make a mod for Minecraft 1.12.2 and I'm using Intellij IDEA. Everything works fine for the version 1.16.4, but if I want to build a mod for the 1.12 I get this error:
Failed to apply plugin 'net.minecraftforge.gradle'.
Found Gradle version Gradle 7.4. Versions Gradle 6.0.0 and newer are not supported in FG3, FG4 however supports Versions 6.8.1 and newer. Consider upgrading.
It's supposed to do something with apply plugin: 'net.minecraftforge.gradle' in the build.gradle file.
I don't have much experience with this sort of stuff so please help me. Thanks in advance
to write a mod for 1.12.2, Forge provides a build.gradle file. In this, the 3.+ (FG3) is specified as the ForgeGradle version.
The current version of Gradle (7.4.2) only supports ForgeGradle versions from FG4 and newer.
FG3 - older than Gradle version 6.0.0
FG4 - Gradle version 6.8.1 and newer
You now have two options:
You take the Gradle version 7.4.2 and make a mod for a Minecraft version with a ForgeGradle version from FG4 or newer.
You take an older Gradle version.

How do I set a gradle version in Github CI

Our project specifically uses some deprecated features and Kotlin so we have to use Gradle 6.1.1. On GitHub, the android studio build action automatically uses Gradle 7.0, how can we change this?
Our code is available at GitHub
Thanks!
You can switch to older version by updating your wrapper:
./gradlew wrapper --gradle-version=6.1.1
so it would be:
- name: Build with Gradle
run: |
./gradlew wrapper --gradle-version=6.1.1
./gradlew build

Running Gradle on macbook

I have recently bought a macbook and tried to install Gradle with brew install gradle
When I do gradle -v I get my Gradle specifications with no problem, bit when I try to run a Gradle task on my project I got this error:
org.gradle.api.tasks.SourceSetOutput.getClassesDir()Ljava/io/File;
On windows I usually compile the project by doing ./gradlew task_name, but the ./gradlew isn't working here on Mac OS.
What Im I doing wrong?
SourceSetOutput.getClassesDir() was deprecated in Gradle 4 and removed in Gradle 5. It's now SourceSetOutput.getClassesDirs(). I'm guessing you are running a newer version of Gradle on the macbook than you were running on the Windows box. A simple fix is to downgrade the Gradle version.
If you want to actually fix your build to work with Gradle 5+ I suggest you run with --stacktrace on the command line to find out what's using the old API (ie if it's your Gradle script or one of your plugins).
Perhaps a fix is as simple as upgrading one or two of your plugins to a new version which supports Gradle 5+

Using Kotlin version 1.2+, but still get compiler error about `use`

when running the gradlew build or gradlew install on my kotlin project, the following exception shows up in the console:
'use((T) -> R): R' is only available since Kotlin 1.2 and cannot be used in Kotlin 1.1.
Requires newer compiler version to be inlined correctly.
information:
the project is already configured to use Kotlin version 1.2.40.
the project seems to compile and run fine when i run it from my IDE (intelliJ)
what's wrong?
i ran into the same problem.
i updated update my Gradle version from 4.4.1 to 4.7 and then i could build my project with Gradle just fine.
if you are using the gradle wrapper, follow these steps:
visit the Gradle docs to find out what the latest version of Gradle is now.
in [project_root]/gradle/wrapper/gradle-wrapper.properties, use the latest Gradle version available for the distributionUrl property. for example, here is my gradle-wrapper.properties, using Gradle version 4.7:
#Fri Jun 02 20:20:27 PDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
Months later, I encountered the same problem with a projet which is not up to date (still Kotlin 1.1.60), which suddenly stopped being compilable.
I resolved it by using the last version of Gradle Kotlin plugin (1.3.0 as I write).

Gradle tasks missing after bumping gradle version

I was previously using Gradle 2.3 and the Gradle Android plugin 1.3.1.
After upgrading to 4.0.1 and 2.3.0 respectively, my build fails with the following message:
Task with name 'packageReleaseJar' not found in project
Is there a compatibility problem between these versions of Gradle? I believe this is not a custom defined task.

Resources