[GRADLE-1374] Add option to Eclipse plugin to have a single Eclipse project Created: 05/Feb/11 Updated: 10/Feb/17 Resolved: 10/Feb/17 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | New Feature | ||
Reporter: | Ben McCann | Assignee: | Unassigned |
Resolution: | Won't Fix | Votes: | 0 |
Attachments: | build.gradle |
Description |
I don't use the Eclipse plugin right now because I don't like that it forces me to have an Eclipse project per Gradle subproject. I have my Gradle project split up into many tiny little libraries and it would be too hard to have them all as Eclipse projects. E.g. I might have a package structure that looks something like: Every one of these has its own Gradle build file with some dependent upon each other. This work great with Gradle. But it quickly becomes unwieldy within Eclipse if each must be its own Eclipse project with interdependencies. What works much better for me is to have a single Eclipse project with all the transitive dependencies on the classpath. I've written the attached updateClasspath task, which updates the .classpath file assuming all Gradle subprojects live within a single Eclipse project. I'd like to contribute this to the Eclipse plugin. I think it'd be great if the Eclipse plugin could work in either mode by specifying an option. |
Comments |
Comment by Peter Niederwieser [ 05/Feb/11 ] |
Why does it quickly become unwieldy in Eclipse? From my experience, it's quite common to work on an app comprised of many Eclipse projects. Keep in mind that the Gradle Eclipse plugin generates a lot more stuff than just the lib entries in the .classpath file. Merging all of that into a single Eclipse project could cause all sorts of conflicts. At the very least, it would result in Eclipse behaving very differently from the Gradle build. To give just one example, Eclipse would no longer prevent you from using a dependency that's not available in that subproject. An alternative might be to stick to a single Gradle project and let it produce multiple artifacts. This seems to align well with your mental model of the project, and would create just one Eclipse project. |
Comment by Ben McCann [ 06/Feb/11 ] |
Perhaps I don't understand how multi-module projects are intended to work within Eclipse. Let's say that I have two build files: Right now I believe that the Gradle Eclipse plugin generates .project files next to both of those build files. But I'm not sure that you can have the .project files that deep in the directory structure. How do you import those into Eclipse in any meaningful way? Also, if you have a couple dozen of them, I'm not sure how to import them except to do it manually one by one. I love that Gradle doesn't force me to use the Maven project structure, but I feel that the Eclipse plugin it really geared towards that use case. I'm only suggesting that the Eclipse plugin update the classpath when running in 'single project' mode. I actually don't have any problem with the fact that Eclipse will allow me to use a dependency that's not available in the subproject. I setup Eclipse to run a gradle compilation whenever Eclipse does a build (Properties > Builders, fill out the info on main tab, and select During auto builds), so I would immediately be alerted to that and never actually run into that problem. (Actually, having the Eclipse plugin automatically set this up might be nice in 'single project' mode as well.) |
Comment by Mathias Kalb [ 06/Feb/11 ] |
I think you get a lot of trouble if your gradle subprojects doesn't match your eclipse projects. A typical layout: build.gradle (subprojects {apply plugin: "java" apply plugin "eclipse" ...} ) |
Comment by Ben McCann [ 06/Feb/11 ] |
The problem I have with that is that it forces the Maven layout upon you, which is something that Gradle avoids until you start using the Eclipse plugin. Using the Maven layout makes all the classes live three directories deeper, which I really don't like. We use a single Eclipse project to build multiple projects at Google with our own build system and Eclipse plugin all the time and there's never been a situation where I've had difficulty with the two being different. It might sound a bit odd at first if you're coming from a Maven directory structure and are in that mindset. However, if you set Gradle up to build the project within Eclipse there really shouldn't be any problem. |
Comment by Peter Niederwieser [ 07/Feb/11 ] |
> But I'm not sure that you can have the .project files that deep in the directory structure. How do you import those into Eclipse in any meaningful way? File->Import->Existing Projects into Workspace, and select a common parent directory. All projects will be found and imported in one go. > I love that Gradle doesn't force me to use the Maven project structure, but I feel that the Eclipse plugin it really geared towards that use case. It's geared towards the way Eclipse handles multi-projects. |
Comment by Peter Niederwieser [ 07/Feb/11 ] |
After some more discussion with Adam, we have come to the conclusion that we are not going to add a "single-project" mode to the Eclipse plugin at this point. But what we would like to do is to make it easier to reuse the Eclipse tasks separately from the plugin. The idea being that if you are happy to configure the tasks without the help of the plugin, you should be able to generate a single Eclipse project from a multi-project Gradle build without reinventing the wheel. |
Comment by Ben McCann [ 02/Mar/11 ] |
Thanks Peter. That certainly seems reasonable. I'm trying to restructure my project in the way you suggested and I ran into a couple small frustrations. Perhaps rather than working on the "single-project" mode, which it seems like I'm the only one asking for, it'd be better to solve these issues instead. |
Comment by Ben McCann [ 02/Mar/11 ] |
I filed the two issues I just mentioned as new JIRA tickets: |
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. |