Visual Studio C++ gradle build and long filenames

I have a gradle C++ multi-project build, but am getting the following error from Visual Studio when trying to compile on our build server:

’…\myFile.obj" exceeds windows path limitation of 260 character.

Indeed the path is longer than 260 characters, which is a problem caused by a number of things:

  • the default location of our Jenkins workspace directory
  • the length of the project name (25 chars)
  • the length of the subdirectories that Gradle uses within the build directory for the object files

Is there any way to change the third of these? Or is there a solution that gets around the limitation somehow?