1

I tried to write an FileWriter to output my file.

public class TestWriter{
    public static void main(String[] args){
        FileWriter fw = new FileWriter("\\User\\Eric\\Desktop\\writer.txt"); //absolute position
            fw.write("testing");           //write some content in my text file
            fw.flush();                    //force to output the source from buffer zone
            fw.close();                    //close the IOstream and release the source
    }
}

and the result said

"Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0."

I have tried to lower my gradle version ,but it still didn't work. Sorry to ask this basic question and I'll really appreciate anyone to solve my problem.

Here's my gradle document

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.5.10'
    id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
    mavenCentral()
}


dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib"
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
    // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api

}

test {
    useJUnitPlatform()
}
Serya
  • 25
  • 1
  • 6
  • 1
    The problem is most likely in the Gradle file ... not the Java source code you are trying to compile. The fix will be to update the Gradle file ... not downgrade Gradle. – Stephen C Dec 20 '21 at 08:24
  • I upgrade to the latest gradle,but it still doesn't work `distributionUrl=https://services.gradle.org/distributions/gradle-7.3.2-bin.zip` – Serya Dec 21 '21 at 05:12
  • I didn't say "upgrade Gradle". I said update the gradle file. The file that specifies how Gradle builds your application. (The "gradle document" as you have called it.) – Stephen C Dec 21 '21 at 05:15
  • According to https://stackoverflow.com/questions/51610420, you can find out which deprecated features Gradle is talking about by adding `--warning-mode=all` to the gradle command line options. – Stephen C Dec 21 '21 at 05:19

2 Answers2

1

I finally found the problem.I used ./gradlew lint --warning-mode fail to testify the program and returned the failure says FAILURE: Build failed with an exception.so probably my absolute path was wrong.The reasons why the code doesn't work is because absolute path formal is invalid. In Windows environment,we use "\" to separate the folder between folder in IntelliJ. ex. D:\\Documents\\course\\practice.txt On the other hand,in Mac environment,you don't have to change anything in your path.ex./Users/Eric/Desktop/writer.txt,and it will work

Serya
  • 25
  • 1
  • 6
0

Try gradle --version and compare it with ./gradlew wrapper --version; maybe what you need to downgrade is gradle-wrapper rather than gradle itself.


However, that's simply a warning that your code or some dependency is using some Gradle feature that was deprecated.

This is not an error per-se.

A deprecation is just a warning, about the need to update the currently running code in order to be able to upgrade when the Gradle 8.0 API will be released.
Only at that point you'll be forced to fix the problem.

You can ignore it, for now. But don't forget it.

Kamafeather
  • 8,663
  • 14
  • 69
  • 99