Skip to content

Commit

Permalink
Added support for Mill 0.11 (#48)
Browse files Browse the repository at this point in the history
Pull request: #48
  • Loading branch information
lefou authored Nov 24, 2023
1 parent b2d616f commit d89d714
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 15 deletions.
12 changes: 9 additions & 3 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ trait Setup {
}

object Setup {
object R011 extends Setup {
override val millPlatform = "0.11"
override val millVersion = "0.11.0" // scala-steward:off
override val testMillVersions = Seq("0.11.6", millVersion)
override val osLibVersion = "0.9.1" // scala-steward:off
}
object R010 extends Setup {
override val millPlatform = "0.10"
override val millVersion = "0.10.0" // scala-steward:off
Expand Down Expand Up @@ -48,7 +54,7 @@ object Setup {
}
}

val setups = Seq(Setup.R010, Setup.R09, Setup.R07, Setup.R06)
val setups = Seq(Setup.R011, Setup.R010, Setup.R09, Setup.R07, Setup.R06)

object jbake extends Cross[JbakeCross](setups.map(_.millPlatform))
trait JbakeCross extends ScalaModule with PublishModule with Cross.Module[String] {
Expand Down Expand Up @@ -100,8 +106,8 @@ trait ItestCross extends MillIntegrationTestModule with Cross.Module[String] {
override def testInvocations: Target[Seq[(PathRef, Seq[TestInvocation.Targets])]] = T {
Seq(
PathRef(millSourcePath / "src" / "01-simple-site") -> Seq(
TestInvocation.Targets(Seq("verify")),
TestInvocation.Targets(Seq("site.jbake"))
TestInvocation.Targets(Seq("verifyInit")),
TestInvocation.Targets(Seq("verifyBake"))
)
)
}
Expand Down
74 changes: 65 additions & 9 deletions itest/src/01-simple-site/build.sc
Original file line number Diff line number Diff line change
@@ -1,28 +1,84 @@
import mill._
import mill.define._
// import $ivy.`de.tototec::de.tobiasroeser.mill.jbake:0.2.0`
import $exec.plugins
import $file.plugins
import de.tobiasroeser.mill.jbake._
import $ivy.`org.scalatest::scalatest:3.1.4`
import org.scalatest.Assertions

object site extends JBakeModule {

object siteSp extends JBakeModule {
override def jbakeVersion = "2.6.4"

override def jbakeProcessMode = JBakeModule.SubProcess
}

object siteCl extends JBakeModule {
override def jbakeVersion = "2.6.4"

override def jbakeProcessMode = JBakeModule.ClassLoader
}

def verify(): Command[Unit] = T.command {
val A = new Assertions {}

import A._

val A = new Assertions{}
import A._
val sites = Seq(siteSp, siteCl)

def vInit(site: JBakeModule) = T.task {

site.jbakeInit()()
val files = os.walk(site.millSourcePath / "src")

assert(files.contains(site.millSourcePath / "src" / "templates"))
val expected = Seq(
os.sub / "jbake.properties",
os.sub / "templates" / "archive.ftl",
os.sub / "templates" / "feed.ftl",
os.sub / "templates" / "footer.ftl",
os.sub / "templates" / "header.ftl",
os.sub / "templates" / "index.ftl",
os.sub / "templates" / "menu.ftl",
os.sub / "templates" / "page.ftl",
os.sub / "templates" / "post.ftl",
os.sub / "templates" / "sitemap.ftl",
os.sub / "templates" / "tags.ftl",
os.sub / "content" / "about.html",
)

val dir = site.millSourcePath / "src"
val files = os.walk(dir)

for {
file <- expected
} assert(files.contains(dir / file))
}

def vBake(site: JBakeModule) = T.task {
site.jbake()

val expected = Seq(
os.sub / "index.html",
os.sub / "favicon.ico",
os.sub / "feed.xml",
os.sub / "archive.html"

)

val dir = Option(os.pwd / "out" / site.toString() / "jbake.dest")
// Support for older out layout
.filter(os.exists)
.getOrElse(os.pwd / "out" / site.toString() / "jbake" / "dest")
val files = os.walk(dir)

for {
file <- expected
} assert(files.contains(dir / file))
}

def verifyInit() = T.command {
T.traverse(sites)(s => vInit(s))()
()
}

def verifyBake() = T.command {
// Classloader mode does not work anymore with newer Java
T.traverse(Seq(siteSp))(s => vBake(s))()
()
}
7 changes: 4 additions & 3 deletions jbake/src/de/tobiasroeser/mill/jbake/JBakeModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ trait JBakeModule extends Module with TaskModule {
parseVersion(jbakeVersion()) match {
case Success(Array(2, 0 | 1 | 2 | 3 | 4 | 5, _)) =>
(Seq(jbakeDistributionDir().path / "jbake-core.jar") ++
os.list(jbakeDistributionDir().path / 'lib)).map(PathRef(_))
os.list(jbakeDistributionDir().path / "lib")).map(PathRef(_))
case _ =>
os.list(jbakeDistributionDir().path / 'lib).map(PathRef(_))
os.list(jbakeDistributionDir().path / "lib").map(PathRef(_))
}
}

Expand Down Expand Up @@ -109,7 +109,7 @@ trait JBakeModule extends Module with TaskModule {
/**
* Initialized the sources for a new project.
*/
def jbakeInit() = T.command {
def jbakeInit(): Command[PathRef] = T.command {
val src = sources().head.path
if (os.exists(src) && !os.walk(src).isEmpty) {
throw new RuntimeException(s"Source directory ${src} is not empty. Aborting initialization of fresh JBake project")
Expand All @@ -119,6 +119,7 @@ trait JBakeModule extends Module with TaskModule {
// val baseZip = ???
// IO.unpackZip(baseZip, )
}
PathRef(T.ctx().dest)
}

/**
Expand Down

0 comments on commit d89d714

Please sign in to comment.