Running a task has different behavior that running a test applying AST's

Hello!

I have a problem with my plugin ‘org.grooscript.conversion’, I have tasks that do conversions from groovy to javascript. But running that tasks not working as running the code out of task (tests). It’s a bit difficult to explain, but I think something is different when running this class:

https://github.com/chiquitinxx/grooscript/blob/master/src/main/groovy/org/grooscript/convert/AstTreeGenerator.groovy

AST’s applied in SEMANTIC_ANALYSIS not applied when running code from a task. Something in classloading or compilation is touched by gradle? or maybe can configure gradle build to avoid that?.

I’m using GradleWrapper 2.1, and using the plugin.

Thank you very much!

I have seen the problem, in AbstractTask.ClosureTaskAction, when the closure task is executing, before the call(), classloader is changed with:

Thread.currentThread().setContextClassLoader(closure.getClass().getClassLoader());

To use the context of the closure I suppose. Then in my conversion, when I do “new GroovyClassLoader()”, I get context of the closure, not the default Thread.currentThread().getContextClassLoader().

So, I will try find how to solve that. Please if you know a solution, is more than welcome :slight_smile:

Thank you.