Different subproject behavior between Windows 10 and Linux

I have a multi-project structure with dozens of sibling projects with various subprojects, something like this:

master/
proja/
 |-- projaEAR
 |-- projaJAR
projb/
 |-- projb
 |-- projbhelper
etc/

Ultimately, I want to dynamically generate the projects in settings.gradle. However, I’m having trouble on Windows. It is throwing this error:

java.io.IOException: The filename, directory name, or volume label syntax is incorrect

Using my current gradle installation (v2.2.1), the error comes from GfFileUtils.java:

Caused by: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
    at org.gradle.util.GFileUtils.canonicalise(GFileUtils.java:222)

Here is my setup:

C:\TEMP\gradle_test\master>dir /b /ad /s ..
C:\TEMP\gradle_test\foo
C:\TEMP\gradle_test\master
C:\TEMP\gradle_test\foo\foo
C:\TEMP\gradle_test\foo\proja
C:\TEMP\gradle_test\foo\projb
C:\TEMP\gradle_test\master>type settings.gradle
includeFlat "foo:foo", "foo:proja", "foo:projb"
C:\TEMP\gradle_test\master>gradle -s projects

FAILURE: Build failed with an exception.

* Where:
Settings file 'C:\TEMP\gradle_test\master\settings.gradle' line: 1

* What went wrong:
A problem occurred evaluating settings 'master'.
> java.io.IOException: The filename, directory name, or volume label syntax is incorrect

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating settings 'master'.
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
<snip>
        ... 45 more
Caused by: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
        at org.gradle.util.GFileUtils.canonicalise(GFileUtils.java:222)
        ... 54 more

If I use a newer gradle (v5.2.1) the problem comes from somewhere else:

C:\TEMP\gradle_test\master>c:\apps\gradle-5.2.1\bin\gradle -s projects

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':foo:foo'.
> The project name 'foo:foo' must not contain any of the following characters: [/, \, :, <, >, ", ?, *, |]. Set the 'rootProject.name' or adjust the 'include' statement (see https://docs.gradle.org/5.2.1/dsl/org.gradle.api.initialization.Settings.html#org.gradle.api.initialization.Settings:include(java.lang.String[]) for more details).

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':foo:foo'.
<snip>
Caused by: org.gradle.api.InvalidUserDataException: The project name 'foo:foo' must not contain any of the following characters: [/, \, :, <, >, ", ?, *, |]. Set the 'rootProject.name' or adjust the 'include' statement (see https://docs.gradle.org/5.2.1/dsl/org.gradle.api.initialization.Settings.html#org.gradle.api.initialization.Settings:include(java.lang.String[]) for more details).
        at org.gradle.util.NameValidator.newInvalidUserDataException(NameValidator.java:45)
        at org.gradle.util.NameValidator.validate(NameValidator.java:38)
        at org.gradle.api.internal.project.ProjectFactory$1.execute(ProjectFactory.java:62)
        at org.gradle.api.internal.project.ProjectFactory$1.execute(ProjectFactory.java:59)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:91)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:80)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:230)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:149)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
        at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:324)
        at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:234)
        at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:140)
        at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
        at com.sun.proxy.$Proxy30.beforeEvaluate(Unknown Source)
        at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyBeforeEvaluate.run(LifecycleProjectEvaluator.java:157)
        ... 112 more

The same simple setup works fine on Linux:

[tomcat@cskpcloudxn2133 master]$ find .. -type d
..
../foo
../foo/proja
../foo/foo
../foo/projb
../master
[tomcat@cskpcloudxn2133 master]$ cat settings.gradle
includeFlat "foo:foo", "foo:proja", "foo:projb"
[tomcat@cskpcloudxn2133 master]$ /apps/gradle-2.2.1/bin/gradle projects
:projects

------------------------------------------------------------
Root project
------------------------------------------------------------

Root project 'master'
+--- Project ':foo:foo'
+--- Project ':foo:proja'
\--- Project ':foo:projb'

To see a list of the tasks of a project, run gradle <project-path>:tasks
For example, try running gradle :foo:foo:tasks

BUILD SUCCESSFUL

Total time: 3.488 secs

Any suggestions, greatly appreciated!

Andy

Note: Cross-posted to Stack Overflow

You should use include instead of includeFlat. The former will interpret foo:bar as the directory bar inside a directory foo inside next to the root project directory, the latter one will interpret it as the directory named foo:bar directly inside the root project directory.

In Windows file and directory names must never contain a : character, in Linux such a directory name is possible. That’s why this fails on Windows while it succeeds on Linux.

1 Like