Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"JavadocIntegrationKt not found" compilation error when adding method doc in *.sq file #1982

Closed
mfickett opened this issue Sep 25, 2020 · 0 comments · Fixed by #1999
Closed

Comments

@mfickett
Copy link

Build Environment
SQLDelight version: 1.4.1

./gradlew --version

------------------------------------------------------------
Gradle 6.5.1
------------------------------------------------------------

Build time:   2020-06-30 06:32:47 UTC
Revision:     66bc713f7169626a7f0134bf452abde51550ea0a

Kotlin:       1.3.72
Groovy:       2.5.11
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          1.8.0_242 (AdoptOpenJDK 25.242-b08)
OS:           Mac OS X 10.15.6 x86_64

Describe the bug
I added a Javadoc-style comment above my SQL function definition in a *.sq file:

/**                                                                                                  
 * Search for xyz.               
 *                                                                                                   
 * @param query: Text for substing match. SQLDelight will sanitize this input. It should be wrapped  
 *     in %..%.                                                                                      
 * @param limit: For pagination, maximum number of results.                                          
 * @param max_build_date: For pagination. Results are ordered by build date, latest first. This      
 *     specifies the first build date to include in this result set.                                 
 */                                                                                                  
search:                                                                                              
SELECT                                                                                               
    some_id,                                                           
    some_description, 
...

If I remove the comment, SQL compilation succeeds. If it's there, I get an error.

> Task :generateMainMyDbInterface FAILED
FAILURE: Build failed with an exception.

I was wondering if I was missing a gradle dependency, but I didn't see mention of JavadocIntegrationKt in the SQLDelight docs or repo.

  1. Stacktrace:
        at com.squareup.sqldelight.core.compiler.SqlDelightCompilerKt.tryWithElement(SqlDelightCompiler.kt:224)
        at com.squareup.sqldelight.core.compiler.QueriesTypeGenerator.interfaceType(QueriesTypeGenerator.kt:32)
        at com.squareup.sqldelight.core.compiler.SqlDelightCompiler.writeQueriesInterface$sqldelight_compiler(SqlDelightCompiler.kt:174)
        at com.squareup.sqldelight.core.compiler.SqlDelightCompiler.writeInterfaces(SqlDelightCompiler.kt:47)
        at com.squareup.sqldelight.core.SqlDelightEnvironment$generateSqlDelightFiles$2.invoke(SqlDelightEnvironment.kt:129)
        at com.squareup.sqldelight.core.SqlDelightEnvironment$generateSqlDelightFiles$2.invoke(SqlDelightEnvironment.kt:56)
        at com.squareup.sqldelight.core.SqlDelightEnvironment$forSourceFiles$1.invoke(SqlDelightEnvironment.kt:160)
        at com.squareup.sqldelight.core.SqlDelightEnvironment$forSourceFiles$1.invoke(SqlDelightEnvironment.kt:56)
        at com.alecstrong.sql.psi.core.SqlCoreEnvironment$forSourceFiles$1.processFile(SqlCoreEnvironment.kt:95)
        at com.alecstrong.sql.psi.core.CoreFileIndex.iterateContentUnderDirectory(SqlCoreEnvironment.kt:130)
        at com.alecstrong.sql.psi.core.CoreFileIndex.iterateContentUnderDirectory(SqlCoreEnvironment.kt:127)
        at com.alecstrong.sql.psi.core.CoreFileIndex.iterateContentUnderDirectory(SqlCoreEnvironment.kt:127)
        at com.alecstrong.sql.psi.core.CoreFileIndex.iterateContentUnderDirectory(SqlCoreEnvironment.kt:127)
        at com.alecstrong.sql.psi.core.CoreFileIndex.iterateContentUnderDirectory(SqlCoreEnvironment.kt:127)
        at com.alecstrong.sql.psi.core.CoreFileIndex.iterateContentUnderDirectory(SqlCoreEnvironment.kt:127)
        at com.alecstrong.sql.psi.core.CoreFileIndex.iterateContent(SqlCoreEnvironment.kt:121)
        at com.alecstrong.sql.psi.core.SqlCoreEnvironment.forSourceFiles(SqlCoreEnvironment.kt:93)
        at com.squareup.sqldelight.core.SqlDelightEnvironment.forSourceFiles(SqlDelightEnvironment.kt:158)
        at com.squareup.sqldelight.core.SqlDelightEnvironment.generateSqlDelightFiles(SqlDelightEnvironment.kt:121)
        at com.squareup.sqldelight.gradle.SqlDelightTask.generateSqlDelightFiles(SqlDelightTask.kt:65)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
        ... snip ...
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.squareup.sqldelight.core.compiler.integration.JavadocIntegrationKt$javadocText$2
        at com.squareup.sqldelight.core.compiler.integration.JavadocIntegrationKt.javadocText(JavadocIntegration.kt:36)
        at com.squareup.sqldelight.core.compiler.QueryGenerator.addJavadoc(QueryGenerator.kt:180)
        at com.squareup.sqldelight.core.compiler.SelectQueryGenerator.defaultResultTypeFunctionInterface(SelectQueryGenerator.kt:65)
        at com.squareup.sqldelight.core.compiler.QueriesTypeGenerator$interfaceType$$inlined$forEach$lambda$1.invoke(QueriesTypeGenerator.kt:40)
        at com.squareup.sqldelight.core.compiler.QueriesTypeGenerator$interfaceType$$inlined$forEach$lambda$1.invoke(QueriesTypeGenerator.kt:22)
        at com.squareup.sqldelight.core.compiler.SqlDelightCompilerKt.tryWithElement(SqlDelightCompiler.kt:222)
        ... 114 more
  1. The build.gradle file for the failing project
plugins {
    id "org.jetbrains.kotlin.jvm" version "1.3.72"
    id "org.jetbrains.kotlin.kapt" version "1.3.72"
    id "org.jetbrains.kotlin.plugin.allopen" version "1.3.72"
    id "com.github.johnrengelman.shadow" version "6.0.0"
    id "application"
    id "com.google.protobuf" version "0.8.12"
    id "com.squareup.sqldelight" version "1.4.1"
}

version "0.1"
group "$projectPackage"

repositories {
    mavenCentral()
    jcenter()
    google()
}

configurations {
    // for dependencies that are needed for development only
    developmentOnly
}

dependencies {
    kapt(platform("io.micronaut:micronaut-bom:$micronautVersion"))
    kapt("io.micronaut:micronaut-inject-java")
    kapt("io.micronaut:micronaut-validation")
    kapt("io.micronaut.data:micronaut-data-processor")
    implementation(platform("io.micronaut:micronaut-bom:$micronautVersion"))
    implementation("io.micronaut:micronaut-inject")
    implementation("io.micronaut:micronaut-validation")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
    implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
    implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
    implementation("io.micronaut:micronaut-runtime")
    implementation("io.micronaut.grpc:micronaut-grpc-server-runtime:$micronautGrpcVersion")
    implementation("io.micronaut.grpc:micronaut-grpc-client-runtime:$micronautGrpcVersion")
    implementation("io.grpc:grpc-kotlin-stub:${grpcKotlinVersion}")
    implementation("io.grpc:grpc-services:${grpcKotlinVersion}")
    implementation("javax.annotation:javax.annotation-api")
    implementation("io.micronaut.sql:micronaut-jdbc-hikari")
    implementation("com.squareup.sqldelight:jdbc-driver:1.4.1")
    implementation("io.micronaut.kotlin:micronaut-kotlin-extension-functions")
    runtimeOnly("ch.qos.logback:logback-classic")
    runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
    runtimeOnly("mysql:mysql-connector-java")
    kaptTest(enforcedPlatform("io.micronaut:micronaut-bom:$micronautVersion"))
    kaptTest("io.micronaut:micronaut-inject-java")
    testImplementation(enforcedPlatform("io.micronaut:micronaut-bom:$micronautVersion"))
    testImplementation("io.micronaut.test:micronaut-test-kotlintest")
    testImplementation("io.mockk:mockk:1.9.3")
    testImplementation("io.kotlintest:kotlintest-runner-junit5:3.3.2")
    testImplementation(platform("org.testcontainers:testcontainers-bom:1.14.3"))
}

test.classpath += configurations.developmentOnly

mainClassName = "${projectPackage}.ApplicationKt"

// use JUnit 5 platform
test {
    useJUnitPlatform()
}

java {
    sourceCompatibility = JavaVersion.toVersion('11')
}

allOpen {
    annotation("io.micronaut.aop.Around")
}
compileKotlin {
    kotlinOptions {
        jvmTarget = '11'
        //Will retain parameter names for Java reflection
        javaParameters = true
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = '11'
        javaParameters = true
    }
}
kapt {
    arguments {
        arg("micronaut.processing.incremental", true)
        arg("micronaut.processing.annotations", "${projectPackage}.*")
        arg("micronaut.processing.group", "$projectPackage")
        arg("micronaut.processing.module", "monocle")
    }
}

shadowJar {
    mergeServiceFiles()
}

tasks.withType(JavaExec) {
    classpath += configurations.developmentOnly
    jvmArgs('-XX:TieredStopAtLevel=1', '-Dcom.sun.management.jmxremote')
    if (gradle.startParameter.continuous) {
        systemProperties(
            'micronaut.io.watch.restart':'true',
            'micronaut.io.watch.enabled':'true',
            "micronaut.io.watch.paths":"src/main"
        )
    }
}



sourceSets {
    main {
        java {
            srcDirs 'build/generated/source/proto/main/grpc'
            srcDirs 'build/generated/source/proto/main/grpckt'
            srcDirs 'build/generated/source/proto/main/java'
        }
        proto {
            srcDirs = ['../interface']
        }
    }
}

protobuf {
    protoc { artifact = "com.google.protobuf:protoc:3.12.2" }
    plugins {
        grpc { artifact = "io.grpc:protoc-gen-grpc-java:1.29.0" }
        grpckt { artifact = "io.grpc:protoc-gen-grpc-kotlin:0.1.2" }
    }
    generateProtoTasks {
        all()*.plugins {
            grpc {}
            grpckt {}
        }
    }
}

sqldelight {
    MyDb { // the name of the generated database class
        packageName = "${projectPackage}.db"
        dialect = "mysql"
    }
}

gradle.properties:

micronautVersion=2.0.1
kotlinVersion=1.4.10
org.gradle.java.home=/Library/Java/JavaVirtualMachines/openjdk-13.0.2.jdk/Contents/Home
micronautGrpcVersion = 2.0.0.M3
kotlinxCoroutinesVersion=1.3.9
protocVersion=3.12.2
grpcVersion=1.29.0
grpcKotlinVersion=0.1.2
projectPackage=com.my.project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants