build.gradle is not part of the build defined by settings file

烈酒焚心 提交于 2020-04-13 17:21:05

问题


I'm trying to build a Gradle file and getting the error 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.

Here is my 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")
}

Here is my 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'

How do I get this to build?


回答1:


I had same issue. I see there is no answer, though I'm late, this might be helpful for others.

Copy the settings.gradle file from the available location and paste it and needed location.

In my case Error was -

* 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.

I copied settings.gradle file from /Users/pradeepbehera/settings.gradle and pasted at /Users/pradeepbehera/Downloads/ud867-master/1.04-Demo-GroovyClosuresAndObjects.

Then it worked just fine.




回答2:


I also encountered the same problem recently which actually brought me to this question.

In my case, I was trying to build the jar from the wrong path '../project/someFolder' and I corrected my path to '../project'.



来源:https://stackoverflow.com/questions/56293162/build-gradle-is-not-part-of-the-build-defined-by-settings-file

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