{"id":13733702,"url":"https://github.com/ksoichiro/gradle-web-resource-plugin","last_synced_at":"2025-10-27T10:31:46.974Z","repository":{"id":57720898,"uuid":"38532159","full_name":"ksoichiro/gradle-web-resource-plugin","owner":"ksoichiro","description":"Gradle plugin to use CoffeeScript, LESS and Bower libraries without Node.js/npm.","archived":false,"fork":false,"pushed_at":"2018-06-27T10:39:52.000Z","size":504,"stargazers_count":22,"open_issues_count":7,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-01T05:23:36.486Z","etag":null,"topics":["bower","coffeescript","gradle","gradle-plugin","less","lesscss","npm","rhino","trireme"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ksoichiro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-04T11:46:58.000Z","updated_at":"2024-12-04T00:35:44.000Z","dependencies_parsed_at":"2022-08-25T15:51:14.166Z","dependency_job_id":null,"html_url":"https://github.com/ksoichiro/gradle-web-resource-plugin","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksoichiro%2Fgradle-web-resource-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksoichiro%2Fgradle-web-resource-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksoichiro%2Fgradle-web-resource-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksoichiro%2Fgradle-web-resource-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ksoichiro","download_url":"https://codeload.github.com/ksoichiro/gradle-web-resource-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238480857,"owners_count":19479570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bower","coffeescript","gradle","gradle-plugin","less","lesscss","npm","rhino","trireme"],"created_at":"2024-08-03T03:00:47.719Z","updated_at":"2025-10-27T10:31:46.447Z","avatar_url":"https://github.com/ksoichiro.png","language":"Groovy","funding_links":[],"categories":["Plugins"],"sub_categories":["Web application development"],"readme":"# gradle-web-resource-plugin\n\n[![Build Status](https://img.shields.io/travis/ksoichiro/gradle-web-resource-plugin/master.svg?style=flat-square)](https://travis-ci.org/ksoichiro/gradle-web-resource-plugin)\n[![Build status](https://img.shields.io/appveyor/ci/ksoichiro/gradle-web-resource-plugin/master.svg?style=flat-square)](https://ci.appveyor.com/project/ksoichiro/gradle-web-resource-plugin)\n[![Coverage Stagus](https://img.shields.io/coveralls/ksoichiro/gradle-web-resource-plugin/master.svg?style=flat-square)](https://coveralls.io/github/ksoichiro/gradle-web-resource-plugin?branch=master)\n[![Bintray](https://img.shields.io/bintray/v/ksoichiro/maven/gradle-web-resource-plugin.svg?style=flat-square)](https://bintray.com/ksoichiro/maven/gradle-web-resource-plugin/_latestVersion)\n[![Maven Central](http://img.shields.io/maven-central/v/com.github.ksoichiro/gradle-web-resource-plugin.svg?style=flat-square)](https://github.com/ksoichiro/gradle-web-resource-plugin/releases/latest)\n\n\u003e Gradle plugin to use CoffeeScript, LESS and Bower libraries without Node.js/npm.\n\nYou don't have to install `node`, `npm`, `bower`, `gulp`, etc.  \nYou don't have to write `package.json`, `bower.json`, `gulpfile.js`, etc.  \nJust update your `build.gradle` and execute a task.\n\n## Getting started\n\n### Apply plugin in build.gradle\n\nFor Gradle 2.1+:\n\n```gradle\nplugins {\n    id 'com.github.ksoichiro.web.resource' version '1.7.3'\n}\n```\n\nGradle 2.0 and former:\n\n```gradle\nbuildscript {\n    repositories {\n        jcenter()\n    }\n    dependencies {\n        classpath 'com.github.ksoichiro:gradle-web-resource-plugin:1.7.3'\n    }\n}\n\napply plugin: 'com.github.ksoichiro.web.resource'\n```\n\nIf you use SNAPSHOT version:\n\n```gradle\nbuildscript {\n    repositories {\n        jcenter()\n        maven {\n            url 'https://oss.sonatype.org/content/repositories/snapshots/'\n        }\n    }\n    dependencies {\n        classpath 'com.github.ksoichiro:gradle-web-resource-plugin:X.X.X-SNAPSHOT'\n    }\n}\n\napply plugin: 'com.github.ksoichiro.web.resource'\n```\n\n### Configure plugin if you need\n\nSee configuration section for details.\n\n```gradle\nwebResource {\n    bower {\n        dependencies {\n            install name: 'jquery', version: '1.11.2'\n            install name: 'bootstrap', version: '3.3.4'\n        }\n    }\n}\n```\n\n### Put your CoffeeScript and LESS source files\n\n```\nsrc\n└── main\n    ├── coffee\n    │   └── app.coffee\n    └── less\n        └── app.less\n```\n\n### Execute build task\n\n```console\n$ ./gradlew webResourceCompile\n```\n\nYou can see the built resources:\n\n```\nbuild/webResource/outputs\n├── css\n│   └── app.css\n├── js\n│   └── app.js\n└── lib\n    ├── bootstrap\n:\n```\n\n## Why do you need this plugin?\n\nIf I would like to use JavaScript library for browsers,\nBower or this kind of package manager is good to manage dependencies.\nBower can be managed with npm, and npm or Bower works on Node.js,\nso I also need to install Node.js to include JavaScript dependencies into our apps.\n\n[srs/gradle-node-plugin](https://github.com/srs/gradle-node-plugin) does most of all things,\nbut still I (or other team members who writes Java codes usually) need to learn about node, npm, bower, etc.\nThese are so good software but all we want to do is just managing JavaScript dependencies\njust like other jar dependencies.\nI know the Webjars project is also trying to solve this problem,\nbut it supports not all of the JavaScript projects and some of the jars are uploaded\nby someone who we don't know and their contents are not necessarily reliable.\nWe want to use directly the trusted JavaScript projects.\n\nSo I wrapped all of them with a Gradle plugin.\n\n## Dependency\n\n### Git\n\nThis plugin bundles bower, and it depends on git to handle dependencies.  \nTo use bower features, please install git first.\n\n## Task\n\n| Task name          | Description               |\n| ------------------ | ------------------------- |\n| webResourceCompile | Triggers all other tasks. If you need to set task dependency (e.g. `classes.dependsOn 'webResourceCompile'`), you should use this task. |\n| webResourceInstallBowerDependencies | Installs JavaScript dependencies using bower. If the configuration `webResource.bower.dependencies` is empty, this task will be skipped (since v1.6.0). |\n| webResourceCopyBowerDependencies    | Copies bower dependencies which `webResourceInstallBowerDependencies` installed to a certain directory. If the configuration `webResource.bower.dependencies` is empty, this task will be skipped (since v1.6.0). |\n| webResourceCompileCoffeeScript      | Compiles CoffeeScript source files into JavaScript files. If the source directory does not exist, this task will be skipped (since v1.6.0). |\n| webResourceTestCoffeeScript         | Tests CoffeeScript source files with Mocha. If the source directory does not exist, this task will be skipped (since v1.7.0). |\n| webResourceCompileLess              | Compiles LESS source files into CSS files. If the source directory does not exist, this task will be skipped (since v1.6.0). |\n\n## Configuration\n\nAll configurations are optional.\n\n```gradle\nwebResource {\n    base {\n        // Change base directories for src/dest\n        src = 'src/main'\n        dest = 'src/main/resources/static'\n\n        // You can omit '=' like this:\n        // src 'src/main'\n        // dest 'src/main/resources/static'\n    }\n\n    testBase {\n        // Change base directories\n        src = 'src/test'\n    }\n\n    coffeeScript {\n        // Set false if you don't use CoffeeScript related features\n        enabled = true\n        // Change CoffeeScript src/dest directories\n        src = 'coffee'\n        dest = 'js'\n        // Default: ['**/*.coffee']\n        include = ['app.coffee']\n        // Default: ['**/_*.coffee']\n        exclude = ['**/_*.coffee']\n        // Default: true\n        minify = false\n        // Default: true\n        parallelize = true\n    }\n\n    testCoffeeScript {\n        // Set false if you don't test CoffeeScript source files\n        enabled = true\n        // Change CoffeeScript src/dest directories\n        src = 'coffee'\n        dest = 'test'\n    }\n\n    less {\n        // Set false if you don't use LESS related features\n        enabled = true\n        // Change LESS src/dest directories and filter setting\n        src = 'less'\n        dest = 'css'\n        // Default: ['**/*.less']\n        include = ['app.less']\n        // Default: ['**/_*.less']\n        exclude = ['**/_*.less']\n        // Default: true\n        minify = false\n        // Default: true\n        parallelize = true\n\n        // Advanced filters (available from 1.1.0-SNAPSHOT)\n        // If you need complex filtering, try 'filters' configuration.\n        filters {\n            // You can use include/exclude methods here.\n            // 'exclude' excludes files from the current file tree.\n            // 'include' includes files to the current file tree.\n            // For example, with the next 2 filters, we can add\n            // 'bootstrap.less' to the target file set\n            // while ignoring all the other .less files\n            // in bootstrap directory.\n            // (This cannot be achieved with less.include/less.exclude configs.)\n            exclude '**/bootstrap/less/**/*.less'\n            include '**/bootstrap/less/bootstrap.less'\n\n            // You can add more exclude/include if you want.\n            //exclude '**/foo/**/*.less'\n            //include '**/foo/**/bar*.less'\n        }\n    }\n\n    lib {\n        // Change directories for libraries downloaded with bower\n        dest = 'lib'\n    }\n\n    bower {\n        dependencies {\n            // 'filter' filters files like main-bower-files\n            install name: 'jquery', version: '1.11.2', filter: ['dist/*.min.*']\n            install name: 'bootstrap', version: '3.3.4', filter: ['dist/css/*.min.css', 'dist/js/*.min.js', 'dist/fonts/*']\n\n            // You can set your favorite name to 'outputName'.\n            // e.g.\n            //   build/webResource/bower_components/components-font-awesome\n            // will be copied to\n            //   build/webResource/outputs/lib/font-awesome\n            install name: 'components-font-awesome', version: '4.3.0', outputName: 'font-awesome'\n\n            // If there is a conflict, you can resolve it by using \"resolve\"\n            //resolve name: 'jquery', version: '1.9.0'\n        }\n\n        // Set this option to true if you want to copy\n        // all dependencies in build/webResource/bower_components directory\n        // to lib.dest directory.\n        // This is useful when your dependencies have transitive dependencies.\n        // However this option can cause problems that old dependencies\n        // are unintentionally copied, so it is false by default.\n        copyAll true\n\n        // Giving --force-latest option also work for resolving conflict\n        //options = [\"--force-latest\"]\n\n        // You can make bower installation serial, but be careful.\n        // (See \"Parallel installation for bower\" section for details.) \n        //parallelize false\n    }\n}\n```\n\n## Samples\n\nSee [samples](samples) directory.\n\n## Techniques and notes\n\n### General\n\n#### Running on Trireme and Rhino\n\nThis plugin executes node/npm using [Trireme][trireme] and [Rhino][rhino].  \nTherefore the limitations in Trireme and Rhino might affect to the features in this plugin (e.g. performance).\n\n#### Setting task dependency\n\nIf you use this plugin in Java project, you can set task dependency to execute build task provided by this plugin like this:\n\n```gradle\n// If you want to build CoffeeScript/LESS/bower before compiling Java sources,\n// set dependency using 'compileJava' task:\ncompileJava.dependsOn 'webResourceCompile'\n```\n\n### CoffeeScript\n\n#### Including and excluding files\n\nBy default, the `.coffee` files that has prefix '`_`' will be excluded (filtered).\n\nIf you want to include files into some specific files, and want to filter those files, use `include` directive.  \nThis plugin will include this library as a dependency, so you can use it without any configurations.\n\nFor example, in `app.coffee`, you can include `a/_b.coffee` by writing this:\n\n```coffee\n#=include a/_b.coffee\n```\n\nThen `a/_b.coffee` will be exploded into the `app.coffee` just before compiling,  \nand `_b.coffee` itself will be filtered.  \nAs a result, you can see the compiled and concatenated JavaScript file `app.js`.\n\n```coffee\n# a.coffee:\n#=include _b.coffee\nconsole.log 'a'\n\n# _b.coffee:\nconsole.log 'b'\n```\n\n↓\n\n```javascript\n// a.js:\n(function(){console.log(\"b\"),console.log(\"a\")}).call(this);\n\n// b.js: (will not be generated)\n```\n\n### LESS\n\n#### Including and excluding files\n\nBy default, the .coffee/.less files that has prefix '`_`' will be excluded (filtered).\n\nIf you want to include files into some specific files, and want to filter those files, use `import` directive (this feature is provided by LESS).\n\nFor example, in `app.less`, you can include `a/_b.less` by writing this:\n\n```less\n@import 'a/_b.less';\n```\n\nThen `a/_b.less` will be exploded into the `app.less` just before compiling,  \nand `_b.less` itself will be filtered.  \nAs a result, you can see the compiled and concatenated CSS file `app.css`.\n\n```less\n// a.less:\n@import '_b.less';\n#a1 { color #f00; }\n\n// _b.less:\n#b1 { color #fff; }\n```\n\n↓\n\n```css\n/* a.css: */\n#b1{color #fff;}#a1{color #f00;}\n\n/* b.css: (will not be generated) */\n```\n\n### Bower\n\n#### Resolving version conflict\n\nWhen some dependencies have transitive dependencies and they have conflict,\nbower installation will fail.\nTo solve this problem, bower provides `resolutions` config and this plugin\ncan handle this option with `resolve`:\n\n```gradle\nwebResource {\n    bower {\n        dependencies {\n            resolve name: 'angular', version: '1.5.0'\n        }\n    }\n}\n```\n\n#### Offline installation\n\nWhen using parallel installation (default), the plugin will check if\nall the dependencies (including transitive dependencies) are cached.\nIf they all have *exact version* notation and are cached,\ninstallation will be executed using offline option.\nThis is faster than online installation.\n*Exact version* means that the versions that does not include\nany operator symbols to express version range (see [node-semver](https://github.com/npm/node-semver) for details).\n\nFor example, the following notation can be offline because it can be resolved to only 1 artifact.\n\n```gradle\nwebResource {\n    bower {\n        dependencies {\n            install name: \"jquery\", version: \"1.10.2\"\n```\n\nThe following notations are valid but cannot be offline even when cache exists because they can be resolved to several versions. To lock version with cache might cause problems, especially in team development.\n\n```gradle\nwebResource {\n    bower {\n        dependencies {\n            install name: \"jquery\", version: \"\u003e= 1.9.0\"\n            install name: \"angular\", version: \"latest\"\n```\n\n#### Installation behind the proxy\n\nIf you run `webResourceInstallBowerDependencies` behind the proxy server, you must configure proxies for bower with one of the following methods.\n\n##### Configure proxies with environment variables\n\nDefine environment variable `http_proxy` and `https_proxy`.\n\n##### Configure proxies with .bowerrc\n\nCreate `~/.bowerrc` that defines `proxy` and `https-proxy`.\n\n```json\n{\n  \"proxy\": \"http://proxy.local\",\n  \"https-proxy\": \"https://proxy.local\"\n}\n```\n\n#### Parallel and serial installation\n\nBy default, `webResourceInstallBowerDependencies` task will\ninstall dependencies in parallel.  \nThis can be controlled by `webResource.bower.parallelize` option,\nbut we recommend not to overwrite it to `false`.\n\nSerial install have issues around version resolution.  \nWhen `bower.json` is created for each dependency,\nsome dependencies that has child dependencies\nwould install child dependencies without checking\ninstalled or other dependencies.  \nThis will cause unintentional update, for example,\nwhen jquery 1.11.2 is installed at first, and then bootstrap 3.3.4\nis installed, bootstrap will also install jquery 2.2.0\n(current latest stable version) because bootstrap doesn't know\nthat the compatible jquery version is already installed.  \nThis situation cannot be avoided as long as we use this method.  \nTherefore we should execute normal bower installation in parallel.  \nOne reason that we had chosen the serial installation is\nthat bower's install API allows `offline` option that does not use\nany network connections, and it could be used for each dependency\naccording to cache status.  \nOffline installation is faster than one that uses network connection,\nand often it's good for builds at restricted environment,\nbut when you have any dependencies that has child dependencies,\nit is recommended to install them in parallel.\n\n## Contribution\n\nContributions are welcome!  \nPlease check the [contribution guideline](CONTRIBUTING.md) before submitting issues or sending pull requests.\n\n## Thanks\n\nThis plugin deeply depends on these excellent projects.\n\n* [apigee/trireme][trireme]\n    * Node engine for JVM used to execute bower, LESS, JavaScript.\n* [mozilla/rhino][rhino]\n    * JavaScript engine for JVM used as the backend of trireme.\n* [srs/gradle-node-plugin](https://github.com/srs/gradle-node-plugin)\n    * Node/npm wrapper for Gradle to aggregating npm dependencies.\n* [npm/npm](https://github.com/npm/npm)\n    * Node packages manager used in build phase to aggregate Node libraries.\n* [substack/node-browserify](https://github.com/substack/node-browserify)\n    * Used in build phase to merge and remove redundant Node modules.\n* [bower/bower](https://github.com/bower/bower)\n    * Bundled in the plugin jar to manage Browser JavaScript libraries.\n* [less/less.js](https://github.com/less/less.js)\n    * Bundled in the plugin jar to compile LESS files.\n* [jashkenas/coffee-script](https://github.com/jashkenas/coffeescript)\n    * Bundlded in the plugin jar to compile CoffeeScript files.\n* [wiledal/gulp-include](https://github.com/wiledal/gulp-include)\n    * Bundled partially (internal functions) in the plugin jar to use include feature for CoffeeScript.\n* [mishoo/UglifyJS2](https://github.com/mishoo/UglifyJS2)\n    * Bundled in the plugin jar to minify JavaScript files.\n* [kriskowal/q](https://github.com/kriskowal/q)\n    * Bundled in the plugin jar to execute async tasks without native Promise class.\n* [isaacs/glob](https://github.com/isaacs/node-glob)\n    * Bundled in the plugin jar to expand globs for minifying JavaScript files.\n* [mochajs/mocha](https://github.com/mochajs/mocha)\n    * Bundled in the plugin jar to test CoffeeScript files.\n\n## License\n\n    Copyright 2015 Soichiro Kashima\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n        http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n[trireme]:https://github.com/apigee/trireme\n[rhino]:https://github.com/mozilla/rhino\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksoichiro%2Fgradle-web-resource-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fksoichiro%2Fgradle-web-resource-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksoichiro%2Fgradle-web-resource-plugin/lists"}