Closed sratatata closed 8 years ago
Thank you for trying this plugin! I'm glad you like it.
I confirmed the issue after a lots of tests. That's weird.. The plugin should download transitive dependencies too, but it seems it sometimes doesn't download. I'll look further into it.
Got it!!!!! In my opinion there is problem with making a copy of libs from build/bower-components to src/.../libs directory. Please find some details below:
My config is:
webResource {
base {
src 'src/main'
dest 'src/main/webapp/static'
}
bower {
dependencies {
install name: "bootstrap", version: "3.3.6"
install name: "angular", version: "latest"
install name: "angular-route", version: "latest"
install name: "font-awesome", version: "latest"
}
}
}
after running plugin:
src/main/webapp/static/lib/
├── angular
├── angular-route
├── bootstrap
└── font-awesome
However in build directory, transitive libs are visible (in this case jquery):
build
└── webResource
├── bower_components
│ ├── angular
│ ├── angular-route
│ ├── bootstrap
│ ├── font-awesome
│ └── jquery
├── bower.js
├── common.js
└── node_modules
Problem is with this method:
plugin/src/main/groovy/com/github/ksoichiro/web/resource/task/WebResourceCopyBowerDependenciesTask.groovy ->
void copyDependencies() {
project.copy {
from project.fileTree("${extension.workDir}/bower_components").matching {
extension.bower.dependencies.each { dependency ->
String[] expr = dependency.filter
if (expr) {
expr.each { e -> it.include("${dependency.getCacheName()}/${e}") }
} else {
it.include("${dependency.getCacheName()}/**/*")
}
}
}
into "${extension.base.dest}/${extension.lib.dest}"
}
}
You are making a copy within a loop based on bower.dependencies which are declared in config. In this case transitive dependencies are skipped.
This could be done in 2 ways: 1) Lazy solution: copy all files without matching (however this could be problematic if some one would not clean it before) 2) Load bower.json from each directory and check dependencies, copy only them - however it's duplication over bower behavior.
Ma favorite is first solution, because dosn't introduce any behavior duplication and let bower manage versions. However it's your project, you have better insight. What do you thing? Do you have time to implement this? If not, I can do this but would need some advice.
Thank you for your investigation and suggestions! And sorry, I misunderstood the problem. The problem I mentioned is another new problem (I'll report it later).
1) Lazy solution: copy all files without matching (however this could be problematic if some one would not clean it before) 2) Load bower.json from each directory and check dependencies, copy only them - however it's duplication over bower behavior.
Yes, as you say, the first one seems better.
Cleaning old dependencies should be handled in other way, such as bower prune
, I think.
If you have time to implement this, please do it and send me a PR :)
If you have time to implement this, please do it and send me a PR :)
that's the problem. However I would try do this during some weekend.
PS. I've also noticed strange problem with downloading dependencies to differ directory then specified in build.gradle. But I ask my colleague on whose computer issue occurred (only one).
Thanks.
I've also noticed strange problem with downloading dependencies to differ directory then specified in build.gradle. But I ask my colleague on whose computer issue occurred (only one).
Sorry, I don't understand the problem. Are there any problems with downloading...? Please let me know details when you have time.
Mentioned in "PS" problem is new and is in this issue: wrong download path #5 Sorry for offtopic here. Nevermind.
I would create pull request. But I'm not able to test in decently. Tests and gradle setup is fragile. If you could specify in topic https://github.com/ksoichiro/gradle-web-resource-plugin/issues/8 how to setup proper testing environemnt it would be great help here.
I've added an option named 'bower.copyAll' for this. It'll be available from version 1.5.0.
I've released v1.5.0. You can use this option to solve this issue.
webResource {
bower {
copyAll true
}
}
When I'm adding dependency to bootstrap and calling webResourceCompile task, bootstrap is downloaded, but jquery which is bootstrap dependency is not downloaded.
It's by design, or not yet implemented? Does this feature is planned?
PS. I love this plugin! You have make my day!!!