Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.6-61-710ac8
0.11.7-17-17dea9
270 changes: 172 additions & 98 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import $ivy.`de.tototec::de.tobiasroeser.mill.integrationtest::0.7.1`
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
import $ivy.`com.lihaoyi::mill-contrib-scoverage:`
import $ivy.`com.lihaoyi::mill-contrib-buildinfo:`
import de.tobiasroeser.mill.vcs.version.{Vcs, VcsState}
import mill.define.Cross

// imports
Expand All @@ -11,6 +13,7 @@ import de.tobiasroeser.mill.integrationtest._
import de.tobiasroeser.mill.vcs.version.VcsVersion
import mill._
import mill.contrib.scoverage.{ScoverageModule, ScoverageReport}
import mill.contrib.buildinfo.{BuildInfo}
import mill.define.{Module, Target, Task, TaskModule}
import mill.scalalib._
import mill.scalalib.api.ZincWorkerUtil
Expand All @@ -22,32 +25,60 @@ trait Deps {
def scalaVersion: String = "2.13.13"
def testWithMill: Seq[String]

val vaadinFlowVersion = "23.3.29"

val logbackClassic = ivy"ch.qos.logback:logback-classic:1.1.3"
val millMainApi = ivy"com.lihaoyi::mill-main-api:${millVersion}"
val millMain = ivy"com.lihaoyi::mill-main:${millVersion}"
val millScalalib = ivy"com.lihaoyi::mill-scalalib:${millVersion}"
def osLib: Dep
val reflections = ivy"org.reflections:reflections:0.10.2"
val scalaTest = ivy"org.scalatest::scalatest:3.2.17"
val scoverageVersion = "2.1.0"
val slf4j = ivy"org.slf4j:slf4j-api:1.7.25"
val slf4jSimple = ivy"org.slf4j:slf4j-simple:1.7.25"
val utilsFunctional = ivy"de.tototec:de.tototec.utils.functional:2.0.1"
val vaadinFlowServer = ivy"com.vaadin:flow-server:${vaadinFlowVersion}"
val vaadinFlowPluginBase = ivy"com.vaadin:flow-plugin-base:${vaadinFlowVersion}"
val scalaTest = ivy"org.scalatest::scalatest:3.2.17"
val lambdaTest = ivy"de.tototec:de.tobiasroeser.lambdatest:0.7.1"

trait Vaadin {
def logbackClassic: Dep
def reflections: Dep
def slf4j: Dep
def slf4jSimple: Dep
def vaadinFlowVersion: String
def vaadinFlowServer: Dep
def vaadinFlowPluginBase: Dep
def vaadinFlowPolymer2lit: Dep
}
object Vaadin_23 extends Vaadin {
def vaadinFlowVersion: String = "23.3.29"
def vaadinFlowServer = ivy"com.vaadin:flow-server:${vaadinFlowVersion}"
def vaadinFlowPluginBase = ivy"com.vaadin:flow-plugin-base:${vaadinFlowVersion}"
def vaadinFlowPolymer2lit: Dep = ivy"com.vaadin:flow-polymer2lit:${vaadinFlowVersion}"
def reflections = ivy"org.reflections:reflections:0.10.2"
def slf4j = ivy"org.slf4j:slf4j-api:1.7.25"
def slf4jSimple = ivy"org.slf4j:slf4j-simple:1.7.25"
def logbackClassic = ivy"ch.qos.logback:logback-classic:1.1.3"
}
object Vaadin_24 extends Vaadin {
def vaadinFlowVersion: String = "24.3.5"
def vaadinFlowServer = ivy"com.vaadin:flow-server:${vaadinFlowVersion}"
def vaadinFlowPluginBase = ivy"com.vaadin:flow-plugin-base:${vaadinFlowVersion}"
def vaadinFlowPolymer2lit: Dep = ivy"com.vaadin:flow-polymer2lit:${vaadinFlowVersion}"
def reflections = ivy"org.reflections:reflections:0.10.2"
def slf4j = ivy"org.slf4j:slf4j-api:2.0.12"
def slf4jSimple = ivy"org.slf4j:slf4j-simple:2.0.12"
def logbackClassic = ivy"ch.qos.logback:logback-classic:1.5.1"
}
val vaadin = Map(
"23" -> Vaadin_23,
"24" -> Vaadin_24
)
}

object Deps_0_11 extends Deps {
override def millVersion = "0.11.0" // scala-steward:off
override def millPlatform = "0.11"
override def testWithMill = Seq(millVersion)
override def testWithMill = Seq("0.11.7", millVersion)
override def osLib = ivy"com.lihaoyi::os-lib:0.9.1" // scala-steward:off
}
object Deps_0_10 extends Deps {
override def millVersion = "0.10.0" // scala-steward:off
override def millPlatform = "0.10"
override def testWithMill = Seq("0.10.11", millVersion)
override def testWithMill = Seq("0.10.15", millVersion)
override def osLib = ivy"com.lihaoyi::os-lib:0.8.0" // scala-steward:off
}

Expand All @@ -57,17 +88,37 @@ val millItestVersions = millApiVersions.flatMap { case (_, d) => d.testWithMill.

lazy val baseDir = build.millSourcePath

trait MillVaadinModule extends ScalaModule with PublishModule with ScoverageModule {
object MyVcsVersion extends VcsVersion {
override def vcsBasePath: os.Path = baseDir
override def vcsState: Input[VcsState] = T{
super.vcsState().copy(
currentRevision = "",
lastTag = Some("0.0.4-SNAPSHOT"),
commitsSinceLastTag = 0,
dirtyHash = None,
vcs = Some(Vcs("manual"))
)
// VcsState("SNAPSHOT", state.lastTag, 0, None, None)
}
}

def deps: Deps
trait MillVaadinModule extends ScalaModule with PublishModule with ScoverageModule {
def millPlatform: String
def deps: Deps = millApiVersions.toMap.apply(millPlatform)

override def scalaVersion: T[String] = T(deps.scalaVersion)
override def publishVersion: T[String] = VcsVersion.vcsState().format()
override def publishVersion: T[String] = MyVcsVersion.vcsState().format()
override def artifactSuffix: T[String] = s"_mill${deps.millPlatform}_${artifactScalaVersion()}"
override def javacOptions = Seq("-source", "1.8", "-target", "1.8", "-encoding", "UTF-8", "-deprecation")
override def scalacOptions = Seq("-target:jvm-1.8", "-encoding", "UTF-8", "-deprecation")
override def scoverageVersion = deps.scoverageVersion

override def sources: T[Seq[PathRef]] = T.sources {
super.sources() ++
ZincWorkerUtil.versionRanges(millPlatform, millApiVersions.map(_._1))
.map(p => PathRef(millSourcePath / s"src-${p}"))
}

def pomSettings = T {
PomSettings(
description = "Vaadin support for mill",
Expand All @@ -79,26 +130,54 @@ trait MillVaadinModule extends ScalaModule with PublishModule with ScoverageModu
)
}

override def skipIdea: Boolean = millApiVersions.head._2.scalaVersion != deps.scalaVersion
override lazy val scoverage: ScoverageData = new MyScoverageData {}
trait MyScoverageData extends ScoverageData {
override def skipIdea: Boolean = true
}
def skipIdea = millPlatform != Deps_0_11.millPlatform
}

object main extends Cross[MainCross](millApiVersions.map(_._1))
trait MainCross extends MillVaadinModule with Cross.Module[String] { vaadin =>
val millPlatform = crossValue
override def deps: Deps = millApiVersions.toMap.apply(millPlatform)
trait MainCross extends MillVaadinModule with Cross.Module[String] with BuildInfo { main =>
override def millPlatform = crossValue

override def sources: T[Seq[PathRef]] = T.sources {
super.sources() ++
ZincWorkerUtil.versionRanges(millPlatform, millApiVersions.map(_._1))
.map(p => PathRef(millSourcePath / s"src-${p}"))
override def artifactName = "de.tobiasroeser.mill.vaadin"
override def moduleDeps: Seq[PublishModule] = Seq(worker)
override def ivyDeps = T {
Agg(ivy"${scalaOrganization()}:scala-library:${scalaVersion()}")
}

override def compileIvyDeps = Agg(
deps.millMain,
deps.millScalalib
)

override def buildInfoPackageName = "de.tobiasroeser.mill.vaadin"
override def buildInfoObjectName: String = "Versions"
override def buildInfoStaticCompiled: Boolean = true
override def buildInfoMembers: T[Seq[BuildInfo.Value]] = Seq(
BuildInfo.Value("millVaadinVersion", publishVersion(), "The mill-vaadin plugin version"),
BuildInfo.Value("buildTimeMillVersion", deps.millVersion, "The Mill API version used to build mill-vaadin plugin"),
BuildInfo.Value(
"workerIvyDeps23",
Seq(
formatDep(worker.impl("23").publishSelfDependency()),
formatDep(deps.Vaadin_23.vaadinFlowPluginBase),
formatDep(deps.Vaadin_23.slf4j),
formatDep(deps.Vaadin_23.slf4jSimple)
).mkString(","),
"The dependencies to load the Worker for Vaadin 23"
),
BuildInfo.Value(
"workerIvyDeps24",
Seq(
formatDep(worker.impl("24").publishSelfDependency())
// formatDep(deps.Vaadin_24.vaadinFlowPluginBase),
// formatDep(deps.Vaadin_24.slf4j),
// formatDep(deps.Vaadin_24.slf4jSimple)
).mkString(","),
"The dependencies to load the Worker for Vaadin 24"
)
)

object worker extends MillVaadinModule {
def deps = vaadin.deps
override def millPlatform = main.millPlatform
override def artifactName = "de.tobiasroeser.mill.vaadin-worker"
override def compileIvyDeps: T[Loose.Agg[Dep]] = T {
Agg(
Expand All @@ -107,85 +186,36 @@ trait MainCross extends MillVaadinModule with Cross.Module[String] { vaadin =>
)
}

object impl extends MillVaadinModule {
def deps = vaadin.deps

override def artifactName = "de.tobiasroeser.mill.vaadin-worker-impl"
object impl extends Cross[Impl]("24", "23")
trait Impl extends MillVaadinModule with Cross.Module[String] {
override def millSourcePath = super.millSourcePath / os.up / s"impl-${crossValue}"
override def millPlatform = main.millPlatform
def vaadinDeps = deps.vaadin(crossValue)
override def artifactName = s"de.tobiasroeser.mill.vaadin-worker-impl-${crossValue}"

override def moduleDeps: Seq[PublishModule] = Seq(worker)

override def compileIvyDeps: T[Loose.Agg[Dep]] = T {
Agg(
deps.osLib,
deps.millMainApi,
deps.vaadinFlowServer,
deps.vaadinFlowPluginBase
deps.millMainApi
)
}

override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg(
deps.reflections
)
vaadinDeps.reflections,
vaadinDeps.vaadinFlowServer,
vaadinDeps.vaadinFlowPluginBase,
vaadinDeps.slf4j,
vaadinDeps.logbackClassic
) ++
Agg.when(crossValue == "24")(
// ivy"com.vaadin:vaadin-dev:${vaadinDeps.vaadinFlowVersion}",
// ivy"com.vaadin:copilot:${vaadinDeps.vaadinFlowVersion}"
vaadinDeps.vaadinFlowPolymer2lit
)
}
}

override def artifactName = "de.tobiasroeser.mill.vaadin"
override def moduleDeps: Seq[PublishModule] = Seq(worker)
override def ivyDeps = T {
Agg(ivy"${scalaOrganization()}:scala-library:${scalaVersion()}")
}

override def compileIvyDeps = Agg(
deps.millMain,
deps.millScalalib
)

object test extends ScalaTests with TestModule.ScalaTest {
override def ivyDeps = Agg(
deps.scalaTest
)
}

override def generatedSources: Target[Seq[PathRef]] = T {
super.generatedSources() :+ versionFile()
}

private def formatIvyDep(dep: Dep): String = {
val module = dep.dep.module
s"${module.organization.value}:${module.name.value}:${dep.dep.version}"
}

def versionFile: Target[PathRef] = T {
val dest = T.ctx().dest
val artifactMetadata = worker.impl.artifactMetadata()
val body =
s"""package de.tobiasroeser.mill.vaadin
|
|/**
| * Build-time generated versions file.
| */
|object Versions {
| /** The mill-kotlin version. */
| val millVaadinVersion = "${publishVersion()}"
| /** The mill API version used to build mill-kotlin. */
| val buildTimeMillVersion = "${deps.millVersion}"
| /** The ivy dependency holding the mill kotlin worker impl. */
| val millVaadinWorkerImplIvyDep = "${artifactMetadata.group}:${artifactMetadata.id}:${artifactMetadata.version}"
| val buildTimeFlowServerVersion = "${deps.vaadinFlowServer.dep.version}"
| val vaadinFlowPluginBaseDep ="${formatIvyDep(deps.vaadinFlowPluginBase)}"
| val workerIvyDeps = Seq(
| "${artifactMetadata.group}:${artifactMetadata.id}:${artifactMetadata.version}",
| "${formatIvyDep(deps.vaadinFlowPluginBase)}",
| "${formatIvyDep(deps.slf4j)}",
| "${formatIvyDep(deps.slf4jSimple)}"
| )
|}
|""".stripMargin

os.write(dest / "Versions.scala", body)
PathRef(dest)
}

}

object itest extends Cross[ItestCross](millItestVersions.map(_._1))
Expand All @@ -205,7 +235,9 @@ trait ItestCross extends MillIntegrationTestModule with Cross.Module[String] {

override def pluginsUnderTest = Seq(mainModule)

override def temporaryIvyModules = Seq(mainModule.worker, mainModule.worker.impl)
override def temporaryIvyModules =
Seq(mainModule.worker) ++
deps.vaadin.keys.map(v => mainModule.worker.impl(v))

override def testInvocations: Target[Seq[(PathRef, Seq[TestInvocation.Targets])]] =
testCases().map { tc =>
Expand All @@ -222,7 +254,12 @@ trait ItestCross extends MillIntegrationTestModule with Cross.Module[String] {
TestInvocation.Targets(Seq("-d", "v.vaadinBuildFrontend")),
TestInvocation.Targets(Seq("-d", "validateBuildFrontend"))
)
case _ => Seq()
case _ => Seq(
TestInvocation.Targets(Seq("-d", "v.vaadinPrepareFrontend")),
TestInvocation.Targets(Seq("-d", "validatePrepareFrontend")),
TestInvocation.Targets(Seq("-d", "v.vaadinBuildFrontend")),
TestInvocation.Targets(Seq("-d", "validateBuildFrontend"))
)
})
}

Expand Down Expand Up @@ -258,7 +295,9 @@ trait ItestCross extends MillIntegrationTestModule with Cross.Module[String] {
def generatedSharedSrc = T {
os.write(
T.dest / "shared.sc",
s"""import $$ivy.`org.scoverage::scalac-scoverage-runtime:${deps.scoverageVersion}`
s"""import $$file.plugins
|import $$ivy.`org.scoverage::scalac-scoverage-runtime:${deps.scoverageVersion}`
|import $$ivy.`${formatDep(deps.lambdaTest)}`
|import $$file.helper
|""".stripMargin
)
Expand All @@ -285,3 +324,38 @@ object scoverage extends ScoverageReport {
override def scoverageVersion = Deps_0_10.scoverageVersion
override def scalaVersion: T[String] = Deps_0_10.scalaVersion
}

private def formatDep(dep: Artifact): String = s"${dep.group}:${dep.id}:${dep.version}"
private def formatDep(dep: Dep): String = {
val module = dep.dep.module
s"${module.organization.value}:${module.name.value}:${dep.dep.version}"
}

// Check all dependencies
val dummyDeps: Seq[Dep] = Seq(
Deps_0_11.lambdaTest,
ivy"org.scoverage::scalac-scoverage-runtime:${Deps_0_11.scoverageVersion}",
Deps_0_11.Vaadin_23.vaadinFlowPluginBase,
Deps_0_11.Vaadin_23.logbackClassic,
Deps_0_11.Vaadin_23.slf4j,
Deps_0_11.Vaadin_23.slf4jSimple,
Deps_0_11.Vaadin_24.vaadinFlowPluginBase,
Deps_0_11.Vaadin_24.logbackClassic,
Deps_0_11.Vaadin_24.slf4j,
Deps_0_11.Vaadin_24.slf4jSimple
).distinct

implicit object DepSegment extends Cross.ToSegments[Dep]({ dep =>
val depString = formatDep(dep)
List(depString)
})

/**
* Dummy module(s) to let Dependency/showUpdates or Scala-Steward find
* and bump dependency versions we use at runtime
*/
object dummy extends Cross[DependencyFetchDummy](dummyDeps)
trait DependencyFetchDummy extends ScalaModule with Cross.Module[Dep] {
def scalaVersion = Deps_0_11.scalaVersion
override def compileIvyDeps = Agg(crossValue)
}
2 changes: 0 additions & 2 deletions itest/resources/helper.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import $ivy.`de.tototec:de.tobiasroeser.lambdatest:0.7.1`

import de.tobiasroeser.lambdatest

def checkNonexistantFile(f: os.Path): Option[String] = Option(f)
Expand Down
Loading