The referencedProjects doesn't help (at least it didn't help me). I tried that and I ended up with a
'project' element in the 'projects' element in the .project file. And it seemed to me that eclipse
doesn't care about that (Or maybe I did something wrong).
I tried by using 'withXml' but couldn't figure out how to use it, therefore I implemented some hack
as part of my personal plugin (where I set my download and upload repositories, and do some other
stuff common for all my projects).
I use standard groovy XmlSlurper to parse .classpath file, remove the corresponding jar files of the
linked projects, and add the project reference just after the last src entry.
All I need is (before any apply plugin) a property in my build file:
eclipseLinkToProjects = ['ProjectA', 'ProjectB']
And of course these projects must be present in my eclipse.
Note that I also set all classpath entries exported=false in my code, but that is just a personal
preference.
Here is the relevant code from my plugin (as I am quite new to groovy there's probably a lot which
could be written groovier):
if (project.hasProperty('eclipseLinkToProjects')) {
project.eclipseClasspath {
whenConfigured { classpath ->
classpath.entries.removeAll { entry ->
for (nextLinkedProject in eclipseLinkToProjects) {
if (entry.path ==~ ".*/$nextLinkedProject-.*(.jar|.zip)") {
return true }
}
}
classpath.entries.findAll { entry -> entry.kind == 'lib' || entry.kind == 'con'
}*.exported = false
}
}
project.eclipseClasspath.doLast {
def cpfile = new File('.classpath')
def root = new XmlSlurper().parse(cpfile)
def cpEntries = root.classpathentry
def indexOfSrc = cpEntries.list().reverse().findIndexOf {
it.attributes()['kind'] == 'src' }
def pos = cpEntries.size() - indexOfSrc - 1
root.classpathentry[pos] + {
for (nextLinkedProject in eclipseLinkToProjects) {
classpathentry(combineaccessrules:'false', kind:'src',
path:"/$nextLinkedProject")
}
}
cpfile.write(XmlUtil.serialize(new StreamingMarkupBuilder().bind {
mkp.yield root }))
}
}
Hope that helps a little,
Ruediger.
Am 16.06.2011 21:05, schrieb Szczepan Faber:
Would referencedProjects from
http://gradle.org/current/docs/dsl/org.gradle.plugins.ide.eclipse.GenerateEclipseProject.html
help somehow?
If not, then you can always hook up to the xml generation of the
.project file using 'withXml'
Cheers!
On Thu, Jun 16, 2011 at 6:00 PM, James Carr<[email protected]> wrote:
Is there anyway to hook into the eclipse plug-in and have it reference
other projects in the workspace if they are present?
Thanks,
James
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email