-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripted test to hande multiple extracted versions of same webjar
- Loading branch information
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/sbt-test/sbt-less-plugin/less-same-webjars-different-version/build.sbt
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,12 @@ | ||
lazy val root = (project in file(".")).enablePlugins(SbtWeb) | ||
|
||
val checkMapFileContents = taskKey[Unit]("check that map contents are correct") | ||
|
||
checkMapFileContents := { | ||
val contents = IO.read((Assets / WebKeys.public).value / "css" / "main.min.css.map") | ||
val expectedContents = """{"version":3,"sources":["main.less"],"names":[],"mappings":"AAAA,GACE","file":"main.min.css"}""" | ||
|
||
if (contents != expectedContents) { | ||
sys.error(s"Unexpected contents: $contents, \nexpected: $expectedContents") | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/sbt-test/sbt-less-plugin/less-same-webjars-different-version/project/plugins.sbt
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,29 @@ | ||
addSbtPlugin("com.github.sbt" % "sbt-less" % sys.props("project.version")) | ||
|
||
// When the same webjar (= same name) from different groupIds (org.webjars[.npm|bower]?) | ||
// are are on the classpath, those webjars get extracted into subfolders which are named by the version of the webjar. | ||
// However, if there is just one type (npm, bower, classic) of a webjar on the classpath, NO subfolders gets created. | ||
// Now, because in a project we don't know which other webjars get pulled in from other dependencies, it can happen | ||
// that subfolders get created, or may not. However, require(...) can't know that and therefore has to look in both places. | ||
// To test that the lookup is correct, we force this scripted test to create subfolders by pulling in the same webjar | ||
// but from different groupIds (the other scripted test does not do that and therefore no subfolders get created there) | ||
// btw: dependency eviction within the same type of webjar still works correctly, so e.g. 0.2 wins over 0.1 within the same type of webjar | ||
// and no subfolder will be forced for that case but the newest version will be choosen. Like normal dependency resolution. | ||
libraryDependencies ++= Seq( | ||
// Pulling in the classic and the npm webjar to subfolders for this webjar will be created | ||
"org.webjars" % "mkdirp" % "0.3.5", | ||
"org.webjars.npm" % "mkdirp" % "0.5.1", | ||
|
||
// Same here, we pull in the bower and the npm one so subfolders will be created | ||
// ("3.8.1/ and 3.8.1 etc.) | ||
"org.webjars" % "less" % "3.8.1", | ||
"org.webjars.npm" % "less" % "3.8.1", | ||
|
||
|
||
// and so on... | ||
"org.webjars.npm" % "es6-promise" % "4.1.0", | ||
"org.webjars" % "es6-promise" % "2.1.1", | ||
|
||
"org.webjars.npm" % "less-plugin-clean-css" % "1.5.1" intransitive(), | ||
// TODO: there was no other webjars type for less-plugin-clean-css currently | ||
) |
3 changes: 3 additions & 0 deletions
3
...bt-test/sbt-less-plugin/less-same-webjars-different-version/src/main/assets/css/main.less
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,3 @@ | ||
h1 { | ||
color: blue | ||
} |
21 changes: 21 additions & 0 deletions
21
src/sbt-test/sbt-less-plugin/less-same-webjars-different-version/test
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,21 @@ | ||
# Compile a less file | ||
|
||
> assets | ||
$ exists target/web/public/main/css/main.css | ||
$ exists target/web/public/main/css/main.css.map | ||
|
||
# Compile with compression | ||
|
||
> set Assets / LessKeys.compress := true | ||
> assets | ||
-$ exists target/web/public/main/css/main.css | ||
-$ exists target/web/public/main/css/main.css.map | ||
$ exists target/web/public/main/css/main.min.css | ||
$ exists target/web/public/main/css/main.min.css.map | ||
> checkMapFileContents | ||
|
||
# Compile without sourceMaps | ||
> set Assets / LessKeys.sourceMap := false | ||
> assets | ||
$ exists target/web/public/main/css/main.min.css | ||
-$ exists target/web/public/main/css/main.min.css.map |