{"id":12195,"date":"2014-02-27T12:33:22","date_gmt":"2014-02-27T07:03:22","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=12195"},"modified":"2016-12-19T15:17:46","modified_gmt":"2016-12-19T09:47:46","slug":"groovy-integration-with-cq5-in-maven","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/groovy-integration-with-cq5-in-maven\/","title":{"rendered":"Groovy Integration with CQ5"},"content":{"rendered":"<div>\n<p>Groovy being one of the fresh open source platforms in the market of Programming language, it is attracting Developer to use it because of its friendliness, easy codeabiltiy and many other features.<\/p>\n<p>Tempted by many of such features, <a title=\"CQ5 Developers\" href=\"http:\/\/www.tothenew.com\/wcm\/cq-aem-development-consulting\">CQ developers are also inclining<\/a> towards using Groovy in CQ environment. To the rescue of many such CQ developers, in this blogI am going to cover how to get integrate <span style=\"text-decoration: underline;\"><strong>Groovy<\/strong><\/span> with CQ5 environment.<\/p>\n<p>As Sling Framwork provides built-in support for groovy (<a href=\"https:\/\/issues.apache.org\/jira\/browse\/SLING-315\">https:\/\/issues.apache.org\/jira\/browse\/SLING-315<\/a>) , so it can be done simply by uploading the latest groovy jar to the Felix. But the limitation is, this jar only allows your CQ5 environment to compile the groovy script i.e groovy compiler in CQ5 environment.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">PROBLEM<\/span><\/strong><\/p>\n<p>One of the few problems that arises while using <strong>Groovy with maven,<\/strong> you need to specify the <strong>Compiler Plugin<\/strong> which is to be used to compile the source of your project. Reason being, the default compiler, javac, cannot compile groovy classes. So you need to add the <strong>Groovy-eclipse-compiler <\/strong>in the plugin section of parent <strong>pom.xml<\/strong> as guided on .<\/p>\n<p>Limitation of using <strong>Groovy-eclipse-compiler<\/strong> plugin directly with IntelliJ Idea , is that the bundle of the module using this plugin will not become active , it will remain in Installed state with some dependency issues.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">SOLUTION<\/span><\/strong><\/p>\n<p>After checking a few plugins suggested by many of my CQ developers, I added the same Plugins that were used by <a href=\"https:\/\/github.com\/Citytechinc\/cq-groovy-console\">cq-groovy-console<\/a> (<a href=\"https:\/\/github.com\/Citytechinc\/cq-groovy-console\/blob\/develop\/pom.xml\">https:\/\/github.com\/Citytechinc\/cq-groovy-console\/blob\/develop\/pom.xml<\/a>)<\/p>\n<p>To install the plugin\/s, add the following code to the parent POM.It will allow the bundle to get installed in the Active State.<\/p>\n<p>[js]&amp;lt;plugins&amp;gt;<br \/>\n                &amp;lt;plugin&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;groupId&amp;gt;org.codehaus.groovy&amp;lt;\/groupId&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;artifactId&amp;gt;groovy-eclipse-compiler&amp;lt;\/artifactId&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;version&amp;gt;2.8.0-01&amp;lt;\/version&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;extensions&amp;gt;true&amp;lt;\/extensions&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;dependencies&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;dependency&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;groupId&amp;gt;org.codehaus.groovy&amp;lt;\/groupId&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;artifactId&amp;gt;groovy-eclipse-batch&amp;lt;\/artifactId&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;version&amp;gt;2.1.8-01&amp;lt;\/version&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;\/dependency&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;\/dependencies&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;\/plugin&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;plugin&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;artifactId&amp;gt;maven-compiler-plugin&amp;lt;\/artifactId&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;version&amp;gt;3.1&amp;lt;\/version&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;configuration&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;compilerId&amp;gt;groovy-eclipse-compiler&amp;lt;\/compilerId&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;source&amp;gt;1.7&amp;lt;\/source&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;target&amp;gt;1.7&amp;lt;\/target&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;encoding&amp;gt;utf-8&amp;lt;\/encoding&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;\/configuration&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;dependencies&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;dependency&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;groupId&amp;gt;org.codehaus.groovy&amp;lt;\/groupId&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;artifactId&amp;gt;groovy-eclipse-compiler&amp;lt;\/artifactId&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;version&amp;gt;2.8.0-01&amp;lt;\/version&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;\/dependency&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;dependency&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;groupId&amp;gt;org.codehaus.groovy&amp;lt;\/groupId&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;artifactId&amp;gt;groovy-eclipse-batch&amp;lt;\/artifactId&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;version&amp;gt;2.1.8-01&amp;lt;\/version&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;\/dependency&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;\/dependencies&amp;gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&amp;lt;\/plugin&amp;gt;<br \/>\n&amp;lt;\/plugins&amp;gt;[\/js]<\/p>\n<\/div>\n<p>Above code works good with JDK 1.7 as well as with the legacy version. You can also use the\u00a02.8.0-01 version of groovy-eclipse-compiler and 2.1.8-01 version of groovy-eclipse-batch as suggested on\u00a0\u00a0http:\/\/groovy.codehaus.org\/Groovy-Eclipse+compiler+plugin+for+Maven\u00a0.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Groovy being one of the fresh open source platforms in the market of Programming language, it is attracting Developer to use it because of its friendliness, easy codeabiltiy and many other features. Tempted by many of such features, CQ developers are also inclining towards using Groovy in CQ environment. To the rescue of many such [&hellip;]<\/p>\n","protected":false},"author":111,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1},"categories":[7],"tags":[1235,1205,9,1341,1340],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/12195"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/111"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=12195"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/12195\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=12195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=12195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=12195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}