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?
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.
The global properties file should be located in your home directory: On Windows: C:\Users\<you>\. gradle\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(\).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With