[GRADLE-28] Add tasks for generating Eclipse files Created: 09/Apr/08  Updated: 04/Jan/13  Resolved: 28/Aug/08

Status: Resolved
Project: Gradle
Affects Version/s: 0.1
Fix Version/s: 0.4

Type: New Feature
Reporter: Hans Dockter Assignee: Hans Dockter
Resolution: Fixed Votes: 2

Attachments: File EclipsePlugin_1.groovy     File EclipsePlugin_2.groovy    
Issue Links:
Related
Related to GRADLE-112 Generate a Netbeans project for a gra... Resolved
Related to GRADLE-190 Add tasks for generating IntelliJ files Resolved

 Comments   
Comment by Pieter Smit [ 17/Jul/08 ]

I created a closure to update my eclipse .classpath file to reflect the current dependencies. Maybe this can help:

Closure updateClasspath = { task ->
File eclipseClasspathFile = task.project.file('.classpath')
if (!eclipseClasspathFile.exists())

{ eclipseClasspathFile.append ('<classpath></classpath>') }

ant.copy(file:eclipseClasspathFile, tofile:eclipseClasspathFile.toString() + ".old", overwrite:true)

def classpathXml = new XmlParser().parseText(eclipseClasspathFile.text)
eclipseClasspathFile.delete()

def currentEclipseLibs = classpathXml.classpathentry.findAll

{ it.'@kind'.equals('lib') }

currentEclipseLibs.each

{ classpathXml.remove (it) }

task.project.dependencies.resolve('compile') //vs runtime
for (f in task.project.dependencies.resolveCache.get('compile'))

{ classpathXml.appendNode('classpathentry', [kind:'lib', path:f.toString()]) }

}

fileWriter = task.project.file('.classpath')
new XmlNodePrinter(new PrintWriter(fileWriter)).print (classpathXml)
}

Comment by Phil Messenger [ 15/Aug/08 ]

A more comprehensive version of an eclipse plugin

Comment by Phil Messenger [ 15/Aug/08 ]

The file I've just attached takes the code submitted by Pieter Smit above and adds some additional features:

  • WTP project file generation in the case of a web project
  • support for sibling / child projects
Comment by Hans Dockter [ 18/Aug/08 ]

Hi Phil, I've just returned from my holidays. I'm very much looking forwards to looking at your contribution very soon.

Comment by Phil Messenger [ 18/Aug/08 ]

Hi Hans,

this is an updated version of the plugin with a few bug fixes. It's worth noting that at the moment this plugin doesn't generate the Eclipse ".project" file.

Couple of things to note

  • at the moment, WTP (that is Eclipses built in web development tooling) configuration files are generated if the "war" plugin is in use. This probably ought to be a configuration variable.
  • WTP supports the relocation of random source directories to a location under a web root. This is useful when you have configuration files in src/main/conf, but wish to have them deployed by WTP to WEB-INF/classes (so you can run your project in eclipse without needing to generate a war). At the moment this plugin looks for a map called "warResourceMappings" where the key is the source folder relative to project root and the value is the logical location

FWIW, I find the warResourceMappings map useful when actually generating a war:

warResourceMappings = ["src/conf" : "WEB-INF"]

archive_war {
	warResourceMappings.each { mapEntry ->
		zipFileSet( dir: project.file(mapEntry.key), prefix: mapEntry.value )
	}
}
Comment by Hans Dockter [ 28/Aug/08 ]

We submitted tasks for generating Eclipse files. I'm therefore closing this general issue. For the further work we will work with more fine grained issues. I have created a eclipse component for Jira which is supposed to be assigned to Eclipse related issues.

Generated at Wed Jun 30 11:20:12 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.