ksoichiro / gradle-web-resource-plugin

Gradle plugin to use CoffeeScript, LESS and Bower libraries without Node.js/npm.
Apache License 2.0
23 stars 5 forks source link

Add some wayt to add additional params to bower #12

Closed sratatata closed 8 years ago

sratatata commented 8 years ago

Can't use workaround for problem: https://github.com/bower/bower/issues/866

It would be nice to add some way of bypassing some params to bower. like --force for example. It's done nice in gradle-appengine-plugin:

appcfg {
    ...
        extraOptions=["--oauth2_refresh_token="+oauth2_refresh_token,
        "--application="+googleAppId,
        "--version="+googleAppVersion]
    }

Deps:

dependencies {
            install name: "jquery", version: "1.10.2"
            install name: "bootstrap", version: "3.3.6"
            install name: "angular", version: "1.5.0"
            install name: "angular-bootstrap", version: "1.1.2"
            install name: "angular-route", version: "1.5.0"
            install name: "angular-scroll", version: "1.0.0"
            install name: "font-awesome", version: "4.5.0"
            install name: "angular-ui-tinymce", version: "0.0.12"
            install name: "angular-translate", version: "2.9.0"
            install name: "angular-translate-loader-static-files", version: "2.9.0"
            install name: "angular-google-client", version: "2.0.2"
        }

Reference:

 message: 'Unable to find suitable version for angular',
  code: 'ECONFLICT',
  name: 'angular',
  picks: 
   [ { endpoint: [Object],
       canonicalDir: '/home/w.zarski/.cache/bower/packages/ef2188def21eb1bbd1f1792311942a53/1.4.9',
       pkgMeta: [Object],
       dependencies: {},
       nrDependants: 1,
       dependants: [Object] },
     { endpoint: [Object],
       canonicalDir: '/home/w.zarski/Projects/GIT/BIL/smart-novel/smart-novel/publisher/build/webResource/bower_components/angular',
       pkgMeta: [Object],
       dependencies: {},
       nrDependants: 2,
       dependants: [Object] },
     { endpoint: [Object],
       canonicalDir: '/home/w.zarski/.cache/bower/packages/ef2188def21eb1bbd1f1792311942a53/1.5.0',
       pkgMeta: [Object],
       dependencies: {},
       nrDependants: 1,
       dependants: [Object] },
     { endpoint: [Object],
       canonicalDir: '/home/w.zarski/.cache/bower/packages/ef2188def21eb1bbd1f1792311942a53/1.5.0',
       pkgMeta: [Object],
       dependencies: {},
       nrDependants: 1,
       dependants: [Object] },
     { endpoint: [Object],
       canonicalDir: '/home/w.zarski/.cache/bower/packages/ef2188def21eb1bbd1f1792311942a53/1.5.0',
       pkgMeta: [Object],
       dependencies: {},
       nrDependants: 1,
       dependants: [Object] } ],
  fileName: '/home/w.zarski/Projects/GIT/BIL/smart-novel/smart-novel/publisher/build/webResource/node_modules/bower/lib/core/Manager.js',
  lineNumber: 819,
  stack: 'angular: Unable to find suitable version for angular\n    at /home/w.zarski/Projects/GIT/BIL/smart-novel/smart-novel/publisher/build/webResource/node_modules/q/q.js:1763\n    at _fulfilled (/home/w.zarski/Projects/GIT/BIL/smart-novel/smart-novel/publisher/build/webResource/node_modules/q/q.js:834)\n    at /home/w.zarski/Projects/GIT/BIL/smart-novel/smart-novel/publisher/build/webResource/node_modules/q/q.js:863\n    at /home/w.zarski/Projects/GIT/BIL/smart-novel/smart-novel/publisher/build/webResource/node_modules/q/q.js:796\n    at /home/w.zarski/Projects/GIT/BIL/smart-novel/smart-novel/publisher/build/webResource/node_modules/q/q.js:556\n    at runSingle (/home/w.zarski/Projects/GIT/BIL/smart-novel/smart-novel/publisher/build/webResource/node_modules/q/q.js:137)\n    at flush (/home/w.zarski/Projects/GIT/BIL/smart-novel/smart-novel/publisher/build/webResource/node_modules/q/q.js:125)\n    at processImmediate (timers.js:370)\n' }
:publisher:webResourceInstallBowerDependencies FAILED
ksoichiro commented 8 years ago

OK, I'll add an option for it.

ksoichiro commented 8 years ago

I've added two ways to solve this issue (not yet released).

1. bower.dependencies.resolve

This is equivalent to "resolutions" attribute in bower.json.

webResource {
    bower {
        dependencies {
            install name: "bootstrap", version: "3.3.6"
            install name: "angular", version: "1.5.0"

            // Add this to resolve conflict
            resolve name: "angular", version: "1.5.0"
        }

2. --force-latest option

You can also resolve conflict by setting "--force-latest" option to "options". This will be passed to bower's install command.

webResource {
    bower {
        // Add this to resolve conflict
        options = ["--force-latest"]

If you omit these options, the plugin will suggest to add "resolve" option.

23:30:26.418 ERROR [Bower] Install failed: Unable to find a suitable version for angular while installing angular-translate#2.9.0.
23:30:26.419 WARN  [Bower] To resolve this conflict, please define resolution to your build.gradle.
23:30:26.420 WARN  [Bower] Example:
23:30:26.421 WARN  [Bower]     bower {
23:30:26.421 WARN  [Bower]         dependencies {
23:30:26.421 WARN  [Bower]             resolve name: 'angular', version: '1.4.9'
23:30:26.422 WARN  [Bower]         }
23:30:26.422 WARN  [Bower]     }
23:30:26.423 WARN  [Bower] Candidate versions:
23:30:26.424 WARN  [Bower]     1) angular#>=1.2.26 <=1.5 which resolved to 1.4.9 and is required by angular-translate#2.9.0
23:30:26.426 WARN  [Bower]     2) angular#1.5.0 which resolved to 1.5.0 and is required by angular-route#1.5.0
23:30:26.427 WARN  [Bower]     3) angular#>=1.4.0 which resolved to 1.5.0 and is required by angular-bootstrap#1.1.2
23:30:26.428 WARN  [Bower]     4) angular#^1.2.16 which resolved to 1.5.0 and is required by angular-scroll#1.0.0
23:30:26.428 WARN  [Bower]     5) angular#~1.x which resolved to 1.5.0 and is required by angular-ui-tinymce#0.0.12
23:30:26.429 WARN  [Bower] Some candidates might not be shown above because they are not installed yet.
23:30:26.429 WARN  [Bower] This is a limitation of this plugin.
ksoichiro commented 8 years ago

I've released v1.4.0 that includes two new options above. Please try it when you have time.

sratatata commented 8 years ago

Wow! Thanks. Great!