You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A "source UUID" is a unique ID generated at compile time at a given source code location. So, the value of SourceUUID depends only on the source code location and will be the same each time that code is executed.
defgenerateUUIDs() = {
valuuid1= implicitly[sourcecode.SourceUUID].value // Generate some UUID.valuuid2= implicitly[sourcecode.SourceUUID].value // This will be a different UUID.
(uuid1, uuid2)
}
val (u1a, u2a) = generateUUIDs() // Generate a pair of UUIDs.val (u1b, u2b) = generateUUIDs() // This will be the same pair of UUID.
assert(u1a != u2a) // Verify that the two UUIDs are different.
assert(u1a == u1b) // The UUIDs are generated at compile time.
assert(u2a == u2b) // So, calling `generateUUIDs()` several times will produce the same results.
Motivation for this feature is to be able to generate unique IDs at compile time for values created in a DSL. The IDs should remain unique even when values are created within a function that is being called several times. In this way, the IDs serve as unique labels on values created via DSL code.
FYI - I am not able to run tests on my laptop because the command mill -i all __.test fails with:
Mill version 0.11.1 is different than configured for this directory!
Configured version is 0.10.12 (/Users/sergei.winitzki/Code/sourcecode/.mill-version)
[build.sc] [41/49] compile
[info] compiling 1 Scala source to /Users/sergei.winitzki/Code/sourcecode/out/mill-build/compile.dest/classes ...
[error] /Users/sergei.winitzki/Code/sourcecode/build.sc:6:26: object Util is not a member of package mill.scalalib.api
[error] import mill.scalalib.api.Util.isScala3
[error] ^
[error] /Users/sergei.winitzki/Code/sourcecode/build.sc:30:8: not found: value isScala3
[error] if(isScala3(crossScalaVersion)) Agg.empty[Dep] else super.mimaPreviousArtifacts()
[error] ^
[error] /Users/sergei.winitzki/Code/sourcecode/build.sc:75:11: not found: value CrossModuleBase
[error] .++(CrossModuleBase.scalaVersionPaths(crossScalaVersion, s => millSourcePath / s"src-$s" ))
[error] ^
[error] /Users/sergei.winitzki/Code/sourcecode/build.sc:87:49: type mismatch;
[error] found : List[String]
[error] required: Seq[mill.define.Cross.Factory[millbuild.build.sourcecode.JvmSourcecodeModule]]
[error] object jvm extends Cross[JvmSourcecodeModule](scalaVersions: _*)
[error] ^
[error] /Users/sergei.winitzki/Code/sourcecode/build.sc:98:47: type mismatch;
[error] found : List[(String, String)]
[error] required: Seq[mill.define.Cross.Factory[millbuild.build.sourcecode.JsSourcecodeModule]]
[error] object js extends Cross[JsSourcecodeModule](scalaJSVersions: _*)
[error] ^
[error] /Users/sergei.winitzki/Code/sourcecode/build.sc:113:55: type mismatch;
[error] found : List[(String, String)]
[error] required: Seq[mill.define.Cross.Factory[millbuild.build.sourcecode.NativeSourcecodeModule]]
[error] object native extends Cross[NativeSourcecodeModule](scalaNativeVersions: _*)
[error] ^
[error] 6 errors found
1 targets failed
compile Compilation failed
I have tried to set MILL_VERSION=0.10.12 but I still get the same error.
The CI doesn't seem to run on this PR automatically either. I'm not sure how to proceed, please help.
looks like you're using the mill-assembly jar directly (which is supposed to be downloaded and used by the scripts), instead of a mill script (either to official mill script or millw).
winitzki
changed the title
feature enhancement - implement SourceUUIDs
feature enhancement - implement unique ID generated at compile time
Jul 28, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A "source UUID" is a unique ID generated at compile time at a given source code location. So, the value of
SourceUUIDdepends only on the source code location and will be the same each time that code is executed.Motivation for this feature is to be able to generate unique IDs at compile time for values created in a DSL. The IDs should remain unique even when values are created within a function that is being called several times. In this way, the IDs serve as unique labels on values created via DSL code.