Gradle project name starting with a '.'

人走茶凉 提交于 2021-01-27 18:12:32

问题


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 the rootProject.name or adjust the include 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!