Using relative path for location in eclipse plugin


(triv gattu) #1

Hi, i am using eclipse plugin in gradle to configure .project file.
something like this in my root .gradle file

eclipse {
classpath {
defaultOutputDir = file(‘abc’)
}
project {
linkedResource name: ‘source-java’, type: ‘2’, location: 'test/source/java’
linkedResource name: ‘java’, type: ‘2’, location: 'source/java’
linkedResource name: ‘looseClasses’, type: ‘2’, location: ‘…/./abc’
}
}

I am trying to see if i can get the location of path using relative paths. But it is not finding the location. When i use the absolute path, i will work fine though. Any suggestions on how to use here?


(Stefan Oehme) #2

Linked resources in Eclipse don’t support relative paths like “…/”. They only support absolute paths or relativizing against a path variable. So you could for instance use the built-in variable PROJECT_LOC


(triv gattu) #3

Thanks for quick response Stefan. I kinda figured that out, but, when i used and run eclipse task from command line, i see the expected results. But, when i import that project using gradle buildship plugin to eclipse, those .project and .classpath files are overridden. And won’t have my settings.
I have another question as well, when i tried to build from gradle tasks, the build folder which i set in gradle file inside eclipse{project{}} block, it will not take folder which i set.
whereas, eclipse build(make) will do as expected.


(Stefan Oehme) #4

Can you provide us with a small example project to reproduce the problem?

That’s expected, this is the output folder for Eclipse, not for Gradle. Eclipse works differently from Gradle (different compiler, Eclipse mixes resources amd classes) so using the same folder could break your build.


(triv gattu) #5

Sorry, for some reason, my eclipse was overwriting the descriptors generated by eclipse plugin in gradle file.
when i cleaned up eclipse workspace and imported all over again, it is working fine now.
So, about the build folder thing, you do not want the gradle build task and eclipse build set to same build directory?


(Stefan Oehme) #6

Exactly, they are completely different tools, handling this directory differently. Using the same would lead to problems.


(triv gattu) #7

got it. Thanks Stefan.