vojtechhabarta / typescript-generator

Generates TypeScript from Java - JSON declarations, REST service client
MIT License
1.16k stars 238 forks source link

The plugin does not support the upcoming Gradle 8.0 #903

Open sergeykad opened 2 years ago

sergeykad commented 2 years ago

Running the TypeScriptGenerator version 3.0.1157 on Gradle 7.5 results in the following warning message:

Invocation of Task.project at execution time has been deprecated. This will fail with an error in Gradle 8.0. Consult the upgrading guide for further information: https://docs.gradle.org/7.5/userguide/upgrading_version_7.html#task_project

vojtechhabarta commented 2 years ago

I wasn't able to reproduce the problem. I tried sample-gradle project with Gradle 7.5 and 7.5.1 (with --warning-mode all). Do you have different setup?

sergeykad commented 2 years ago

I have the following build configuration:

plugins {
    id 'java'
    id "cz.habarta.typescript-generator" version "3.0.1157"
}

sourceSets {
    main {
        java {
            resources {
                srcDir 'build/typescript-generator'
            }
        }
    }
}

generateTypeScript {
    jsonLibrary = 'jackson2'
    requiredAnnotations = ['javax.validation.constraints.NotNull']
    classes = ['com.company.config.ConfigContext']
    outputKind = 'module'
}

It produces the following output:

Task :module-name:generateTypeScript Running TypeScriptGenerator version 3.0.1157 Invocation of Task.project at execution time has been deprecated. This will fail with an error in Gradle 8.0. Consult the upgrading guide for further information: https://docs.gradle.org/7.5/userguide/upgrading_version_7.html#task_project Loading class javax.validation.constraints.NotNull Scanning classpath

I am not an expert on Gradle, but I suspect that GenerateTask.java line 232 (for (Task task : getProject().getTasks())) trips it.

sergeykad commented 3 weeks ago

It works with a warning on Gradle 8.x, but the message says: "This will fail with an error in Gradle 9.0".

In typescript-generator v3.2.1263 the issue is in GenerateTask class line 232

at org.gradle.api.DefaultTask.getProject(DefaultTask.java:59)   
at cz.habarta.typescript.generator.gradle.GenerateTask.generate(GenerateTask.java:232)

See https://docs.gradle.org/8.10.2/userguide/upgrading_version_7.html#task_project