2

Originally, gradle windows java.io.IOException: CreateProcess error=206, filename is too long was a great solution. However, with gradle 5:

CollectionUtils.join(File.pathSeparator, classpath.getFiles())

fails with

 unknown property 'CollectionUtils' type org.gradle.api.tasks.testing.Test

What would be a suitable fix for gradle 5.0?

At least for me: https://github.com/viswaramamoorthy/gradle-util-plugins/ also fails with the same error on gradle 5.0

Georg Heiler
  • 16,916
  • 36
  • 162
  • 292

3 Answers3

1

You can use external libraries in gradle buildscript.

example:

buildscript {
   repositories {
      mavenCentral()
   }
   dependencies {
      // this dependency will be used in gradle build script.
      classpath 'org.apache.commons:commons-lang3:3.8.1'
   }
}
//and use it like this in Your tasks
org.apache.commons.lang3.StringUtils.join(configurations.testRuntime,File.pathSeparator)

I am not sure if this will fix your issue though, but You can try other libraries like this also.

miskender
  • 7,460
  • 1
  • 19
  • 23
  • Intersting idea. However, this fails with: `> Cannot change dependencies of configuration ':module-name:compile' after it has been included in dependency resolution.` – Georg Heiler Dec 01 '18 at 11:51
  • It looks like its related to your project configuration ( or where You use it) You can try this approach on a simple project to see If it is suitable for you. – miskender Dec 01 '18 at 12:18
  • Indeed, it is a multi module project. Do you have an idea how to get it to work in a multi module setup? – Georg Heiler Dec 01 '18 at 12:33
1

The following is for build.gradle file.

buildscript {
    dependencies {
        classpath "gradle.plugin.ua.eshepelyuk:ManifestClasspath:1.0.0"
    }
}

apply plugin: "ua.eshepelyuk.ManifestClasspath"`
0

looks like it work after some tweaking

doFirst {
            if (org.apache.commons.lang.SystemUtils.IS_OS_WINDOWS) {
                def cp = org.gradle.util.CollectionUtils.join(File.pathSeparator, classpath.getFiles())
                environment 'CLASSPATH', cp
                classpath = classpath.filter { false }
            }
        }
Georg Heiler
  • 16,916
  • 36
  • 162
  • 292