Binil Thomas
Binil Thomas

Reputation: 13779

How to generate source files and compile them with gradle

I have a gradle build script similar to:

apply plugin: 'war'

task genSources << {
  // here I generate some java files
}

// making sure that source files are generated
// before compilation
compileJava.dependsOn(genSources)

How can I make the files generated in genSources compile along with files in src/main/java during compileJava?

Upvotes: 14

Views: 16109

Answers (1)

c_maker
c_maker

Reputation: 20006

You may try adding the path to the generated sources like this:

sourceSets {
    main {
        java {
            srcDir '<path to generatedJava>'
        }
    }
}

Upvotes: 20

Related Questions