[GRADLE-1209] Use 'sourceSets.main.classesDir' (if present) as the default output dir of the Eclipse classpath Created: 05/Nov/10 Updated: 04/Jan/13 Resolved: 24/Nov/10 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 0.9 |
Fix Version/s: | 0.9-rc-3 |
Type: | Improvement | ||
Reporter: | Andrew Phillips | Assignee: | Hans Dockter |
Resolution: | Fixed | Votes: | 0 |
Description |
Currently, the Eclipse classpath always contains 'bin' as the default output folder, even if no files are actually compiled to there (e.g. sourceSets.main is compiled into 'build/classes/main' etc.) This means that Eclipse will actually not even create the 'bin' folder, so if this is a Java or JVM project the classpath will contain an entry that does not exist. Whilst this is not uncommon, some tools like Scannotation [1] fall over here. The following commit makes the default output dir of the Eclipse classpath an optional parameter to Classpath.groovy. The default value is still 'bin', but if there is a 'main' source set the value 'sourceSets.main.classesDir' is used instead. This should cover Java projects whilst maintaining existing functionality for others. https://github.com/demobox/gradle/commit/a5ac21e3ae1e363561a10784fdb0ebafd14681e4 Please let me know (demobox1 [at] yahoo [dot] co [dot] uk) if a pull request from my fork would be useful. @Hans: I've spoken to Adam about this on IRC, so if there are any questions he should know a bit more. [1] http://sourceforge.net/projects/scannotation/ |
Comments |
Comment by Andrew Phillips [ 05/Nov/10 ] |
Until this is implemented the following workaround does the job:} afterEvaluate { eachProject -> eachProject.tasks.withType(EclipseClasspath).each { task -> task.configure { // replace the (incorrect!) default bin output with the correct entry beforeConfigured { classpath -> removeMatching(classpath.entries, { entry -> entry.kind == 'output' && entry.path == 'bin' }) classpath.entries.add(new org.gradle.plugins.eclipse.model.Output( eachProject.relativePath(sourceSets.main.classesDir))) } } } } def removeMatching(collection, filter) { collection.removeAll(collection.findAll(filter)) } |
Comment by Adam Murdoch [ 08/Nov/10 ] |
This has been applied. Thank you for the patch. |