Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-11371

Detect the webjar version instead of hard-coding it

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.3-milestone-2
    • Fix Version/s: 6.3-rc-1
    • Component/s: Webjar
    • Labels:
      None
    • Tests:
      Unit
    • Difficulty:
      Medium
    • Similar issues:

      Description

      Right now if you want to use a resource from a WebJar you need to do something like this:

      $services.webjars.url('angularjs/1.2.11/angular.js')
      

      The WebJar version is hard-coded so whenever you update the dependency version in your POM file you need to remember to update your source files. Putting the version in the source files is a bad practice anyway.

      The WebJar version can be determined using the Extension Manager so it shouldn't be mandatory to specify it. You may still want to be able to specify the version if you have multiple applications using different major versions of the same WebJar but the version should be optional.

      I propose this API:

      $services.webjars.url('angularjs', 'angular.js')
      $services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar', 'tree.js')
      

      You just have to specify the WebJar id (which is groupId:artifactId but you can omit the groupId if it is 'org.webjars') and the resource path (starting from the version folder).

      I think we also need a way to pass parameters to a WebJar resource so this should work too:

      $services.webjars.url('angularjs', 'angular.js', {'version': '1.2.11'})
      

      We should of course keep the old API for backwards compatibility.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mflorea Marius Dumitru Florea
                Reporter:
                mflorea Marius Dumitru Florea
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: