-
Notifications
You must be signed in to change notification settings - Fork 61
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
Metric overhaul #1504
Metric overhaul #1504
Changes from 7 commits
64d23c6
902e8f7
8f869f4
544a3c4
50a79be
da915cc
4b7ee93
410bbd4
2c861cf
73501df
7dcf74c
ddad510
27da2a0
0cb3003
cb866a6
5351adb
18aaa89
cb61636
6b51f79
471a9bb
cd59445
34f2882
01e10a1
9f9a301
d4b65d6
aff72ae
a22da77
a3598de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
* limitations under the License. | ||
*/ | ||
import kotlin.text.toBoolean | ||
import java.io.ByteArrayOutputStream | ||
|
||
plugins { | ||
kotlin("jvm") | ||
|
@@ -93,22 +94,37 @@ sourceSets { | |
java.srcDir(versionDirectory) | ||
} | ||
} | ||
tasks.create("pluginVersion") { | ||
val outputDir = file(versionDirectory) | ||
|
||
// Task to fetch core version from dependency.list from core submodule | ||
tasks.create("coreVersion", Exec::class.java) { | ||
workingDir = project.file(listOf("..", "external", "core").joinToString(File.separator)) | ||
commandLine = listOf("grep", "^VERSION", "dependencies.list") | ||
standardOutput = ByteArrayOutputStream() | ||
doLast { | ||
extra["output"] = standardOutput.toString().trim().split("=")[1] | ||
} | ||
} | ||
|
||
// Task to generate gradle plugin runtime constants for SDK and core versions | ||
tasks.create("versionConstants") { | ||
val outputDir = file(versionDirectory) | ||
inputs.property("version", project.version) | ||
outputs.dir(outputDir) | ||
|
||
dependsOn(tasks["coreVersion"]) | ||
doLast { | ||
val versionFile = file("$outputDir/io/realm/kotlin/gradle/version.kt") | ||
val coreVersion = (tasks["coreVersion"] as Exec).extra["output"] | ||
versionFile.parentFile.mkdirs() | ||
versionFile.writeText( | ||
""" | ||
// Generated file. Do not edit! | ||
package io.realm.kotlin.gradle | ||
internal const val PLUGIN_VERSION = "${project.version}" | ||
internal const val CORE_VERSION = "${coreVersion}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that we often point to commits that are not tagged releases, this might not be 100% accurate. But I assume that appending the submodule commit sha might be a bit tricky, so maybe this fine? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not tricky ... on the client side. But it will probably clutter the remote view. I guess we should rather just strive to use tagged core-releases 😉 For discussion see https://mongodb.slack.com/archives/C04M17MCY0H/p1693920525143069 |
||
""".trimIndent() | ||
) | ||
} | ||
} | ||
tasks.getByName("compileKotlin").dependsOn("pluginVersion") | ||
|
||
tasks.getByName("compileKotlin").dependsOn("versionConstants") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if grep is available on Windows? It would probably be safer to use the Kotlin API to read the file content and find it that way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn it. You and your windows machine 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated it to read the file through Kotlin API on top of Gradles file content provider API so now it should be fully platform agnostic and appropriately regenerate if
external/core/dependencies.list
is updated.