问题
When the name of a current directory starts with a '.'
(e.g. /home/you/.gproject
),
gradle build
returns
The project name
.gproject
starts or ends with a'.'
. This has been deprecated and is scheduled to be removed in Gradle 5.0. Set therootProject.name
or adjust theinclude
statement (see https://docs.gradle.org/4.3/dsl/org.gradle.api.initialization.Settings.html#org.gradle.api.initialization.Settings:include(java.lang.String[]) for more details).
How can I fix it? Should I avoid such names (starting with a '.'
)?
If I put such a name in settings.gradle
, the same error shows up.
回答1:
The simple answer: You should not use project directories starting with a dot, because for Unix-based systems any files and folders starting with a dot are hidden by default. Since Gradle aims to be platform-independent, it may happen that your project is used on such a system and some project directories are not shown to the user.
However, you can use code like in the following example to change the project names in Gradle to something different than their project directories:
rootProject.name = 'root'
include 'sub'
project(':sub').projectDir = file('.sub')
This way, you can satisfy the Gradle rule for project names and still use project directories starting with a dot.
来源:https://stackoverflow.com/questions/48375733/gradle-project-name-starting-with-a