How do I get IntelliJ to recognize gradle generated sources dir?

后端 未结 5 2437
天涯浪人
天涯浪人 2021-02-20 13:08

So I have an XJC javaExec that spins like a top but IntelliJ doesn\'t recognize the generated output despite having marked generated-src/java as such. Do I need to

5条回答
  •  误落风尘
    2021-02-20 13:32

    ext {
        // path to IDEA generated sources directory
        ideaGeneratedSourcesDir = "$projectDir/src/main/generated"
    }
    compileJava {
        //……
        options.annotationProcessorGeneratedSourcesDirectory = file(ideaGeneratedSourcesDir)
        //options.headerOutputDirectory.set(file(ideaGeneratedSourcesDir)) (tested no effect)
        //……
    }
    // above work for me, and i try all method this question mentioned it's not work! env: idea2019.3, wrapped gradle6.3-all, zh-CN, JDK8, [x] annotation processing is disabled(no effect, in global settings ), no idea plugin([x]plugins {id idea}), [x]sourceSets no need to set(genereated srcDir)
    

    myCodeGenExample:

    task vertxCodeGen(type: JavaCompile) {
        group 'build'
        source = sourceSets.main.java
        destinationDir = file(ideaGeneratedSourcesDir)
        classpath = configurations.compileClasspath
        options.annotationProcessorPath = configurations.annotationProcessor
        options.debugOptions.debugLevel = "source,lines,vars"
        options.compilerArgs = [
                "-proc:only",
                "-processor", "io.vertx.codegen.CodeGenProcessor",
                // where the non Java classes / non resources are stored (mandatory) - the processors requires this option to know where to place them
                "-Acodegen.output=$destinationDir.absolutePath",
        ]
    }
    

    refresh the gradle, continously exist

提交回复
热议问题