Gradle Task does not create files as defined Buildhip 2.2

Hello together,

i use eclipse oxygen an try to create some files in my workspace in the ressources folder with a gradle task. Unfortunately my gradle tasks cannot add these files to my workspace if it is executed with buildship. It says “build successful” but no files are in the folder they should be. This seems to be an buildship issue because it works without any problem on idea or my commandline.

Does anybody have an idea how to fix this? Or at least know the cause of this issue?

Eclipse version: 4.6 to 4.7.1
Buildship version: 2.0 to 2.2.1

Thank you in advance

Can you please provide a reproducible example project?

I have to tell you, that this is a bug in our project.
Im really sorry for that. We investigated this bug about 3 weeks and didnt find the answer.
Yesterday we found it.
Thank you for response. Have a nice day.

Would you mind sharing what kind of bug it was? Maybe something we could detect and warn about?

Yes of course I try to explain it here - I think this could affect others as well:

We created a gradle task which exports some files from unix to any other system in the current working folder.
In case of using IDEA it worked - but with eclipse we got errors.
The reason for that seems to be that IDEA uses the workspace as base path but eclipse uses the installation dir. So relative path strings in eclipse (at least in our project) point to the eclipse installation folder instead of the workspace. We tried to export the file with absolute path by using the gradle “project.projectDir” variable. Since we use gradle SSH plugin for copying, this was just working on unix systems - Windows threw “MalformedUrlException” because the plugin uses URI strings and these (if it contains “C:”) were interpreted as protocol instead of path. If you exclusively use windows you can just add “file:///” as prefix to your URL and it works. But as a result the task fails on unix system.

Finally we fixed it by working with File objects instead of string path variables.
I hope this is understandable

Yes I see what you mean. Always use the Project.file() API when working with files. This will give you the right base directory.

1 Like