forked from richdougherty/sbt-coffeescript
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from mkurz/fallback
Handle multiple extracted versions of same webjar
- Loading branch information
Showing
6 changed files
with
63 additions
and
4 deletions.
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
22 changes: 22 additions & 0 deletions
22
src/sbt-test/sbt-coffeescript-plugin/coffee-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,22 @@ | ||
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 / "coffee" / "a.js.map") | ||
if (contents != """{ | ||
| "version": 3, | ||
| "file": "a.js", | ||
| "sourceRoot": "", | ||
| "sources": [ | ||
| "a.coffee" | ||
| ], | ||
| "names": [], | ||
| "mappings": "AAAA;AAAA,MAAA,MAAA,EAAA;;EAAA,MAAA,GAAW;;EACX,QAAA,GAAW;AADX", | ||
| "sourcesContent": [ | ||
| "number = 42\nopposite = true\n" | ||
| ] | ||
|}""".stripMargin) { | ||
sys.error(s"Unexpected contents: $contents") | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...bt-test/sbt-coffeescript-plugin/coffee-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,25 @@ | ||
sys.props.get("project.version") match { | ||
case Some(x) => addSbtPlugin("com.github.sbt" % "sbt-coffeescript" % x) | ||
case _ => sys.error("""|The system property 'project.version' is not defined. | ||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin) | ||
} | ||
|
||
// 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 | ||
// ("1.9.2/ and 2.5.1 etc.) | ||
"org.webjars.bower" % "coffeescript" % "1.9.2", | ||
"org.webjars.npm" % "coffeescript" % "2.5.1", | ||
) |
2 changes: 2 additions & 0 deletions
2
...coffeescript-plugin/coffee-same-webjars-different-version/src/main/assets/coffee/a.coffee
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,2 @@ | ||
number = 42 | ||
opposite = true |
8 changes: 8 additions & 0 deletions
8
src/sbt-test/sbt-coffeescript-plugin/coffee-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,8 @@ | ||
# Compile a CoffeeScript file | ||
|
||
> assets | ||
$ exists target/web/public/main/coffee/a.js | ||
$ exists target/web/public/main/coffee/a.js.map | ||
|
||
> checkMapFileContents | ||
|