Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

gradle

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?

like image 934
jimboweb Avatar asked May 24 '19 12:05

jimboweb


People also ask

Where is gradle build defined?

It is located in the root project directory and its main function is to define the build configurations that will be applied to all the modules in the project. It is implemented as: Java.

Where is gradle settings file?

The global properties file should be located in your home directory: On Windows: C:\Users\<you>\. gradle\gradle.

Could not compile settings file '/ app settings gradle?

Solution. To solve this problem you need to open the project/android/settings. gradle file and have to replace the backslash(\) with the frontslash(/) as windows directory structure do not support the backslash(\).

What does settings gradle contain?

The main role of settings. gradle is to define all included submodules and to mark the directory root of a tree of modules, so you can only have one settings. gradle file in a multi-module project. The settings file is also written in groovy, and submodule lookup can be customized.


1 Answers

I was running into the exact same issue:

org.gradle.api.InvalidUserDataException: Project directory 'Users/Shared/myProject/theDirectory/src/test is not part of the build defined by settings file 'Users/Shared/myProject/theDirectory/settings.gradle.

The issue was I was running gradle from a terminal window that was based too far down in the directory structure.

The FIX: simply Change Directories in the terminal window cd ..

So for me I simply backed up to directory levels to: "myProject" folder and boom...simple gradle works.

like image 162
matthew_automater Avatar answered Sep 20 '22 10:09

matthew_automater