gradle - build.gradle 不是设置文件定义的构建的一部分

标签 gradle

我正在尝试构建 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'

我如何得到这个建立?

最佳答案

我有同样的问题。我看到没有答案,虽然我迟到了,但这可能对其他人有帮助。

从可用位置复制 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.

我复制了 settings.gradle文件来自 /Users/pradeepbehera/settings.gradle并粘贴在 /Users/pradeepbehera/Downloads/ud867-master/1.04-Demo-GroovyClosuresAndObjects .

然后它工作得很好。

关于gradle - build.gradle 不是设置文件定义的构建的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56293162/

相关文章:

android - 如何在 Gradle 中将产品 flavor 添加到版本名称

android - 构建.gradle : how to execute code only on selected flavor

gradle - Protobuf/ Guava 依赖性问题

android - 如何提取合并的proguard规则

android - 无法获取未知属性 ‘classesDir’ android studio

Android:跳过依赖项项目的 Gradle "testClasses"任务

gradle - 如何指定由 Gradle SonarQube 插件运行的测试任务

android - 找不到com.google.android.gms:oss-licenses-plugin:0.9.3

android - appcompat-v7 :28. 0.0-rc01 构建问题

java - 为什么我不能直接使用 Gradles Exec-task 启动 java?