Skip to content

Update settings.gradle to correct the behavior if creating a new subproject with default buildFile name #16387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,24 @@ buildFiles.each { File buildFile ->
boolean isKotlin = buildFile.name.endsWith(".kts")
if(isDefaultName) {
String buildFilePath = buildFile.parentFile.absolutePath
String projectPath = buildFilePath.replace(rootDirPath, '').replace(File.separator, ':')
include projectPath
String projectName = buildFilePath.tokenize(File.separator)[-1]
configureProject(':' + projectName, projectName, buildFile)
} else {
String projectName
if (isKotlin) {
projectName = buildFile.name.replace('.gradle.kts', '')
} else {
projectName = buildFile.name.replace('.gradle', '')
}
String projectPath = ':' + projectName;
include projectPath
def project = findProject("${projectPath}")
project.name = projectName
project.projectDir = buildFile.parentFile
project.buildFileName = buildFile.name
configureProject(':' + projectName, projectName, buildFile)
}
}

def configureProject(String projectPath, String projectName, File buildFile) {
include(projectPath)

def project = findProject(projectPath)
project.name = projectName
project.projectDir = buildFile.parentFile
project.buildFileName = buildFile.name
}
Loading