-
Notifications
You must be signed in to change notification settings - Fork 3
/
settings.gradle.kts
162 lines (139 loc) · 5.75 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2015-2021 Andre White.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.nio.file.Files
import java.nio.file.Paths
rootProject.name = "ddo-calc-parent"
pluginManagement {
// Scala
// Coverage
val scoveragePluginVersion: String by settings
// Avro
val avroHuggerPluginVersion: String by settings
val openApiGeneratorPluginVersion: String by settings
// val kordampGradlePluginVersion: String by settings
// val semVerPluginVersion: String by settings
val mooltiverseNyxPluginVersion: String by settings
val foojayResolverPluginVersionversion: String by settings
plugins {
id("com.github.hierynomus.license") version "0.16.1"
id("com.zlad.gradle.avrohugger") version avroHuggerPluginVersion
// id("com.chudsaviet.gradle.avrohugger") version avroHuggerPluginVersion
id("org.openapi.generator") version openApiGeneratorPluginVersion
id("org.scoverage") version scoveragePluginVersion
id("com.mooltiverse.oss.nyx") version mooltiverseNyxPluginVersion
id("org.gradle.toolchains.foojay-resolver-convention") version foojayResolverPluginVersionversion
// id("org.kordamp.gradle.project") version kordampGradlePluginVersion
// id("net.thauvin.erik.gradle.semver") version semVerPluginVersion
id("ru.vyarus.mkdocs") version "3.0.0"
id("io.quarkus") version "3.3.3"
id("org.sonarqube") version "4.3.1.3277"
}
repositories {
gradlePluginPortal()
mavenCentral()
}
}
plugins {
id("com.mooltiverse.oss.nyx")
id("org.gradle.toolchains.foojay-resolver-convention")
}
enableFeaturePreviewQuietly("TYPESAFE_PROJECT_ACCESSORS", "Type-safe project accessors")
/**
* @see <a href="https://github.com/gradle/gradle/issues/19069">Feature request</a>
*/
fun Settings.enableFeaturePreviewQuietly(
name: String,
summary: String,
) {
enableFeaturePreview(name)
val logger: Any =
org.gradle.util.internal.IncubationLogger::class.java
.getDeclaredField("INCUBATING_FEATURE_HANDLER")
.apply { isAccessible = true }
.get(null)
@Suppress("UNCHECKED_CAST")
val features: MutableSet<String> =
org.gradle.internal.featurelifecycle.LoggingIncubatingFeatureHandler::class.java
.getDeclaredField("features")
.apply { isAccessible = true }
.get(logger) as MutableSet<String>
features.add(summary)
}
// at some point in the future, see if we can safely make this property optional so there is no build warning if it is
// not specified or create a sensible default
val projectFolderDelimiter: String by settings
@Suppress("CUSTOM_GETTERS_SETTERS")
val projectFolders: List<String>
get() = settings.extra["projectFolders"]?.toString()?.split(projectFolderDelimiter) ?: listOf()
logger.info("checking $projectFolders for sub-projects")
/**
* reads the first part of a string up to the "."
* should be an Extension, but can not inline compile as one in settings.gradle.kts
*
* so we're doing a quick one off verses polluting a buildSrc, um... further
*
* @param str the string to parse
* @return the first part of the string
*/
fun readFirstPart(str: String): String = str.split(".").first()
logger.info("checking ${projectFolders.size} project folders")
projectFolders.forEach { dirName ->
val directory = Paths.get("$rootDir/$dirName")
if (Files.notExists(directory)) {
logger.warn("$directory does not exist, creating")
Files.createDirectory(directory)
}
Files.find(
directory,
Integer.MAX_VALUE,
{ _: java.nio.file.Path, attributes: java.nio.file.attribute.BasicFileAttributes ->
attributes.isDirectory
},
).use { dir ->
dir.forEach { dr ->
val customName = dr.toFile().name
// ({{f,s -> true}})
val files =
dr.toFile()
.listFiles { _, str -> str.matches(Regex("($customName|build)\\.gradle(\\.kts)?")) }
if (files?.isEmpty() != true) {
if (files!!.size != 1) {
logger.warn("Multiple build files located in project directory $dr")
}
val projectDir = rootDir.toPath().relativize(dr)
val first = files.first()
val buildFileName = first.name
// build file name may be arbitrary but usually follows either build or the directory name.
// since we're mostly controlling the build we'll assume the containing folders' name.
val projectName = first.parentFile.name
logger.info("Including Project:$projectName \tprojectDir: $projectDir \tBuildFile: $buildFileName")
include(projectName)
project(":$projectName").projectDir = projectDir.toFile()
project(":$projectName").buildFileName = buildFileName
}
}
}
}
if (System.getenv("enableCompositeBuild") == "true") {
logger.info("Adding included builds")
file("examples").listFiles()?.filter { ft -> ft.isDirectory }?.forEach { moduleBuild: File ->
includeBuild(moduleBuild)
}
}
includeBuild("build-logic")
// includeBuild("include/ddo-avro")