{"action":"created","issue":{"url":"https://api.github.com/repos/mycila/license-maven-plugin/issues/107","repository_url":"https://api.github.com/repos/mycila/license-maven-plugin","labels_url":"https://api.github.com/repos/mycila/license-maven-plugin/issues/107/labels{/name}","comments_url":"https://api.github.com/repos/mycila/license-maven-plugin/issues/107/comments","events_url":"https://api.github.com/repos/mycila/license-maven-plugin/issues/107/events","html_url":"https://github.com/mycila/license-maven-plugin/issues/107","id":169985464,"number":107,"title":"Custom mapping seems to not honor order from configuration","user":{"login":"shane-hp","id":15145531,"avatar_url":"https://avatars.githubusercontent.com/u/15145531?v=3","gravatar_id":"","url":"https://api.github.com/users/shane-hp","html_url":"https://github.com/shane-hp","followers_url":"https://api.github.com/users/shane-hp/followers","following_url":"https://api.github.com/users/shane-hp/following{/other_user}","gists_url":"https://api.github.com/users/shane-hp/gists{/gist_id}","starred_url":"https://api.github.com/users/shane-hp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shane-hp/subscriptions","organizations_url":"https://api.github.com/users/shane-hp/orgs","repos_url":"https://api.github.com/users/shane-hp/repos","events_url":"https://api.github.com/users/shane-hp/events{/privacy}","received_events_url":"https://api.github.com/users/shane-hp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-08T17:57:56Z","updated_at":"2016-08-08T22:50:35Z","closed_at":null,"body":"I am using 2.11 and the mapping configuration is not working as expected and documented. It seems like the mapping is handled in alphabetical order, not configuration order.\r\n\r\nIf I add a custom mapping like this:\r\n\r\n\\<mapping>\r\n\\<xml.tmpl>XML_STYLE\\</xml.tmpl>\r\n\\<tmpl>SCRIPT_STYLE\\</tmpl>\r\n\\</mapping>\r\n\r\nThe *.tmpl mapping is always chosen for my *xml.tmpl files. I would expect the *xml.tmpl files to match to the *.xml.tmpl mapping, which is XML, not SCRIPT. \r\n\r\nThis is how it is described in the documentation: \"You can use composed-extensions like *.apt.vm and redefine them, but you will have to nake sure that the mapping of apt.vm is before the mapping of the vm extension. The order in the mapping section is important: extensions seen first take precedence.\"\r\n\r\nI am not a Maven plugin expert with respect to coding one, but it seems like the problem is that the mapping is brought in as a HashMap, which will lose the order. Later on, it is moved to a LinkedHashMap; however, the order is already lost. I am not sure where the configuration is put into alphabetical order, perhaps in the Maven base code for plugins.\r\n\r\nFrom AbstractLicenseMojo line 159 - 160:\r\n@Parameter\r\npublic Map<String, String> mapping = new HashMap<String, String>();\r\n\r\nI then took a look at the test cases in this plugin to see if I was doing my mapping wrong, but I think the problem is that the test is not catching the issue due to the test case having mappings being \"randomly\" in alphabetical order, as \"apt.vm\" comes before \"vm\" alphabetically. This means that the alphabetical nature will not catch the ordering problem.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/mycila/license-maven-plugin/issues/comments/238401803","html_url":"https://github.com/mycila/license-maven-plugin/issues/107#issuecomment-238401803","issue_url":"https://api.github.com/repos/mycila/license-maven-plugin/issues/107","id":238401803,"user":{"login":"shane-hp","id":15145531,"avatar_url":"https://avatars.githubusercontent.com/u/15145531?v=3","gravatar_id":"","url":"https://api.github.com/users/shane-hp","html_url":"https://github.com/shane-hp","followers_url":"https://api.github.com/users/shane-hp/followers","following_url":"https://api.github.com/users/shane-hp/following{/other_user}","gists_url":"https://api.github.com/users/shane-hp/gists{/gist_id}","starred_url":"https://api.github.com/users/shane-hp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shane-hp/subscriptions","organizations_url":"https://api.github.com/users/shane-hp/orgs","repos_url":"https://api.github.com/users/shane-hp/repos","events_url":"https://api.github.com/users/shane-hp/events{/privacy}","received_events_url":"https://api.github.com/users/shane-hp/received_events","type":"User","site_admin":false},"created_at":"2016-08-08T22:50:35Z","updated_at":"2016-08-08T22:50:35Z","body":"My research showed that Maven will create a TreeMap for any configurations that are set to be a java.util.Map with the @Parameter. The TreeMap is sorted, hence the alphabetical order of the mappings. The solution seems to be to change the type to a LinkedHashMap and then the order seems to be retained."}}
{"actor":{"display_login":"shane-hp"}}