我有一个多项目结构,其中包含数十个同级项目以及不同的子项目,如下所示:
master/
proja/
|-- projaEAR
|-- projaJAR
projb/
|-- projb
|-- projbhelper
etc/
最终,我想在settings.gradle
中动态生成项目。但是,我在Windows上遇到了麻烦。引发此错误:
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
使用我当前的gradle
安装(v2.2.1),错误来自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)
这是我的设置:
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
如果我使用较新的gradle(v5.2.1),问题可能出在其他地方:
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
相同的简单设置在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
任何建议,不胜感激!
注意:交叉发布到Gradle Forum