OK. I understood all three, and thought that I would publish this answer for future readers.
Please note: this solution is really viable for modern C programmers who:
- Want to do all the development in Eclipse using modern IDE tools such as syntax highlighting, error, goto declaration, open call hierarchy, Eclipse debugger, etc .; but ...
- Want a modern push-a ** build system like Gradle to do all the command line / shell building
In addition, since I am on Windows, I decided to use MinGW for my GCC software, so if you are either on * nix or Mac, or if you prefer Cygwin, you will have to configure this solution even later.
In addition, I only confirmed that this works with Eclipse Luna, using the latest Eclipse CDT plugin (8.6) and using Gradle 2.3.
Decision
First I had to fix my use of the C plugin by changing my build.gradle to look like this:
apply plugin: 'c' apply plugin: 'eclipse' model { components { derpus(NativeExecutableSpec) { sources { c(CSourceSet) { source { srcDir "src/derpus/c" include "**/*.c" } exportedHeaders { srcDir "src/derpus/headers" } } } } } } task wrapper(type: Wrapper) { gradleVersion = '2.3' }
This allowed me to run gradle wrapper without any errors.
Next, I started very strange that the Gradle Native Binaries documentation never mentions a build call to compile / create your own executables. I figured it could be using the Gradle "configuration agreement" approach, and I ran gradlew build - voila! Big success. Now under derpus/build/binaries/derpusExecutable I have derpus.exe ! So far so good.
The real headache comes when you want to import this Gradle project into Eclipse, but still the Eclipse CDT has all the usual features of a modern C IDE.
I started by running gradlew eclipse , which added the following files to the root of the derpus/ project:
.project.settings/language.settings
I opened Eclipse and imported it as a project, however I had all kinds of errors, and when I hung over #include <stdio.h> in the derpus.c file and pressed F3 , Eclipse did nothing. Obviously, something is still not configured correctly. And so I had to hack.
Turns out you just need to:
- Of course, first make sure the CDT plugin is installed and working correctly (doh!)
- Create a "dummy" C project in Eclipse that allows you to copy n 'paste the Eclipse CDT-created settings / configs into your actual project
- Modify the actual
.project file to include the same <buildSpec /> and <natures /> elements that were generated in the .project file's .project file - Copy the dummy project
.cproject to your actual project root, and then open it in a text editor. You want to rename ALL instances of the name of the dummy project with the name of your actual project; in my case there were 3 cases. In my case, my dummy project was literally called dummy , and my actual project is called derpus . So I had to change 3 dummy instances to derpus in this file. - Restart Eclipse
Your actual project will now behave exactly like a C project created using the CDT plugin. Remember to delete the "dummy" project; -)