0

I am trying generate pojo files from schema using this guide https://netflix.github.io/dgs/generating-code-from-schema/

build.gradle.kts

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-web")
    implementation(project(":graphql-dgs-spring-boot-starter"))
    implementation(project(":graphql-dgs-subscriptions-websockets-autoconfigure"))
    implementation("io.projectreactor:reactor-core:3.4.0")

    api("com.graphql-java:graphql-java:${Versions.GRAPHQL_JAVA}") //v 16.2
}

// Using plugins DSL
plugins {
    id("com.netflix.dgs.codegen") version "4.4.1"
}

tasks {
    generateJava {
//        schemaPaths = ["${projectDir}/src/main/resources/schema"] // List of directories containing schema files
        packageName ="com.example.packagename" // The package name to use to generate sources
        generateClient = true // Enable generating the type safe query API
    }
}

Getting error


Caused by: java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with UUID 59627784-3be5-417a-b9eb-8131a7286089 (expected aadb8d7e-aeef-4415-ad2b-8204d6cf042e or a legacy UUID).
    at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:153)
    at graphql.parser.antlr.GraphqlLexer.<clinit>(GraphqlLexer.java:337)
    ... 231 more
Caused by: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with UUID 59627784-3be5-417a-b9eb-8131a7286089 (expected aadb8d7e-aeef-4415-ad2b-8204d6cf042e or a legacy UUID).
    ... 233 more

I tried older versions of plugin, but that didn't help

2 Answers2

1

It looks like you have a classpath conflict with ANTLR. This is very likely caused by another Gradle plugin that pulls in another (probably older) version of ANTLR. The easy workaround is to re-order your plugins, putting the codegen plugin before the other plugin. Hopefully, the other plugin works with the newer version of ANTLR, but usually, that is the case.

Paul Bakker
  • 1,024
  • 7
  • 9
0

I tried in other project that use gradle, and it works.