Skip to content
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

Move BuildInfo from sources into resources, defer use of resources during compilation #2425

Merged
merged 41 commits into from
Apr 8, 2023
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
504d6ff
.
lihaoyi Apr 6, 2023
1075d7e
build.sc compiles
lihaoyi Apr 7, 2023
482b52f
move to resource based buildinfo
lihaoyi Apr 7, 2023
18a54a4
.
lihaoyi Apr 7, 2023
c9382e5
cleanup
lihaoyi Apr 7, 2023
9eef9c3
fix
lihaoyi Apr 7, 2023
028c779
.
lihaoyi Apr 7, 2023
cddc254
transitiveCompileClasspath should include compile.classes
lihaoyi Apr 7, 2023
0dc7664
wip replacing contribu/buildinfo with new implementation
lihaoyi Apr 7, 2023
80b8d0b
contrib.buildinfo.test passes
lihaoyi Apr 7, 2023
1a5bb75
fix build.sc
lihaoyi Apr 7, 2023
ac0e98e
.
lihaoyi Apr 7, 2023
f6e96b0
.
lihaoyi Apr 7, 2023
5050886
.
lihaoyi Apr 7, 2023
f490919
update patch bootstrap
lihaoyi Apr 7, 2023
196c320
add mill-contrib-buildinfo import to patch
lihaoyi Apr 7, 2023
e2625ce
scaladoc
lihaoyi Apr 7, 2023
e28d97f
fixcompile
lihaoyi Apr 7, 2023
fe6aef7
fix-compile
lihaoyi Apr 7, 2023
a622dca
.
lihaoyi Apr 7, 2023
6600186
fixbsp
lihaoyi Apr 7, 2023
f351a10
add import to patch
lihaoyi Apr 7, 2023
2c2590d
.
lihaoyi Apr 7, 2023
a5fabc3
fixpatch
lihaoyi Apr 7, 2023
a5f9e54
BuildInfo.Value
lihaoyi Apr 7, 2023
147942e
update patch
lihaoyi Apr 7, 2023
8af9b5d
fixbuild
lihaoyi Apr 7, 2023
6590af0
.
lihaoyi Apr 7, 2023
1455fcd
rename to BuildInfo.buildinfo.properties
lihaoyi Apr 8, 2023
d2ebf93
use relative getResourceAsStream
lihaoyi Apr 8, 2023
818f7fc
.
lihaoyi Apr 8, 2023
6aa9984
update build.sc buildinfo
lihaoyi Apr 8, 2023
e229fc9
update
lihaoyi Apr 8, 2023
235fc7f
remove-println
lihaoyi Apr 8, 2023
d50c0ed
fix-patch
lihaoyi Apr 8, 2023
1ae58e4
.
lihaoyi Apr 8, 2023
f725a38
debug
lihaoyi Apr 8, 2023
8ea492f
.
lihaoyi Apr 8, 2023
8d7f669
add publishLocal to make test-mill-dev pass
lihaoyi Apr 8, 2023
a6e2084
bump timeout for flaky test
lihaoyi Apr 8, 2023
f36c0b8
scalafmt
lihaoyi Apr 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
scaladoc
  • Loading branch information
lihaoyi committed Apr 7, 2023
commit e2625ce6f57f3224cc9141e147aeff7629f95041
31 changes: 30 additions & 1 deletion contrib/buildinfo/src/mill/contrib/buildinfo/BuildInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,43 @@ import mill.{PathRef, T}
import mill.scalalib.{JavaModule, ScalaModule}

trait BuildInfo extends JavaModule {
/**
* The package name under which the BuildInfo data object will be stored.
*/
def buildInfoPackageName: String

/**
* The name of the BuildInfo data object, defaults to "BuildInfo"
*/
def buildInfoObjectName: String = "BuildInfo"

/**
* Enable to compile the BuildInfo values directly into the classfiles,
* rather than the default behavior of storing them as a JVM resource. Needed
* to use BuildInfo on Scala.js which does not support JVM resources
*/
def buildInfoStaticCompiled: Boolean = false

/**
* A mapping of key-value pairs to pass from the Build script to the
* application code at runtime.
*/
def buildInfoMembers: T[Map[String, String]]
def buildInfoObjectName: String = "BuildInfo"

def resources =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file generation should be a dedicated target. This helps when someone needs to override the resources target but wants to keep some overridden functionality, or if the file is needed elsewhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (buildInfoStaticCompiled) super.resources
else T.sources{
// BuildInfo values are stored each as a separate file in resources,
// under the `buildInfoPackageName` folder.
//
// - Storing them under `buildInfoPackageName` scopes them to avoid
// conflicts, so multiple BuildInfos for separate packages or libraries
// can define the same keys without conflicting
//
// - Storing each value in a separate file allows them to be
// automatically merged as the classpath is aggregated, without needing
// to worry about one definition shadowing another or configuring
// assembly-jar logic to merge text files
for((k, v) <- buildInfoMembers()) os.write(
T.dest / os.SubPath(buildInfoPackageName.replace('.', '/')) / s"$k.buildinfo",
v.getBytes("UTF-8"),
Expand Down