简体   繁体   中英

How to add output of task to srcDir of SourceSet

How can I add the output of a task to a SourceSet. My goal is that the task will implicitly be executed before compileGenJava-task.

sourceSets  {
  gen {
    java {
      srcDir "${buildDir}/generated-sources/markup2pojo" // equals output directory of generateSources
    }
  }
[...]

see https://docs.gradle.org/current/userguide/java_plugin.html#sec:changing_java_project_layout

if you have task that generates code before compile; you can add the generated folder path ex: build/gensrc

sourceSets {
    main {
        java {
            srcDirs = ['src/java', 'build/gensrc']
        }
        resources {
            srcDirs = ['src/resources']
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM