-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to resolve groovy source in test files #321
Comments
I'm not 100% sure that the Groovy Maven plug-in allows overriding of the sourceDirectory and testSourceDirectory. From what I have seen, it is hardcoded to src/main/groovy and src/test/groovy. Could you at least try that out to be sure it is not the issue?
|
Hi Eric, and tests under but still no luck. I see the same issue. Any other pointers on this? I am trying all the possible options :( Thanks |
@gprasann Setting up sourcefolders for the groovy-eclipse-maven plugin is a bit complicated. Have your read https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-Maven-plugin#setting-up-the-source-folders ? |
When you build from Eclipse, are you just running the builder (Ctrl-B or Build Project/All)? Or are you running Maven's Run As > Maven Build.
Did you start from the Groovy Maven<https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-Maven-plugin> wiki page? If there is something incorrect there, I'd like to get it fixed.
|
Thank you @PascalSchumacher and @eric-milles for your replies. @PascalSchumacher - I have read that link and tried all of the options suggested by moving the source/test files under src/main and directly under src/ with different build options. @eric-milles - I am running it as Maven build and not the eclipse build. I have tried the options from the link provided, but no luck. I am still trying to figureout the issue :( Thanks |
Now I tried to add maven-surefire-plugin as well and after which the grovy testcases are not at all compiled by the compiler. It really is behaving crazy. I tried to even add build-helper-maven-plugin by moving the source/test files outside of src/main and src/test, still no luck. Thanks |
I created a very simple Groovy-Maven project and could compile both main and test sources using Run As > Maven Build... with goals <project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>Mvn</artifactId>
<groupId>a.b.c</groupId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>ASCII</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.2-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.4.3-01</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.12</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project> When I run Maven > Update Project... it added the Groovy nature and the source folders src/main/groovy and src/test/groovy. I needed files in src/main/java and src/test/java for this, as described in https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-Maven-plugin#setting-up-the-source-folders
This last line for compile and test-compile lets you know the Groovy batch compiler is active. |
Hi @eric-milles - Thank you very mmuch for your help on this. Now I followed your approach of creating the Maven project and then converting to Grails and it looks to be working fine. I am unable to understand the differences between the two approaches, but I am happy that I am able to run it fine now :) Thanks again all for your help on this. |
Hi @eric-milles - I got the exact issue now. Any idea what I am missing here? Thanks, |
@gprasann Can you describe the change I would make to my pom.xml to get to this state? I've not used Maven a whole lot. |
Hi @eric-milles, Thank you for the reply. You need to add tag to your pom.xml file as below <packaging>pom</packaging> With this we would be able to build grails plugin projects as zip artifacts instead of jar. Thanks, |
So once changed to a pom project, I think Maven is expecting a module that contains the sources and tests to be packaged as jar or war or whatever. With pom packaging, my build does not even compile sources. |
Hi @eric-milles - Looks like I have craked it. I am using the default packaging (jar) and I am using the grails-maven-plugin with goal as package-plugin. With this I had to move source files out of src/main directly under src. And same for test files. Otherwise even the test files are packaged in the plugin artifact (not really sure why) I also had to use build-helper-maven-plugin to add source and test folders. Now after doing all this, I am able to build the grails plugin fine with maven. Hopefully this will help someone who has same problem :) And Thank you again for your help. |
I am fairly new to Groovy. I have created a groovy project and have converted it to maven. I use Eclipse Kepler with groovy support for development.
When I run the maven build locally, everything works fine, but when I run the build on Jenkins, I see unresolved groovy source file errors and all the compilation errors are only in test cases.
Does anyone know why do I have an issue on Jenkins? Any pointers on this would be vey helpful.
section in my pom.xml file looks like below. Thank you.
The text was updated successfully, but these errors were encountered: