Closed oris4ecm closed 10 years ago
Transitive dependencies can override versions. You can exclude the transitive deps in artifact resolution. sbt produces some nice reports for looking at how the versions were selected. Look in your target/resolution-cache/reports
dir.
Let me know if that helps.
I tried making any webjar that depends on another intransitive()
just as a test to see if that would solve the issue:
"org.webjars" % "font-awesome" % "4.0.3" intransitive(),
"org.webjars" % "jquery" % "1.11.1",
"org.webjars" % "bootstrap" % "3.0.3" intransitive(),
"org.webjars" % "bootstrap-datepicker" % "1.3.0-3" intransitive(),
"org.webjars" % "bootstrapvalidator" % "0.5.0" intransitive(),
"org.webjars" % "jquery-cookie" % "1.4.1" intransitive(),
"org.webjars" % "d3js" % "3.4.11",
"org.webjars" % "hoganjs" % "3.0.2",
"org.webjars" % "momentjs" % "2.8.3",
"org.webjars" % "tagmanager" % "3.0.1" intransitive(),
"org.webjars" % "typeaheadjs" % "0.10.4-1",
"org.webjars" % "zTree" % "3.5.15" intransitive(),
However, the compiled output is similar (but with different libs missing):
requirejs.config ( {"paths":{"typeaheadjs":["/webjars/typeaheadjs/0.10.4-1/typeahead.jquery","typeahead.jquery"]}} );
requirejs.config ( {} );
requirejs.config ( {} );
requirejs.config ( {"paths":{"bootstrapvalidator":["/webjars/bootstrapvalidator/0.5.0/js/bootstrapValidator","js/bootstrapValidator"]},"shim":{"bootstrapvalidator":["bootstrap","jquery"]}} );
requirejs.config ( {} );
requirejs.config ( {"paths":{"d3js":["/webjars/d3js/3.4.11/d3","d3"]},"shim":{"d3js":{"exports":"d3"}}} );
requirejs.config ( {"paths":{"jquery":["/webjars/jquery/1.11.1/jquery","jquery"]},"shim":{"jquery":{"exports":"$"}}} );
requirejs.config ( {} );
requirejs.config ( {} );
requirejs.config ( {"paths":{"bootstrap-datepicker":["/webjars/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker","js/bootstrap-datepicker"]},"shim":{"bootstrap-datepicker":["bootstrap"]}} );
requirejs.config ( {} );
requirejs.config ( {"paths":{"momentjs":["/webjars/momentjs/2.8.3/moment","moment"],"moment":["/webjars/momentjs/2.8.3/moment","moment"],"moment-with-locales":["/webjars/momentjs/2.8.3/min/moment-with-locales","min/moment-with-locales"]}} );
requirejs.config ( {} );
requirejs.config ( {} );
(note that the typeahead module doesn't have deps in its POM, thought it should be dependant on bootstrap??)
EDIT: I should note that the files simply aren't loading (404 error) eg: http://localhost:9000/assets/javascripts/bootstrap.js
Can you file a bug about typeahead not having the right transitive dep?
I'm not seeing the version mismatch. Which versions are different?
AFAIK, there should be no version mismatch now (since every webjar that would declare a dependency is marked intransitive()
). However, most of the webjars fail to load (404) errors. The only webjar that is loading is zTree
(the last one in the list).
Hmm... There shouldn't be any 404ing for this setup. Did you restart your Play app after you changed the deps?
I've restarted (CTRL-D), reloaded, exited activator entirely, cleaned & compiled, etc...
I still get the "Could not read WebJar RequireJS config for" messages too for:
However, everything resolves fine. The jars in the ivy2 cache look fine.
So that means the require config doesn't exist for those WebJars. You can see if the newest version has the require config. If you not can shim your own config in. Or you can file a bug on the WebJar to have it added.
Ok, so I'm trying to shim in the webjars' sources... eg:
requirejs.config ({
"paths" : {
"jquery" : "@routes.WebJarAssets.at(WebJarAssets.locate("jquery.min.js"))",
...
}
});
However, that renders to "jquery/1.11.1/jquery.min.js"
which require then attempts to drop append a .js
to. Any idea how i get the locate to NOT provide the .js
or to tell require to not append it?
I'm beginning to think perhaps webjars isn't the way to go for us, though the niceness of having the sources download as part of our dep management is really killer.
The jquery 1.11.1 WebJar should have the correct require config. For others that don't you can just remove the .js suffix, like:
routes.WebJarAssets.at(WebJarAssets.locate("foo.min.js").stripSuffix(".js"))
My
build.sbt
section for the webjars looks like this:We configure the requirejs section in a page as follows:
When the page renders, the following is generated... (notice that there are ~8 missing configs, including jquery, zTree, etc):
When the app loads (via run) we get the following messages:
As you can see, the versions being reported by the activator ui are NOT those that were specified in the
build.sbt
Any thoughts on what is going on?