{"action":"opened","number":74,"pull_request":{"url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/pulls/74","id":52420193,"html_url":"https://github.com/pentaho/pentaho-osgi-bundles/pull/74","diff_url":"https://github.com/pentaho/pentaho-osgi-bundles/pull/74.diff","patch_url":"https://github.com/pentaho/pentaho-osgi-bundles/pull/74.patch","issue_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/issues/74","number":74,"state":"open","locked":false,"title":"[BACKLOG-5522][BACKLOG-5525] Webjars published with versioned path and dependency resolution","user":{"login":"nantunes","id":209365,"avatar_url":"https://avatars.githubusercontent.com/u/209365?v=3","gravatar_id":"","url":"https://api.github.com/users/nantunes","html_url":"https://github.com/nantunes","followers_url":"https://api.github.com/users/nantunes/followers","following_url":"https://api.github.com/users/nantunes/following{/other_user}","gists_url":"https://api.github.com/users/nantunes/gists{/gist_id}","starred_url":"https://api.github.com/users/nantunes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nantunes/subscriptions","organizations_url":"https://api.github.com/users/nantunes/orgs","repos_url":"https://api.github.com/users/nantunes/repos","events_url":"https://api.github.com/users/nantunes/events{/privacy}","received_events_url":"https://api.github.com/users/nantunes/received_events","type":"User","site_admin":false},"body":"This PR supersedes #61 and #68.\n\n\n* All published moduleIds are versioned by webjar-deployer;\n* Metadata enables \"runtime\" dependency resolution by require-osgi-manager;\n* A **new third-party library** was added, requiring pentaho/pentaho-karaf-assembly#160 merge;\n* Duplicate code cleanup and refactoring led to new **pentaho-requirejs-utils** bundle.\n\n\nAll published moduleIds are now versioned, avoiding conflicts between versions.\n\nSample published moduleIds:\n\n```json\n\"paths\": {\n  \"angular-ui-router.stateHelper_1.3.1\": \"angular-ui-router.stateHelper/1.3.1\",\n  \"smart-table-min_2.0.3-1\": \"smart-table/2.0.3-1/smart-table.min\",\n  \"smart-table_2.0.3-1\": \"smart-table/2.0.3-1/smart-table\",\n  \"angular_1.3.0\": \"angularjs/1.3.0/angular\"\n}\n```\n\n* ```WebjarsURLConnection``` reads requirejs configuration from these sources (ordered by priority):\n    1. ```<requirejs>``` property on ```pom.xml``` (handcrafted in Classic WebJars);\n        * Dependencies are read from ```<dependencies>``` node (where ```groupId=org.webjars[.*]```);\n    2. ```webjars-requirejs.js``` script execution (coded by the package's author in Classic WebJars);\n        * No dependency discovery;\n    3. [```package.json```](https://docs.npmjs.com/files/package.json) package definition (present in NPM WebJars) or [```bower.json```](https://github.com/bower/spec/blob/master/json.md) package definition (present in Bower WebJars);\n        * Dependencies are read from ```\"dependencies\"``` property;\n        * If the ```\"main\"``` property (and/or the [```\"browser\"``` property](https://gist.github.com/defunctzombie/4339901)) is found, the developer can require the module using just its Id;\n        * If not, the root path is mapped and the developer must know the package structure for requiring files;\n    4. fallbacks to just mapping the root path (for malformed WebJars);\n        * No dependency discovery;\n        * User must know the package structure for requiring files;\n* Discovered dependency information, if any, is stored in ```\"requirejs-osgi-meta\"``` property for later resolution.\n\nSample meta information:\n\n```json\n\"requirejs-osgi-meta\": {\n  \"modules\": {\n    \"angular-ui-router.stateHelper\": {\n      \"1.3.1\": {\n        \"dependencies\": {\n          \"mvn:org.webjars/angularjs\": \">=1.2.0\",\n          \"angular-ui-router\": \"~0.2.11\"\n        }\n      }\n    }\n  },\n  \"artifacts\": {\n    \"org.webjars.bower/angular-ui-router.stateHelper\": {\n      \"1.3.1\": {\n        \"angular-ui-router.stateHelper\": \"1.3.1\"\n      }\n    }\n  }\n}\n```\n\n\nThe bundle's requirejs configuration will not only keep using ```META-INF/js/require.json``` (mainly preprocessed webjars), but also generate it from the package's information:\n\n* ```RequireJsConfigManager``` looks for ```META-INF/js/require.json``` and parses its contents;\n* If not found, generates it from ```META-INF/js/package.json```.\n* If a valid require config is obtained, it is stored in ```configMap``` (behaviour regarding ```META-INF/js/externalResources.json``` and ```META-INF/js/staticResources.json``` is kept unchanged).\n\nWhen rebuilding the cache the declared dependencies will be resolved.\n\n* ```RebuildCacheCallable``` now calls ```RequireJsDependencyResolver.processMetaInformation``` after merging the different configs;\n* ```RequireJsDependencyResolver``` reads the merged ```\"requirejs-osgi-meta\"``` property;\n* For every ```(moduleId, version)``` pair its dependency list is processed:\n    1. If the dependency is prefixed with ```mvn:``` it is a maven dependency; the maven artifact is resolved first and all of its moduleIds are added as dependencies of the module being processed;\n    2. The version is resolved (supporting [semver ranges](https://github.com/npm/node-semver#ranges)) against the available modules;\n    3. requirejs [maps](http://requirejs.org/docs/api.html#config-map) are setup so the correct versions are loaded when called in the context of the processed module.\n\nSample generated map:\n\n```json\n\"map\": {\n  \"angular-ui-router.stateHelper_1.3.1\": {\n    \"angular\": \"angular_1.3.0\"\n  },\n  \"smart-table-min_2.0.3-1\": {\n    \"angular\": \"angular_1.3.0\",\n    \"smart-table\": \"smart-table_2.0.3-1\"\n  },\n  \"smart-table_2.0.3-1\": {\n    \"angular\": \"angular_1.3.0\",\n    \"smart-table-min\": \"smart-table-min_2.0.3-1\"\n  },\n  \"angular_1.3.0\": {}\n}\n```\n\n\nThe code related to requirejs config generation was moved to the new pentaho-requirejs-utils bundle, because the webjar's preprocessing (in pentaho-webjars-deployer) is essentially the same of ```RequireJsConfigManager```.\n\n```RequireJsMerger``` was also created to reduce ```RebuildCacheCallable``` complexity.\n\n\nIn order to parse and resolve version ranges in semver format [zafarkhaja/jsemver](https://github.com/zafarkhaja/jsemver) library was used.\nThe library is at version 0.9.0 (so not officially not API stable), and it has a slow but steady development (109 commits since Nov 2012).\n\nSo:\n\n* A Component Process is being submitted (JIRA); \n* pentaho/pentaho-karaf-assembly#160 must also be merged.\n\n@pentaho-nbaker and @graimundo","created_at":"2015-12-02T16:37:36Z","updated_at":"2015-12-02T16:37:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/pulls/74/commits","review_comments_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/pulls/74/comments","review_comment_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/issues/74/comments","statuses_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/statuses/b25a74744578808ece2f6e95693b2e215e304a0a","head":{"label":"nantunes:BACKLOG-5525","ref":"BACKLOG-5525","sha":"b25a74744578808ece2f6e95693b2e215e304a0a","user":{"login":"nantunes","id":209365,"avatar_url":"https://avatars.githubusercontent.com/u/209365?v=3","gravatar_id":"","url":"https://api.github.com/users/nantunes","html_url":"https://github.com/nantunes","followers_url":"https://api.github.com/users/nantunes/followers","following_url":"https://api.github.com/users/nantunes/following{/other_user}","gists_url":"https://api.github.com/users/nantunes/gists{/gist_id}","starred_url":"https://api.github.com/users/nantunes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nantunes/subscriptions","organizations_url":"https://api.github.com/users/nantunes/orgs","repos_url":"https://api.github.com/users/nantunes/repos","events_url":"https://api.github.com/users/nantunes/events{/privacy}","received_events_url":"https://api.github.com/users/nantunes/received_events","type":"User","site_admin":false},"repo":{"id":42197512,"name":"pentaho-osgi-bundles","full_name":"nantunes/pentaho-osgi-bundles","owner":{"login":"nantunes","id":209365,"avatar_url":"https://avatars.githubusercontent.com/u/209365?v=3","gravatar_id":"","url":"https://api.github.com/users/nantunes","html_url":"https://github.com/nantunes","followers_url":"https://api.github.com/users/nantunes/followers","following_url":"https://api.github.com/users/nantunes/following{/other_user}","gists_url":"https://api.github.com/users/nantunes/gists{/gist_id}","starred_url":"https://api.github.com/users/nantunes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nantunes/subscriptions","organizations_url":"https://api.github.com/users/nantunes/orgs","repos_url":"https://api.github.com/users/nantunes/repos","events_url":"https://api.github.com/users/nantunes/events{/privacy}","received_events_url":"https://api.github.com/users/nantunes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nantunes/pentaho-osgi-bundles","description":"Repository of Pentaho-specific OSGI Bundles","fork":true,"url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles","forks_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/forks","keys_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/teams","hooks_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/hooks","issue_events_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/issues/events{/number}","events_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/events","assignees_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/assignees{/user}","branches_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/branches{/branch}","tags_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/tags","blobs_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/git/refs{/sha}","trees_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/statuses/{sha}","languages_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/languages","stargazers_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/stargazers","contributors_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/contributors","subscribers_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/subscribers","subscription_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/subscription","commits_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/commits{/sha}","git_commits_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/git/commits{/sha}","comments_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/comments{/number}","issue_comment_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/issues/comments{/number}","contents_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/contents/{+path}","compare_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/merges","archive_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/downloads","issues_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/issues{/number}","pulls_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/pulls{/number}","milestones_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/milestones{/number}","notifications_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/labels{/name}","releases_url":"https://api.github.com/repos/nantunes/pentaho-osgi-bundles/releases{/id}","created_at":"2015-09-09T18:40:49Z","updated_at":"2015-09-09T18:40:50Z","pushed_at":"2015-12-02T16:35:17Z","git_url":"git://github.com/nantunes/pentaho-osgi-bundles.git","ssh_url":"git@github.com:nantunes/pentaho-osgi-bundles.git","clone_url":"https://github.com/nantunes/pentaho-osgi-bundles.git","svn_url":"https://github.com/nantunes/pentaho-osgi-bundles","homepage":null,"size":2475,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pentaho:master","ref":"master","sha":"30ad9ef232b9ef7d7c459b971e7f920202bf52ce","user":{"login":"pentaho","id":1022787,"avatar_url":"https://avatars.githubusercontent.com/u/1022787?v=3","gravatar_id":"","url":"https://api.github.com/users/pentaho","html_url":"https://github.com/pentaho","followers_url":"https://api.github.com/users/pentaho/followers","following_url":"https://api.github.com/users/pentaho/following{/other_user}","gists_url":"https://api.github.com/users/pentaho/gists{/gist_id}","starred_url":"https://api.github.com/users/pentaho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pentaho/subscriptions","organizations_url":"https://api.github.com/users/pentaho/orgs","repos_url":"https://api.github.com/users/pentaho/repos","events_url":"https://api.github.com/users/pentaho/events{/privacy}","received_events_url":"https://api.github.com/users/pentaho/received_events","type":"Organization","site_admin":false},"repo":{"id":22734513,"name":"pentaho-osgi-bundles","full_name":"pentaho/pentaho-osgi-bundles","owner":{"login":"pentaho","id":1022787,"avatar_url":"https://avatars.githubusercontent.com/u/1022787?v=3","gravatar_id":"","url":"https://api.github.com/users/pentaho","html_url":"https://github.com/pentaho","followers_url":"https://api.github.com/users/pentaho/followers","following_url":"https://api.github.com/users/pentaho/following{/other_user}","gists_url":"https://api.github.com/users/pentaho/gists{/gist_id}","starred_url":"https://api.github.com/users/pentaho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pentaho/subscriptions","organizations_url":"https://api.github.com/users/pentaho/orgs","repos_url":"https://api.github.com/users/pentaho/repos","events_url":"https://api.github.com/users/pentaho/events{/privacy}","received_events_url":"https://api.github.com/users/pentaho/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pentaho/pentaho-osgi-bundles","description":"Repository of Pentaho-specific OSGI Bundles","fork":false,"url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles","forks_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/forks","keys_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/teams","hooks_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/hooks","issue_events_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/issues/events{/number}","events_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/events","assignees_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/assignees{/user}","branches_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/branches{/branch}","tags_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/tags","blobs_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/git/refs{/sha}","trees_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/statuses/{sha}","languages_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/languages","stargazers_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/stargazers","contributors_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/contributors","subscribers_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/subscribers","subscription_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/subscription","commits_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/commits{/sha}","git_commits_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/git/commits{/sha}","comments_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/comments{/number}","issue_comment_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/issues/comments{/number}","contents_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/contents/{+path}","compare_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/merges","archive_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/downloads","issues_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/issues{/number}","pulls_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/pulls{/number}","milestones_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/milestones{/number}","notifications_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/labels{/name}","releases_url":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/releases{/id}","created_at":"2014-08-07T19:52:07Z","updated_at":"2015-09-21T21:01:04Z","pushed_at":"2015-12-02T16:37:37Z","git_url":"git://github.com/pentaho/pentaho-osgi-bundles.git","ssh_url":"git@github.com:pentaho/pentaho-osgi-bundles.git","clone_url":"https://github.com/pentaho/pentaho-osgi-bundles.git","svn_url":"https://github.com/pentaho/pentaho-osgi-bundles","homepage":null,"size":2481,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":3,"forks":22,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/pulls/74"},"html":{"href":"https://github.com/pentaho/pentaho-osgi-bundles/pull/74"},"issue":{"href":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/issues/74"},"comments":{"href":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/issues/74/comments"},"review_comments":{"href":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/pulls/74/comments"},"review_comment":{"href":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/pulls/74/commits"},"statuses":{"href":"https://api.github.com/repos/pentaho/pentaho-osgi-bundles/statuses/b25a74744578808ece2f6e95693b2e215e304a0a"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":12,"additions":4631,"deletions":869,"changed_files":34}}