On 05/08/2011, at 9:08 AM, phil swenson wrote:

> I want to hook in a doFirst closure to compileJava to copy my sources
> in from an external directory.
> 
> This is problematic as the configuration phase will look to see if the
> sources need to be compiled first, won't find a directory and will
> bypass compile so my copy task doesn't execute.
> 
> So is there a way to accomplish this?

Generally, you should use a separate task to do this sort of thing, and attach 
a dependency between the two tasks.

task prepareSource(type: Copy) {
   from 'wherever-the-source-is'
   into 'some-source-dir'
}

compileJava {
    dependsOn prepareSource
}

Another option is to simply add the external directory as a source directory:

sourceSets.main.java.srcDir 'whereever-the-source-is'


--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com

Reply via email to