-
-
Notifications
You must be signed in to change notification settings - Fork 368
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
Make mill.define.Module
a trait to allow abstract/virtual module lazy val
s to be trait
s rather than class
es
#2536
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4572916
.
lihaoyi 3b4c52f
.
lihaoyi f006bce
.
lihaoyi be98223
.
lihaoyi a4c5922
.
lihaoyi 0192cd4
.
lihaoyi 0be3d51
.
lihaoyi f465e3c
.
lihaoyi 8b99490
.
lihaoyi f1de9d0
update-patch
lihaoyi 757e0b9
update-patch
lihaoyi ca89a21
.
lihaoyi d2e8607
add ModuleRef wrapper to example
lihaoyi 61c62a6
update-patch
lihaoyi 6927475
bincompat
lihaoyi 605dc5b
.
lihaoyi f39f543
.
lihaoyi 4cfab83
Merge branch 'main' into mill-module-trait
lihaoyi bedc416
Merge branch 'put-back-mima' into mill-module-trait
lihaoyi 0c26cd4
.
lihaoyi fa7f579
.
lihaoyi 2704dd2
.
lihaoyi 901a25c
.
lihaoyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,235 @@ | ||
diff --git a/build.sc b/build.sc | ||
index 20fe84f7e4..869c3ba31e 100644 | ||
--- a/build.sc | ||
+++ b/build.sc | ||
@@ -2,23 +2,23 @@ | ||
import $file.ci.shared | ||
import $file.ci.upload | ||
import $ivy.`org.scalaj::scalaj-http:2.4.2` | ||
-import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.3.1-6-e80da7` | ||
+//import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.3.1-6-e80da7` | ||
|
||
-import $ivy.`com.github.lolgab::mill-mima::0.0.20` | ||
+//import $ivy.`com.github.lolgab::mill-mima::0.0.20` | ||
import $ivy.`net.sourceforge.htmlcleaner:htmlcleaner:2.25` | ||
|
||
// imports | ||
-import com.github.lolgab.mill.mima | ||
-import com.github.lolgab.mill.mima.{ | ||
- CheckDirection, | ||
- DirectMissingMethodProblem, | ||
- IncompatibleMethTypeProblem, | ||
- IncompatibleSignatureProblem, | ||
- ProblemFilter, | ||
- ReversedMissingMethodProblem | ||
-} | ||
+//import com.github.lolgab.mill.mima | ||
+//import com.github.lolgab.mill.mima.{ | ||
+// CheckDirection, | ||
+// DirectMissingMethodProblem, | ||
+// IncompatibleMethTypeProblem, | ||
+// IncompatibleSignatureProblem, | ||
+// ProblemFilter, | ||
+// ReversedMissingMethodProblem | ||
+//} | ||
import coursier.maven.MavenRepository | ||
-import de.tobiasroeser.mill.vcs.version.VcsVersion | ||
+//import de.tobiasroeser.mill.vcs.version.VcsVersion | ||
import mill._ | ||
import mill.eval.Evaluator | ||
import mill.main.MainModule | ||
@@ -167,11 +167,12 @@ object Deps { | ||
val requests = ivy"com.lihaoyi::requests:0.8.0" | ||
} | ||
|
||
-def millVersion: T[String] = T { VcsVersion.vcsState().format() } | ||
+def millVersion: T[String] = T { "dev"/*VcsVersion.vcsState().format()*/ } | ||
def millLastTag: T[String] = T { | ||
- VcsVersion.vcsState().lastTag.getOrElse( | ||
- sys.error("No (last) git tag found. Your git history seems incomplete!") | ||
- ) | ||
+// VcsVersion.vcsState().lastTag.getOrElse( | ||
+// sys.error("No (last) git tag found. Your git history seems incomplete!") | ||
+// ) | ||
+ "dev" | ||
} | ||
def millBinPlatform: T[String] = T { | ||
val tag = millLastTag() | ||
@@ -319,26 +320,26 @@ trait MillJavaModule extends JavaModule { | ||
) | ||
} | ||
|
||
-trait MillMimaConfig extends mima.Mima { | ||
- override def mimaPreviousVersions: T[Seq[String]] = Settings.mimaBaseVersions | ||
- override def mimaPreviousArtifacts: T[Agg[Dep]] = T { | ||
- Agg.from( | ||
- Settings.mimaBaseVersions | ||
- .filter(v => !skipPreviousVersions().contains(v)) | ||
- .map(version => | ||
- ivy"${pomSettings().organization}:${artifactId()}:${version}" | ||
- ) | ||
- ) | ||
- } | ||
- override def mimaExcludeAnnotations: T[Seq[String]] = Seq( | ||
- "mill.api.internal", | ||
- "mill.api.experimental" | ||
- ) | ||
- override def mimaCheckDirection: Target[CheckDirection] = T { CheckDirection.Backward } | ||
- override def mimaBinaryIssueFilters: Target[Seq[ProblemFilter]] = T { | ||
- issueFilterByModule.getOrElse(this, Seq()) | ||
- } | ||
- lazy val issueFilterByModule: Map[MillMimaConfig, Seq[ProblemFilter]] = Map() | ||
+trait MillMimaConfig extends Module/*mima.Mima*/ { | ||
+// override def mimaPreviousVersions: T[Seq[String]] = Settings.mimaBaseVersions | ||
+// override def mimaPreviousArtifacts: T[Agg[Dep]] = T { | ||
+// Agg.from( | ||
+// Settings.mimaBaseVersions | ||
+// .filter(v => !skipPreviousVersions().contains(v)) | ||
+// .map(version => | ||
+// ivy"${pomSettings().organization}:${artifactId()}:${version}" | ||
+// ) | ||
+// ) | ||
+// } | ||
+// override def mimaExcludeAnnotations: T[Seq[String]] = Seq( | ||
+// "mill.api.internal", | ||
+// "mill.api.experimental" | ||
+// ) | ||
+// override def mimaCheckDirection: Target[CheckDirection] = T { CheckDirection.Backward } | ||
+// override def mimaBinaryIssueFilters: Target[Seq[ProblemFilter]] = T { | ||
+// issueFilterByModule.getOrElse(this, Seq()) | ||
+// } | ||
+// lazy val issueFilterByModule: Map[MillMimaConfig, Seq[ProblemFilter]] = Map() | ||
def skipPreviousVersions: T[Seq[String]] = T(Seq.empty[String]) | ||
} | ||
|
||
@@ -425,10 +426,9 @@ trait BaseMillTestsModule extends TestModule { | ||
|
||
/** A MillScalaModule with default set up test module. */ | ||
trait MillAutoTestSetup extends MillScalaModule { | ||
- // instead of `object test` which can't be overridden, we hand-made a val+class singleton | ||
/** Default tests module. */ | ||
- val test = new Tests(implicitly) | ||
- class Tests(ctx0: mill.define.Ctx) extends mill.Module()(ctx0) with super.MillScalaModuleTests | ||
+ lazy val test: Tests = new Tests {} | ||
+ trait Tests extends super.MillScalaModuleTests | ||
} | ||
|
||
/** Published module which does not contain strictly handled API. */ | ||
@@ -917,8 +917,8 @@ object bsp extends MillModule with BuildInfo { | ||
) | ||
} | ||
|
||
- override val test = new Test(implicitly) | ||
- class Test(ctx0: mill.define.Ctx) extends Tests(ctx0) { | ||
+ override lazy val test: Test = new Test {} | ||
+ trait Test extends Tests{ | ||
override def forkEnv: Target[Map[String, String]] = T { | ||
// We try to fetch this dependency with coursier in the tests | ||
bsp.worker.publishLocal()() | ||
@@ -1066,7 +1066,7 @@ object example extends MillScalaModule { | ||
val title = | ||
if (seenCode) "" | ||
else { | ||
- val label = VcsVersion.vcsState().format() | ||
+ val label = millVersion() | ||
val exampleDashed = examplePath.segments.mkString("-") | ||
val download = s"{mill-download-url}/$label-$exampleDashed.zip[download]" | ||
val browse = s"{mill-example-url}/$examplePath[browse]" | ||
@@ -1744,7 +1744,7 @@ def exampleZips: Target[Seq[PathRef]] = T { | ||
examplePath = exampleMod.millSourcePath | ||
} yield { | ||
val example = examplePath.subRelativeTo(T.workspace) | ||
- val exampleStr = VcsVersion.vcsState().format() + "-" + example.segments.mkString("-") | ||
+ val exampleStr = millVersion() + "-" + example.segments.mkString("-") | ||
os.copy(examplePath, T.dest / exampleStr, createFolders = true) | ||
os.copy(bootstrapLauncher().path, T.dest / exampleStr / "mill") | ||
val zip = T.dest / s"$exampleStr.zip" | ||
@@ -1754,47 +1754,47 @@ def exampleZips: Target[Seq[PathRef]] = T { | ||
} | ||
|
||
def uploadToGithub(authKey: String) = T.command { | ||
- val vcsState = VcsVersion.vcsState() | ||
- val label = vcsState.format() | ||
- if (label != millVersion()) sys.error("Modified mill version detected, aborting upload") | ||
- val releaseTag = vcsState.lastTag.getOrElse(sys.error( | ||
- "Incomplete git history. No tag found.\nIf on CI, make sure your git checkout job includes enough history." | ||
- )) | ||
- | ||
- if (releaseTag == label) { | ||
- // TODO: check if the tag already exists (e.g. because we created it manually) and do not fail | ||
- scalaj.http.Http( | ||
- s"https://api.github.com/repos/${Settings.githubOrg}/${Settings.githubRepo}/releases" | ||
- ) | ||
- .postData( | ||
- ujson.write( | ||
- ujson.Obj( | ||
- "tag_name" -> releaseTag, | ||
- "name" -> releaseTag | ||
- ) | ||
- ) | ||
- ) | ||
- .header("Authorization", "token " + authKey) | ||
- .asString | ||
- } | ||
- | ||
- val examples = exampleZips().map(z => (z.path, z.path.last)) | ||
- | ||
- val zips = examples ++ Seq( | ||
- (dev.assembly().path, label + "-assembly"), | ||
- (bootstrapLauncher().path, label) | ||
- ) | ||
- | ||
- for ((zip, name) <- zips) { | ||
- upload.apply( | ||
- zip, | ||
- releaseTag, | ||
- name, | ||
- authKey, | ||
- Settings.githubOrg, | ||
- Settings.githubRepo | ||
- ) | ||
- } | ||
+// val vcsState = VcsVersion.vcsState() | ||
+// val label = vcsState.format() | ||
+// if (label != millVersion()) sys.error("Modified mill version detected, aborting upload") | ||
+// val releaseTag = vcsState.lastTag.getOrElse(sys.error( | ||
+// "Incomplete git history. No tag found.\nIf on CI, make sure your git checkout job includes enough history." | ||
+// )) | ||
+// | ||
+// if (releaseTag == label) { | ||
+// // TODO: check if the tag already exists (e.g. because we created it manually) and do not fail | ||
+// scalaj.http.Http( | ||
+// s"https://api.github.com/repos/${Settings.githubOrg}/${Settings.githubRepo}/releases" | ||
+// ) | ||
+// .postData( | ||
+// ujson.write( | ||
+// ujson.Obj( | ||
+// "tag_name" -> releaseTag, | ||
+// "name" -> releaseTag | ||
+// ) | ||
+// ) | ||
+// ) | ||
+// .header("Authorization", "token " + authKey) | ||
+// .asString | ||
+// } | ||
+// | ||
+// val examples = exampleZips().map(z => (z.path, z.path.last)) | ||
+// | ||
+// val zips = examples ++ Seq( | ||
+// (dev.assembly().path, label + "-assembly"), | ||
+// (bootstrapLauncher().path, label) | ||
+// ) | ||
+// | ||
+// for ((zip, name) <- zips) { | ||
+// upload.apply( | ||
+// zip, | ||
+// releaseTag, | ||
+// name, | ||
+// authKey, | ||
+// Settings.githubOrg, | ||
+// Settings.githubRepo | ||
+// ) | ||
+// } | ||
} | ||
|
||
def validate(ev: Evaluator): Command[Unit] = T.command { |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
Is this only to be lazy, or is it fixing some early initialization stuff? If this is a (required) pattern, we should probably document it in
Module
.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.
It doesn't need to be lazy, but I thought that's probably what we should tell people to do. After all,
object
s are lazy, so usinglazy val
for these would avoid unnecessarily changing the evaluation model. It also helps avoidNullPointerException
s from popping up in surprising places, especially once multiple trait inheritance and overriding is involved. Not a problem with this specific definition, but definitely a potential problem in general