For the record, I've implemented this work-around: configurations { java7Mock }
dependencies { java7Mock jsr292Mock } gradle.taskGraph.whenReady { tasks.withType(AbstractCompile).allTasks { Task t -> t.classpath = t.classpath + t.project.configurations.java7Mock } } But it makes my spidey-sense tingle: it doesn't seem right to be injecting the new element onto the classpath after the whole task graph is resolved. ~~ Robert. On 9 December 2010 13:19, Robert Fischer <robert.fisc...@smokejumperit.com> wrote: > I have a jar that I use to mock some code for compiling, but then do > not want that mock jar on the classpath for runtime: the functionality > is provided by a javaagent. What's the recommended way to handle > this? I'm not sure how to redefine the "runtime" configuration to > exclude the jar, so I tried to implement it by mangling the classpath > of compile tasks: > > configurations { > java7Mock > } > > dependencies { > java7Mock jsr292Mock > } > > tasks.withType(AbstractCompile).allTasks { Task t -> > t.classpath = t.classpath + t.project.configurations.java7Mock > } > > That, however, fails with the following message: > > Cause: Failed to notify action. > Cause: Cannot invoke method plus() on null object > > So I tried this: > > tasks.withType(AbstractCompile).allTasks { Task t -> > if(t.classpath) { > t.classpath = t.classpath + t.project.configurations.java7Mock > } else { > t.classpath = t.project.configurations.java7Mock > } > } > > I figured that the other necessary dependencies would be queued up > later, but I actually didn't get anything *but* the java7Mock at that > point. > > So, recommendations as to how to approach this? Am I going about it all > wrong? > > ~~ Robert. > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email