Skip to content

Commit d4ea7a6

Browse files
committed
chore: buildconfig fixes
1 parent e7b46ff commit d4ea7a6

File tree

15 files changed

+242
-46
lines changed

15 files changed

+242
-46
lines changed

CHANGELOG.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Change Log
2+
3+
## [v0.8.2](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.8.2) (2023-07-29)
4+
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.8.1...v0.8.2)
5+
6+
7+
## [v0.8.1](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.8.1) (2023-07-29)
8+
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.8.0...v0.8.1)
9+
10+
11+
## [v0.8.0](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.8.0) (2023-07-29)
12+
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.7.8...v0.8.0)
13+
14+
15+
## [v0.7.8](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.7.8) (2023-07-23)
16+
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.7.7...v0.7.8)
17+
18+
19+
## [v0.7.7](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.7.7) (2023-07-21)
20+
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.7.6...v0.7.7)
21+
22+
23+
## [v0.7.6](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.7.6) (2023-07-21)
24+
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.7.5...v0.7.6)
25+
26+
27+
## [v0.7.5](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.7.5) (2023-07-11)
28+
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.7.1...v0.7.5)
29+
30+
31+
## [v0.7.1](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.7.1) (2023-07-06)
32+
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.7.0...v0.7.1)
33+
34+
35+
## [v0.7.0](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.7.0) (2023-07-03)
36+
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.6.0...v0.7.0)
37+
38+
39+
## [v0.6.0](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.6.0) (2023-07-03)
40+
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.5.0...v0.6.0)
41+
42+
**Merged pull requests:**
43+
44+
- chore\(deps\): bump dependabot/fetch\-metadata from 1.5.1 to 1.6.0 [\#13](https://github.com/sureshg/kotlin-mpp-playground/pull/13) ([@dependabot[bot]](https://github.com/apps/dependabot))
45+
46+
## [v0.5.0](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.5.0) (2023-06-21)
47+
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/dfffbe4cfab7b2f2a93db885ec8a139c960a4221...v0.5.0)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ $ ./gradlew createModuleGraph
4848

4949
# Misc
5050
$ ./gradlew checkBuildLogicBestPractices
51+
$ ./gradlew generateChangelog
5152
$ ./gradlew cleanAll
5253

5354
# GitHub Actions lint

common/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ dependencies {
3131
commonMainApi(libs.ktor.serialization.json)
3232
commonMainApi(libs.uri.kmp)
3333
commonMainApi(libs.ajalt.colormath)
34-
commonMainImplementation(libs.benasher44.uuid)
35-
commonMainImplementation(libs.intellij.markdown)
36-
commonMainImplementation(libs.kotlin.codepoints.deluxe)
37-
commonMainImplementation(libs.multiplatform.settings.core)
34+
commonMainApi(libs.benasher44.uuid)
35+
commonMainApi(libs.intellij.markdown)
36+
commonMainApi(libs.kotlin.codepoints.deluxe)
37+
commonMainApi(libs.multiplatform.settings.core)
3838

3939
jvmMainApi(libs.kotlin.retry)
4040
// jvmMainImplementation(libs.slf4j.api)

common/src/commonMain/kotlin/dev/suresh/Greeting.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Greeting {
2323
fun greeting() =
2424
"""
2525
| Platform : Kotlin $platform
26-
| Build Time (UTC) : ${BuildConfig.buildTimeUTC}
26+
| Build Time : ${BuildConfig.buildTimeLocal}
2727
| Build Version : ${BuildConfig.version}
2828
| Java Version : ${BuildConfig.java}
2929
| Kotlin Version : ${KotlinVersion.CURRENT}

common/src/commonMain/kotlin/dev/suresh/lang/Features.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import kotlin.io.encoding.Base64
22
import kotlin.jvm.JvmInline
3-
import kotlin.text.HexFormat
43
import kotlin.time.Duration.Companion.microseconds
54
import kotlin.time.TimeSource
65

gradle/build-logic/common-plugins/build.gradle.kts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ plugins {
1717
*/
1818
val dslJavaVersion = libs.versions.kotlin.dsl.jvmtarget
1919

20-
// java { toolchain { languageVersion = dslJavaVersion.map(JavaLanguageVersion::of) } }
21-
2220
tasks {
2321
withType<KotlinCompile>().configureEach {
2422
compilerOptions {
@@ -88,7 +86,7 @@ gradlePlugin {
8886
// Jte is used for generating build config.
8987
jte {
9088
contentType = gg.jte.ContentType.Plain
91-
sourceDirectory = sourceSets.main.get().resources.srcDirs.firstOrNull()?.toPath()
89+
sourceDirectory = sourceSets.main.map { it.resources.srcDirs.first().toPath() }
9290
generate()
9391
// jteExtension("gg.jte.models.generator.ModelExtension")
9492
// jteExtension("gg.jte.nativeimage.NativeResourcesExtension")
@@ -117,8 +115,8 @@ dependencies {
117115
implementation(libs.build.zip.prefixer)
118116
// Templating
119117
implementation(libs.jte.runtime)
120-
// jteGenerate(libs.jte.models)
121118
// compileOnly(libs.jte.kotlin)
119+
// jteGenerate(libs.jte.models)
122120

123121
// External plugins deps to use in precompiled script plugins
124122
// https://docs.gradle.org/current/userguide/custom_plugins.html#applying_external_plugins_in_precompiled_script_plugins
@@ -138,6 +136,7 @@ dependencies {
138136
implementation(libs.build.spotless.plugin)
139137
implementation(libs.build.shadow.plugin)
140138
implementation(libs.build.semver.plugin)
139+
implementation(libs.build.github.changelog)
141140
implementation(libs.build.benmanesversions)
142141
implementation(libs.build.dependencyanalysis)
143142
implementation(libs.build.cyclonedx.plugin)
@@ -146,8 +145,8 @@ dependencies {
146145
implementation(libs.build.modulegraph.plugin)
147146
implementation(libs.build.cash.molecule.plugin)
148147
implementation(libs.build.npm.publish.plugin)
148+
implementation(libs.build.mokkery.plugin)
149+
implementation(libs.build.jte.plugin)
149150
testImplementation(gradleTestKit())
150-
// implementation(libs.build.mokkery.plugin)
151-
// implementation(libs.build.jte.plugin)
152151
// implementation(libs.build.includegit.plugin)
153152
}

gradle/build-logic/common-plugins/src/main/kotlin/common/CommonExtns.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ val Long.compactFmt: String
2929
/** Converts a string to camelcase by splitting it by space, dash, underscore, or dot. */
3030
val String.camelCase: String
3131
get() =
32-
split("[. -_]".toRegex())
32+
split("""[.\-_ ]""".toRegex())
3333
.mapIndexed { idx, s -> if (idx == 0) s else s.replaceFirstChar { it.uppercaseChar() } }
3434
.joinToString("")
3535

gradle/build-logic/common-plugins/src/main/kotlin/common/KotlinExtns.kt

Lines changed: 123 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,16 @@ val Project.toolchainVendor
3636
val Project.addModules
3737
get() = libs.versions.java.addModules.get()
3838

39+
val Project.githubUser
40+
get() = libs.versions.dev.name.get().lowercase()
41+
42+
val Project.githubRepo
43+
get() = "https://github.com/${githubUser}/${rootProject.name}"
44+
3945
/**
4046
* Retrieves all JVM arguments for running (**java**) and compiling (**javac**) java/kotlin code..
4147
*
42-
* @param compile Flag indicating whether or not to include additional JVM arguments for compilation.
48+
* @param compile Flag indicating whether to include additional JVM arguments for compilation.
4349
* Defaults to false.
4450
* @return A list of JVM arguments for the project.
4551
*/
@@ -53,6 +59,120 @@ fun Project.jvmArguments(compile: Boolean = false) = buildList {
5359
}
5460
}
5561

62+
// $ java -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal
63+
// --version
64+
// https://docs.oracle.com/en/java/javase/21/docs/specs/man/java.html
65+
// https://docs.oracle.com/en/java/javase/21/core/java-networking.html#GUID-E6C82625-7C02-4AB3-B15D-0DF8A249CD73
66+
// https://cs.oswego.edu/dl/jsr166/dist/jsr166.jar
67+
// https://chriswhocodes.com/hotspot_options_openjdk21.html
68+
// https://sap.github.io/SapMachine/jfrevents
69+
70+
val Project.cc get() = listOf(
71+
"--show-version",
72+
"--enable-preview",
73+
"--add-modules=$addModules",
74+
"--enable-native-access=ALL-UNNAMED",
75+
"-XshowSettings:vm",
76+
"-XshowSettings:system",
77+
"-XshowSettings:properties",
78+
"-Xmx96M",
79+
"-XX:+PrintCommandLineFlags",
80+
"-XX:+UseZGC",
81+
"-XX:+ZGenerational",
82+
"-XX:+UseCompressedOops",
83+
"-XX:+UnlockExperimentalVMOptions",
84+
// os+thread,gc+heap=trace,
85+
"""-Xlog:cds,safepoint,gc*:
86+
|file="$tmp$name-gc-%p-%t.log":
87+
|level,tags,time,uptime,pid,tid:
88+
|filecount=5,
89+
|filesize=10m"""
90+
.joinToConfigString(),
91+
"""-XX:StartFlightRecording=
92+
|filename=$tmp$name.jfr,
93+
|name=$name,
94+
|maxsize=100M,
95+
|maxage=1d,
96+
|path-to-gc-roots=true,
97+
|dumponexit=true,
98+
|memory-leaks=gc-roots,
99+
|gc=detailed,
100+
|+jdk.VirtualThreadStart#enabled=true,
101+
|+jdk.VirtualThreadEnd#enabled=true,
102+
|jdk.ObjectCount#enabled=true,
103+
|jdk.SecurityPropertyModification#enabled=true,
104+
|jdk.TLSHandshake#enabled=true,
105+
|jdk.X509Certificate#enabled=true,
106+
|jdk.X509Validation#enabled=true,
107+
|settings=profile"""
108+
.joinToConfigString(),
109+
"-XX:FlightRecorderOptions:stackdepth=64",
110+
"-XX:+HeapDumpOnOutOfMemoryError",
111+
"-XX:HeapDumpPath=$tmp$name-%p.hprof",
112+
"-XX:ErrorFile=$tmp$name-hs-err-%p.log",
113+
"-XX:OnOutOfMemoryError='kill -9 %p'",
114+
"-XX:+ExitOnOutOfMemoryError",
115+
"-XX:+UnlockDiagnosticVMOptions",
116+
"-XX:NativeMemoryTracking=detail",
117+
"-XX:+EnableDynamicAgentLoading",
118+
"-XX:+LogVMOutput",
119+
"-XX:LogFile=$tmp$name-jvm.log",
120+
"-Djava.awt.headless=true",
121+
"-Djdk.attach.allowAttachSelf=true",
122+
"-Djdk.traceVirtualThreadLocals=false",
123+
"-Djdk.tracePinnedThreads=full",
124+
"-Djava.security.debug=properties",
125+
"-Djava.security.egd=file:/dev/./urandom",
126+
"-Djdk.includeInExceptions=hostInfo,jar",
127+
"-Dkotlinx.coroutines.debug",
128+
"-ea",
129+
// "--show-module-resolution",
130+
// "-XX:+ShowHiddenFrames",
131+
// "-XX:+AutoCreateSharedArchive",
132+
// "-XX:SharedArchiveFile=$tmp/$name.jsa"
133+
// "-verbose:module",
134+
// "-XX:ConcGCThreads=2",
135+
// "-XX:ZUncommitDelay=60",
136+
// "-XX:VMOptionsFile=vm_options",
137+
// "-Xlog:gc\*",
138+
// "-Xlog:class+load=info,cds=debug,cds+dynamic=info",
139+
// "-XX:+IgnoreUnrecognizedVMOptions",
140+
// "-XX:MaxRAMPercentage=0.8",
141+
// "-XX:+StartAttachListener", // For jcmd Dynamic Attach Mechanism
142+
// "-XX:+DisableAttachMechanism",
143+
// "-XX:+DebugNonSafepoints",
144+
// "-XX:OnOutOfMemoryError="./restart.sh"",
145+
// "-XX:SelfDestructTimer=0.05",
146+
// "-XX:NativeMemoryTracking=[off|summary|detail]",
147+
// "-XX:+PrintNMTStatistics",
148+
// "-XX:OnError=\"gdb - %p\"", // Attach gdb on segfault
149+
// "-Djava.security.properties=/path/to/custom/java.security", // == to override
150+
// "-Duser.timezone=\"PST8PDT\"",
151+
// "-Djava.net.preferIPv4Stack=true",
152+
// "-Djavax.net.debug=all",
153+
// "-Dhttps.protocols=TLSv1.2",
154+
// "-Dhttps.agent=$name",
155+
// "-Dhttp.keepAlive=true",
156+
// "-Dhttp.maxConnections=5",
157+
// "-Djava.security.manager=allow",
158+
// "-Dfile.encoding=COMPAT", // uses '-Dnative.encoding'
159+
// "-Djdbc.drivers=org.postgresql.Driver",
160+
// "-Djava.io.tmpdir=/var/data/tmp",
161+
// "-Djava.locale.providers=COMPAT,CLDR",
162+
// "-Djdk.lang.Process.launchMechanism=vfork",
163+
// "-Djdk.tls.maxCertificateChainLength=10",
164+
// "-Djdk.tls.maxHandshakeMessageSize=32768",
165+
// "--add-exports=java.management/sun.management=ALL-UNNAMED",
166+
// "--add-exports=jdk.attach/sun.tools.attach=ALL-UNNAMED",
167+
// "--add-opens=java.base/java.net=ALL-UNNAMED",
168+
// "--add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED",
169+
// "--patch-module java.base="$DIR/jsr166.jar",
170+
// "-javaagent:path/to/glowroot.jar",
171+
// "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005",
172+
// "-agentlib:jdwp=transport=dt_socket,server=n,address=host:5005,suspend=y,onthrow=<FQ
173+
// exception class name>,onuncaught=<y/n>"
174+
)
175+
56176
/** Kotlin version properties. */
57177
val Project.kotlinVersion
58178
get() = libs.versions.kotlin.asProvider()
@@ -303,6 +423,7 @@ fun KotlinDependencyHandler.kspDependency(
303423
)
304424
}
305425

426+
306427
/** Returns the path of the dependency jar in runtime classpath. */
307428
context(Project)
308429
val ExternalDependency.dependencyPath get() = configurations
@@ -315,6 +436,7 @@ val ExternalDependency.dependencyPath get() = configurations
315436
?.path
316437
?: error("Could not find $name in runtime classpath")
317438

439+
318440
/** Returns the application `run` command. */
319441
context(Project)
320442
fun Path.appRunCmd(args: List<String>): String {

gradle/build-logic/common-plugins/src/main/kotlin/plugins/kotlin.docs.gradle.kts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package plugins
22

3+
import common.githubRepo
4+
import common.githubUser
35
import common.kotlinJvmTarget
4-
import common.libs
56
import java.net.URI
67
import kotlinx.validation.ApiValidationExtension
8+
import org.gradle.kotlin.dsl.*
9+
import org.hildan.github.changelog.plugin.GitHubChangelogExtension
710
import org.jetbrains.dokka.DokkaConfiguration.Visibility
811
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
912
import org.jetbrains.dokka.gradle.DokkaTaskPartial
@@ -16,6 +19,7 @@ plugins {
1619

1720
// The following plugins and config apply only to a root project.
1821
if (project == rootProject) {
22+
apply(plugin = "org.hildan.github.changelog")
1923
apply(plugin = "org.jetbrains.kotlinx.binary-compatibility-validator")
2024

2125
// For combined Kotlin coverage report
@@ -28,12 +32,14 @@ if (project == rootProject) {
2832
}
2933
}
3034

31-
// Configure bin-compat validator.
35+
// Configure if the plugin is applied to the project.
3236
plugins.withId("org.jetbrains.kotlinx.binary-compatibility-validator") {
3337
extensions.configure<ApiValidationExtension>("apiValidation") { validationDisabled = true }
3438
}
3539

36-
// pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {}
40+
plugins.withId("org.hildan.github.changelog") {
41+
the<GitHubChangelogExtension>().run { githubUser = project.githubUser }
42+
}
3743

3844
tasks {
3945
withType<DokkaTaskPartial>().configureEach {
@@ -50,7 +56,7 @@ tasks {
5056

5157
sourceLink {
5258
localDirectory = rootProject.projectDir
53-
remoteUrl = libs.versions.publish.scm.url.map { URI("$it/tree/main").toURL() }
59+
remoteUrl = URI("${githubRepo}/tree/main").toURL()
5460
remoteLineSuffix = "#L"
5561
}
5662

gradle/build-logic/common-plugins/src/main/kotlin/plugins/kotlin.jvm.gradle.kts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,13 @@ dependencies {
150150
// outgoing.artifact(shadowJar.flatMap {it.archiveFile})
151151
// }
152152
// }
153+
154+
allprojects {
155+
configurations.all {
156+
resolutionStrategy.eachDependency {
157+
if (requested.name.contains("intellij-coverage")) {
158+
// useVersion(libs.versions.intellij.coverage.get())
159+
}
160+
}
161+
}
162+
}

0 commit comments

Comments
 (0)