How to avoid compilation of gradle files under resources(src/test/resources) in Eclipse


(jomblick.21) #1

Hi,

We have some .gradle files under src/test/resources for testing purpose. But in eclipse these files are getting compiled and .class files are getting generated. And if i have different .gradle files in different packages with same name. Eclipse is giving duplicate Type found Exception.

How to treat the files under resources as just files and not as scripts ?

Thanks.


(Peter Niederwieser) #2

Which Eclipse plugins do you have installed? Gradle tooling? Groovy plugin? Both? Have you checked the preferences for these plugins? I think you’ll be able to configure it there.


(jomblick.21) #3

I’m using Eclipse Juno and i have both Groovy plugin and gradle Tooling


(Peter Niederwieser) #4

And? Found something in the preferences?


(Peter Niederwieser) #5

Actually, I think you can just add an exclude for ‘.gradle’ files under ‘Build Path -> Source’.


(Peter Niederwieser) #6

Alternatively, try to configure ‘Groovy -> Compiler -> Groovy Script Folders’.


(jomblick.21) #7

yes it is working :slight_smile:


(jomblick.21) #8

Thanks :slight_smile: Adding the groovy script folder is working :slight_smile:


(jomblick.21) #9

Thanks peter…

Found solution from this link http://docs.codehaus.org/display/GROOVY/Groovy-Eclipse+2.1.0RC2+New+and+Noteworthy

For excluding gradle files just include

src/test/resources/**/*.gradle

Now .class files are not getting created for gradle files


(harshad_penkar) #10

I am using STS with Groovy-Eclipse plugin: Version: 3.1.0.RELEASE Build Id: 201210061306

And even after enabling script folders as

'src/test/resources/**/*.gradle'

and later also included ‘src/test/resources’, I see that groovy compiler is attempting to compile the deploy.gradle files as scripts. I would like to have it copied as-is as resources. I see them being copied to the ‘output’ folder but it appears to also compile the .gradle files as scripts. I have 2 folders under ‘src/test/resources’ which contain the deploy.gradle separately.

Unexpected error while validating deploy.gradle
  java.lang.NullPointerException
 at com.google.gdt.eclipse.appengine.rpc.validators.JavaCompilationParticipant.buildStarting(JavaCompilationParticipant.java:83)
 at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.notifyParticipants(AbstractImageBuilder.java:597)
 at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:307)
 at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:62)
 at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:254)
 at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:173)
 at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
 at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
 at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
 at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
 at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
 at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
 at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
 at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
 at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
 at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
 at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
 at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

Another exception that i see is:

Errors running builder 'Java Builder' on project 'TestProject'.
  java.lang.NullPointerException
 at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.toRawType(JDTClassNodeBuilder.java:116)
 at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.configureParameterizedType(JDTClassNodeBuilder.java:294)
 at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNodeBuilder.configureType(JDTClassNodeBuilder.java:56)
 at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.createJDTClassNode(JDTResolver.java:470)
 at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.convertToClassNode(JDTResolver.java:449)
 at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.initialize(JDTClassNode.java:216)
 at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.lazyClassInit(JDTClassNode.java:158)
 at org.codehaus.groovy.ast.ClassNode.getDeclaredMethods(ClassNode.java:958)
 at org.codehaus.groovy.ast.ClassNode.getMethods(ClassNode.java:973)
 at org.codehaus.groovy.ast.ClassNode.hasPossibleStaticMethod(ClassNode.java:1417)
 at org.codehaus.groovy.control.StaticImportVisitor.findStaticMethod(StaticImportVisitor.java:532)
 at org.codehaus.groovy.control.StaticImportVisitor.findStaticPropertyAccessorByFullName(StaticImportVisitor.java:518)
 at org.codehaus.groovy.control.StaticImportVisitor.findStaticPropertyAccessor(StaticImportVisitor.java:489)
 at org.codehaus.groovy.control.StaticImportVisitor.findStaticFieldOrPropAccessorImportFromModule(StaticImportVisitor.java:385)
 at org.codehaus.groovy.control.StaticImportVisitor.transformVariableExpression(StaticImportVisitor.java:172)
 at org.codehaus.groovy.control.StaticImportVisitor.transform(StaticImportVisitor.java:73)
 at org.codehaus.groovy.ast.expr.Expression.transformExpressions(Expression.java:49)
 at org.codehaus.groovy.ast.expr.ArgumentListExpression.transformExpression(ArgumentListExpression.java:67)
 at org.codehaus.groovy.control.StaticImportVisitor.transform(StaticImportVisitor.java:91)
 at org.codehaus.groovy.control.StaticImportVisitor.transformMethodCallExpression(StaticImportVisitor.java:231)
 at org.codehaus.groovy.control.StaticImportVisitor.transform(StaticImportVisitor.java:82)
 at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:139)
 at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
 at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)
 at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:179)
 at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
 at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:102)
 at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:113)
 at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod(ClassCodeExpressionTransformer.java:50)
 at org.codehaus.groovy.control.StaticImportVisitor.visitConstructorOrMethod(StaticImportVisitor.java:58)
 at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:124)
 at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1181)
 at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:51)
 at org.codehaus.groovy.control.StaticImportVisitor.visitClass(StaticImportVisitor.java:52)
 at org.codehaus.groovy.control.CompilationUnit$2.call(CompilationUnit.java:686)
 at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1138)
 at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:610)
 at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:588)
 at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:565)
 at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:171)
 at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.resolve(GroovyCompilationUnitDeclaration.java:2015)
 at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:827)
 at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:137)
 at java.lang.Thread.run(Thread.java:662)

Then it complains about duplicate class:

Couldn't find binding for 'deploy': do you maybe have a duplicate type around?
  java.lang.RuntimeException: Couldn't find binding for 'deploy': do you maybe have a duplicate type around?
 at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.generateCode(GroovyCompilationUnitDeclaration.java:1618)
 at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:838)
 at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:895)
 at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:605)
 at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:894)
 at org.eclipse.jdt.internal.corext.dom.ASTBatchParser.createASTs(ASTBatchParser.java:100)
 at com.google.gwt.eclipse.core.validators.java.JavaCompilationParticipant.handleBuildStarting(JavaCompilationParticipant.java:326)
 at com.google.gwt.eclipse.core.validators.java.JavaCompilationParticipant.access$0(JavaCompilationParticipant.java:307)
 at com.google.gwt.eclipse.core.validators.java.JavaCompilationParticipant$1.run(JavaCompilationParticipant.java:191)
 at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

Any help will be greatly appreciated.

Thanks, -Harshad.


(Peter Niederwieser) #11

I’d try to deactivate the other plugins that show up in the stack traces (e.g. Google App Engine and GWT). If you continue to experience problems, the Groovy Eclipse/Gradle Tooling teams may be better able to help. (Both projects are led by SpringSource.)