我正在尝试构建Gradle文件并收到错误Build file '.../build.gradle' is not part of the build defined by settings file '.../settings.gradle'. If this is an unrelated build, it must have it's own settings file.
这是我的build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.4.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
baseName = 'gs-securing-web'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-web")
// tag::security[]
compile("org.springframework.boot:spring-boot-starter-security")
// end::security[]
testCompile("junit:junit")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("org.springframework.security:spring-security-test")
}
这是我的settings.gradle:
/*
* This settings file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
* In a single project build this file can be empty or even removed.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user guide at https://docs.gradle.org/4.0/userguide/multi_project_builds.html
*/
/*
// To declare projects as part of a multi-project build use the 'include' method
include 'shared'
include 'api'
include 'services:webservice'
*/
rootProject.name = 'gs-securing-web'
如何构建它?
答案 0 :(得分:12)
我遇到了完全相同的问题:
org.gradle.api.InvalidUserDataException:项目目录'用户/共享/ myProject / theDirectory / src / test 不属于设置文件定义的版本' Users / Shared / myProject / theDirectory / settings.gradle。
问题是我是从终端目录运行gradle的,而该终端窗口的目录结构太低了。
FIX::只需在终端窗口cd ..
所以对我来说,我只是备份到目录级别:“ myProject”文件夹和繁荣...简单的gradle即可。
答案 1 :(得分:3)
最近我也遇到了同样的问题,这实际上使我想到了这个问题。
就我而言,我试图从错误的路径“ ../project/someFolder”构建罐子,并且将路径更正为“ ../project”。
答案 2 :(得分:1)
就我而言,我的项目没有 settings.gradle 文件,所以我继续按照此 documentation 创建了一个空文件:
<块引用>始终将 settings.gradle 添加到您构建的根目录以 避免初始性能影响。该建议适用于 单项目构建以及多项目构建。 文件可以 为空或定义所需的项目名称。
答案 3 :(得分:0)
我有同样的问题。我看不到答案,尽管我迟到了,这可能对其他人有帮助。
从可用位置复制settings.gradle文件,然后将其粘贴到所需位置。
就我而言,错误是-
* What went wrong:
Project directory '/Users/pradeepbehera/Downloads/ud867-master/1.04-Demo-GroovyClosuresAndObjects' is not part of the build defined by settings file '/Users/pradeepbehera/settings.gradle'. If this is an unrelated build, it must have its own settings file.
我从'/Users/pradeepbehera/settings.gradle'复制了settings.gradle文件,并粘贴到'/Users/pradeepbehera/Downloads/ud867-master/1.04-Demo-GroovyClosuresAndObjects'中。
然后就可以了。
答案 4 :(得分:0)
在大多数情况下,使用Deprecated Gradle features were used in your build.gradle, making it incompatible with the latest Gradle version your IDE
引用时会发生这种情况。
我花了将近半天的时间才能在Ubuntu OS的IntelliJ中找到解决此问题的解决方案。
最后偶然地找到了解决方案:
只需将Gradle版本设置为指向本地安装的版本,然后Gradle JVM在本地计算机上选择JDK的安装版本,就解决了我的问题
答案 5 :(得分:0)
就我而言,我必须从根路径中删除该文件。该文件不在我的项目中,这很奇怪。