Skip to content

Commit

Permalink
Amend slash format, scala 2.12 scripted tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyAutrey committed Oct 15, 2024
1 parent 22fd8c7 commit cbee7d8
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 12 deletions.
20 changes: 16 additions & 4 deletions src/main/scala/com/typesafe/sbt/web/SbtWeb.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,16 @@ object Import {
* {{{
* + src
* --+ main
* ----+ assets .....(sourceDirectory in Assets)
* ----+ assets .....(Assets / sourceDirectory)
* ------+ js
* ----+ public .....(resourceDirectory in Assets)
* ----+ public .....(Assets / resourceDirectory)
* ------+ css
* ------+ images
* ------+ js
* --+ test
* ----+ assets .....(sourceDirectory in TestAssets)
* ----+ assets .....(TestAssets / sourceDirectory)
* ------+ js
* ----+ public .....(resourceDirectory in TestAssets)
* ----+ public .....(TestAssets / resourceDirectory)
* ------+ css
* ------+ images
* ------+ js
Expand Down Expand Up @@ -569,6 +569,18 @@ object SbtWeb extends AutoPlugin {
(fs.toStream flatMap { f => f(a).toSeq }).headOption
}

/**
* Deduplicator that selects the first file contained in the base directory.
*
* @param base
* the base directory to check against
* @return
* a deduplicator function that prefers files in the base directory
*/
def selectFileFrom(base: File): Deduplicator = { (files: Seq[File]) =>
files.find(_.relativeTo(base).isDefined)
}

/**
* Deduplicator that checks whether all duplicates are directories and if so will simply select the first one.
*
Expand Down
6 changes: 3 additions & 3 deletions src/sbt-test/sbt-web/asset-pipeline/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ val coffee = taskKey[Seq[File]]("mock coffeescript processing")

coffee := {
// translate .coffee files into .js files
val sourceDir = (sourceDirectory in Assets).value
val sourceDir = (Assets / sourceDirectory).value
val targetDir = target.value / "cs-plugin"
val sources = sourceDir ** "*.coffee"
val mappings = sources pair Path.relativeTo(sourceDir)
val renamed = mappings map { case (file, path) => file -> path.replaceAll("coffee", "js") }
val copies = renamed map { case (file, path) => file -> (resourceManaged in Assets).value / path }
val copies = renamed map { case (file, path) => file -> (Assets / resourceManaged).value / path }
IO.copy(copies)
copies map (_._2)
}

sourceGenerators in Assets += coffee.taskValue
Assets / sourceGenerators += coffee.taskValue

val jsmin = taskKey[Pipeline.Stage]("mock js minifier")

Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/sbt-web/deduplicate/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
lazy val root = (project in file(".")).enablePlugins(SbtWeb)

WebKeys.deduplicators in Assets += SbtWeb.selectFileFrom((sourceDirectory in Assets).value)
Assets / WebKeys.deduplicators += SbtWeb.selectFileFrom((Assets / sourceDirectory).value)
2 changes: 1 addition & 1 deletion src/sbt-test/sbt-web/dev-pipeline/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ transform := {
}
}

pipelineStages in Assets := Seq(transform)
Assets / pipelineStages := Seq(transform)
2 changes: 1 addition & 1 deletion src/sbt-test/sbt-web/multi-module/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ lazy val b = (project in file("modules/b"))
.enablePlugins(SbtWeb)
.dependsOn(c % "compile;test->test", d % "compile;test->test")
.settings(
WebKeys.directWebModules in TestAssets := Nil
TestAssets / WebKeys.directWebModules := Nil
)

lazy val c = (project in file("modules/c"))
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/sbt-web/multi-module/test
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ $ exists modules/e/target/web/public/test/lib/jquery/jquery.js

# Let's optimize the syncing

> set trackInternalDependencies in ThisBuild := TrackLevel.TrackIfMissing
> set ThisBuild / trackInternalDependencies := TrackLevel.TrackIfMissing

> a/assets

Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/sbt-web/package/test
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $ exists target/web-project-0.1-web-assets.jar
$ exists extracted/js/a.js
$ exists extracted/lib/jquery/jquery.js

> 'set WebKeys.packagePrefix in Assets := "public/"'
> 'set Assets / WebKeys.packagePrefix := "public/"'
> web-assets:package

$ delete extracted
Expand Down

0 comments on commit cbee7d8

Please sign in to comment.