[GRADLE-1190] Gradle groovy plugin and joint compilation Created: 27/Oct/10 Updated: 10/Feb/17 Resolved: 10/Feb/17 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 0.9 |
Fix Version/s: | None |
Type: | Bug | ||
Reporter: | Sargis Harutyunyan | Assignee: | Unassigned |
Resolution: | Won't Fix | Votes: | 3 |
Description |
Hi I have following interface in folder: src/main/java/info/sargis/gedi/InterchangeMessage.java package info.sargis.gedi; import info.sargis.gedi.model.FunctionalGroupPayload; public interface InterchangeMessage { String getEol(); String getCompDataSeparator(); String getDataElemSeparator(); String getDecimalNotation(); String getReleaseIndicator(); String getReserved(); String getSegmentTerminator(); InterchangePayload createInterchangePayload(); FunctionalGroupPayload createFunctionalGroupPayload(); MessagePayload createMessagePayload(); UserSegment createUserSegment(String tagName); }here is my class referred in InterchangeMessage interface src/main/groovy/info/sargis/gedi/model/InterchangePayload.groovy here is build.gradle apply plugin: 'idea' sourceCompatibility = 1.6 repositories { dependencies { testCompile group: 'org.testng', name: 'testng', version: '5.14.1' test { and here is error: sargis@sargis:~/sources/gedi> gradle clean build FAILURE: Build failed with an exception.
BUILD FAILED Total time: 5.344 secs Please note I am able to compile/build my project with IntelliJ |
Comments |
Comment by Adam Murdoch [ 28/Oct/10 ] |
By default, Gradle does joint compilation only for Java and Groovy source under src/main/groovy. Anything in src/main/java is compiled on its own and cannot depend on Groovy classes. This is arguably a pretty confusing default, and one which we should fix. In the meantime, you can configure the groovy plugin to include src/main/java in joint compilation: sourceSets.main.java.srcDirs = []
sourceSets.main.groovy.srcDir 'src/main/java'
|
Comment by Sargis Harutyunyan [ 30/Oct/10 ] |
Thanks for explanation and for your solution, it works nice. |
Comment by Mauro Molinari [ 10/Nov/11 ] |
@Adam: if you intend to change the current default behaviour, please include a clean and simple way to fall back to the current one. I mean, we have projects with hundreds of Java classes and few Groovy classes, in which Java classes do not require Groovy classes. Making Gradle do joint compilation by default on src/main/java too would lead to a performance penalty in the build process in our case. IMHO once one knows that joint compilation is done ONLY in src/main/groovy by default, moving his/her Java code to src/main/groovy or changing sourceSets definition in build.gradle when joint compilation is needed should not be a big trouble... So I personally absolutely prefer the current behaviour. |
Comment by Vaclav Tolar [ 11/Jul/12 ] |
I have also hit this problem. Provided workaround works for me too. |
Comment by Peter Niederwieser [ 14/Jul/12 ] |
The current behavior is how it was designed to work, and we don't currently have plans to change it. It's more likely that we'll revisit this topic once Groovy fundamentally changes its joint compilation approach (which is scheduled for Groovy 3.0). |
Comment by Suresh Khatri [ 20/Sep/12 ] |
@Adam: current design is the right approach for most projects. There is always the option to use src/main/groovy for all java + groovy code and is never going to be a problem. Also the expected behaviour of having java and groovy compiled together in src/main/java is merely a configuration change as mentioned above. Anything more than that probably warrants its own sub project. Also what of the compile*Scala tasks and any other future support for other languages. With polyglot programming becoming popular by the day in projects, any coupling of java and groovy should be made with considerations for other languages as well. |
Comment by Janunsz Sidor [ 02/Jul/14 ] |
What in case of using packages from com.sun…. With recommended strategy of joint compilation(sourceSets.main.groovy.srcDir 'src/main/java') and using workaround for com.sun : doesn't work. I had to move dependency of com.sun into java files with different source root, which cannot depend on groovy files. |
Comment by Benjamin Muschko [ 15/Nov/16 ] |
As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub. We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to. Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:
We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle! |
Comment by Benjamin Muschko [ 10/Feb/17 ] |
Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved. |