-
-
Notifications
You must be signed in to change notification settings - Fork 77
/
settings.gradle.kts
108 lines (96 loc) · 3.23 KB
/
settings.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import me.champeau.gradle.igp.gitRepositories
import org.eclipse.jgit.api.Git
import java.io.FileInputStream
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardCopyOption
import java.util.Properties
rootProject.name = "Dicio"
include(":app")
include(":skill")
// we use includeBuild here since the plugin is a compile-time dependency
includeBuild("sentences-compiler-plugin")
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
// not using version catalog because it is not available in settings.gradle.kts
id("me.champeau.includegit") version "0.1.6"
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
// All of the code below handles depending on libraries from git repos, in particular dicio-numbers,
// dicio-skill and dicio-sentences-compiler. The git commits to checkout can be updated here.
// If you want to use a local copy of the projects (provided that you have cloned them in
// `../dicio-*`), you can add `useLocalDicioLibraries=true` in `local.properties`.
data class IncludeGitRepo(
val name: String,
val uri: String,
val projectPath: String,
val commit: String,
)
val includeGitRepos = listOf(
IncludeGitRepo(
name = "dicio-numbers",
uri = "https://github.com/Stypox/dicio-numbers",
projectPath = ":numbers",
commit = "55f027debf0b44cb71a431b1ab927de6df2eefcc",
),
IncludeGitRepo(
name = "dicio-sentences-compiler",
uri = "https://github.com/Stypox/dicio-sentences-compiler",
projectPath = ":sentences_compiler",
commit = "7d83fe5a3d6dff2fc81b5c40783a1d82ada293d3",
),
)
val localProperties = Properties().apply {
try {
load(FileInputStream(File(rootDir, "local.properties")))
} catch (e: Throwable) {
println("Warning: can't read local.properties: $e")
}
}
if (localProperties.getOrDefault("useLocalDicioLibraries", "") == "true") {
for (repo in includeGitRepos) {
includeBuild("../${repo.name}") {
dependencySubstitution {
substitute(module("git.included.build:${repo.name}"))
.using(project(repo.projectPath))
}
}
}
} else {
// if the repo has already been cloned, the gitRepositories plugin is buggy and doesn't
// fetch the remote repo before trying to checkout the commit (in case the commit has changed),
// so we need to do it manually
for (repo in includeGitRepos) {
val file = File("$rootDir/checkouts/${repo.name}")
if (file.isDirectory) {
Git.open(file).fetch().call()
}
}
gitRepositories {
for (repo in includeGitRepos) {
include(repo.name) {
uri.set(repo.uri)
commit.set(repo.commit)
autoInclude.set(false)
includeBuild("") {
dependencySubstitution {
substitute(module("git.included.build:${repo.name}"))
.using(project(repo.projectPath))
}
}
}
}
}
}