Sourceset compile options?

Is it possible to provide compile options to sourceset? For example If I want to use Java compilation otpion fork, how to apply it to the sourceset?

You have to adjust the associated ‘JavaCompile’ task. For example, if you have a “mySourceSet” source set, then you will have a “compileMySourceSetJava” which you can configure. See the DSL doc about ‘JavaCompile’

Hi can you provide an example of how to configure please. When I tried adding a

task compileMySourceSetJava(type: JavaCompile) { options.fork = true options.forkOptions.executable = myjavacExecutable }

Cannot add task ‘:compileMySourceSetJava’ as a task with that name already exists. I cant see an example of how to configure it.

‘compileMySourceSetJava’ is automatically added by the Java plugin. So you should just do this:

compileMySourceSetJava.options.fork = true
compileMySourceSetJava.options.forkOptions.executable = myjavacExecutable

I am getting the error “Could not find property ‘compileMySourceSetJava’ on root project” when I add the above code in my script. Could you please clarify where the above script should be present in build script…

Thanks Attila. worked for me.