You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by do...@apache.org on 2013/09/26 01:54:50 UTC
svn commit: r1526335 - in /buildr/trunk: CHANGELOG lib/buildr/ide/idea.rb
spec/ide/idea_spec.rb
Author: donaldp
Date: Wed Sep 25 23:54:49 2013
New Revision: 1526335
URL: http://svn.apache.org/r1526335
Log:
Improve support for auto-detection of ejb and web descriptors within Intellij IDEA project generation.
Modified:
buildr/trunk/CHANGELOG
buildr/trunk/lib/buildr/ide/idea.rb
buildr/trunk/spec/ide/idea_spec.rb
Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1526335&r1=1526334&r2=1526335&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Wed Sep 25 23:54:49 2013
@@ -1,4 +1,6 @@
1.4.13 (Pending)
+* Added: Improve support for auto-detection of ejb and web descriptors
+ within Intellij IDEA project generation.
* Change: Default to setting the "User-Agent" header to "Buildr-VERSION"
when accessing http resources. Maven Central rejects requests
without a User-Agent string.
Modified: buildr/trunk/lib/buildr/ide/idea.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/ide/idea.rb?rev=1526335&r1=1526334&r2=1526335&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/ide/idea.rb (original)
+++ buildr/trunk/lib/buildr/ide/idea.rb Wed Sep 25 23:54:49 2013
@@ -302,7 +302,11 @@ module Buildr #:nodoc:
buildr_project.assets.paths.each {|p| default_webroots[p] = "/" }
webroots = options[:webroots] || default_webroots
default_deployment_descriptors = []
- ['web.xml', 'glassfish-web.xml', 'context.xml'].each do |descriptor|
+ ['web.xml', 'sun-web.xml', 'glassfish-web.xml', 'jetty-web.xml', 'geronimo-web.xml',
+ 'context.xml', 'weblogic.xml',
+ 'jboss-deployment-structure.xml', 'jboss-web.xml',
+ 'ibm-web-bnd.xml', 'ibm-web-ext.xml', 'ibm-web-ext-pme.xml'].
+ each do |descriptor|
webroots.each_pair do |path, relative_url|
next unless relative_url == "/"
d = "#{path}/WEB-INF/#{descriptor}"
@@ -375,15 +379,27 @@ module Buildr #:nodoc:
def add_ejb_facet(options = {})
name = options[:name] || "EJB"
- default_ejb_xml = buildr_project._(:source, :main, :resources, "WEB-INF/ejb-jar.xml")
- ejb_xml = options[:ejb_xml] || default_ejb_xml
- ejb_roots = options[:ejb_roots] || [buildr_project.compile.sources, buildr_project.resources.sources].flatten
+
+ default_ejb_roots = [buildr_project.compile.sources, buildr_project.resources.sources].flatten
+ ejb_roots = options[:ejb_roots] || default_ejb_roots
+
+ default_deployment_descriptors = []
+ ['ejb-jar.xml', 'glassfish-ejb-jar.xml', 'ibm-ejb-jar-bnd.xml', 'ibm-ejb-jar-ext-pme.xml', 'ibm-ejb-jar-ext.xml',
+ 'jboss.xml', 'jbosscmp-jdbc.xml', 'openejb-jar.xml', 'sun-cmp-mapping.xml', 'sun-ejb-jar.xml',
+ 'weblogic-cmp-rdbms-jar.xml', 'weblogic-ejb-jar.xml'].
+ each do |descriptor|
+ ejb_roots.each do |path|
+ d = "#{path}/WEB-INF/#{descriptor}"
+ default_deployment_descriptors << d if File.exist?(d)
+ end
+ end
+ deployment_descriptors = options[:deployment_descriptors] || default_deployment_descriptors
add_facet(name, "ejb") do |facet|
facet.configuration do |c|
c.descriptors do |d|
- if File.exist?(ejb_xml) || default_ejb_xml != ejb_xml
- d.deploymentDescriptor :name => 'ejb-jar.xml', :url => file_path(ejb_xml)
+ deployment_descriptors.each do |deployment_descriptor|
+ d.deploymentDescriptor :name => File.basename(deployment_descriptor), :url => file_path(deployment_descriptor)
end
end
c.ejbRoots do |e|
Modified: buildr/trunk/spec/ide/idea_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/ide/idea_spec.rb?rev=1526335&r1=1526334&r2=1526335&view=diff
==============================================================================
--- buildr/trunk/spec/ide/idea_spec.rb (original)
+++ buildr/trunk/spec/ide/idea_spec.rb Wed Sep 25 23:54:49 2013
@@ -296,6 +296,206 @@ describe Buildr::IntellijIdea do
end
end
+ describe "using add_web_facet" do
+ before do
+ write "src/main/webapp/WEB-INF/web.xml"
+ write "src/main/webapp/WEB-INF/glassfish-web.xml"
+ write "src/main/webapp/WEB-INF/context.xml"
+ write "src/main/webapp/WEB-INF/faces-config.xml"
+
+ @foo = define "foo" do
+ iml.add_web_facet
+ end
+ invoke_generate_task
+ end
+
+ it "generates a web facet with appropriate deployment descriptors" do
+ doc = xml_document(@foo._("foo.iml"))
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
+ doc.should have_nodes(facet_xpath, 1)
+ web_facet_xpath = "#{facet_xpath}[@type='web', @name='Web']"
+ doc.should have_xpath(web_facet_xpath)
+ deployment_descriptor_xpath = "#{web_facet_xpath}/configuration/descriptors/deploymentDescriptor"
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='web.xml', url='file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml']")
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='glassfish-web.xml', url='file://$MODULE_DIR$/src/main/webapp/WEB-INF/glassfish-web.xml']")
+ end
+
+ it "generates a web facet with derived webroots" do
+ doc = xml_document(@foo._("foo.iml"))
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
+ doc.should have_nodes(facet_xpath, 1)
+ web_facet_xpath = "#{facet_xpath}[@type='web', @name='Web']"
+ doc.should have_xpath(web_facet_xpath)
+ doc.should have_xpath("#{web_facet_xpath}/configuration/webroots/root[@url='file://$MODULE_DIR$/src/main/webapp', @realtive='/']")
+ end
+
+ it "generates a web facet with jsf facet auto-detected" do
+ doc = xml_document(@foo._("foo.iml"))
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
+ doc.should have_nodes(facet_xpath, 1)
+ web_facet_xpath = "#{facet_xpath}[@type='web', @name='Web']"
+ doc.should have_xpath(web_facet_xpath)
+ doc.should have_xpath("#{web_facet_xpath}/facet[@type='jsf', @name='JSF']")
+ end
+ end
+
+ describe "using add_web_facet with specified parameters" do
+ before do
+ @foo = define "foo" do
+ iml.add_web_facet(:deployment_descriptors => ["src/main/webapp2/WEB-INF/web.xml"],
+ :enable_jsf => true,
+ :webroots => {"src/main/webapp2" => "/", "src/main/css" => "/css"})
+ end
+ invoke_generate_task
+ end
+
+ it "generates a web facet with appropriate deployment descriptors" do
+ doc = xml_document(@foo._("foo.iml"))
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
+ doc.should have_nodes(facet_xpath, 1)
+ web_facet_xpath = "#{facet_xpath}[@type='web', @name='Web']"
+ doc.should have_xpath(web_facet_xpath)
+ deployment_descriptor_xpath = "#{web_facet_xpath}/configuration/descriptors/deploymentDescriptor"
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='web.xml', url='file://$MODULE_DIR$/src/main/webapp2/WEB-INF/web.xml']")
+ end
+
+ it "generates a web facet with specified webroots" do
+ doc = xml_document(@foo._("foo.iml"))
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
+ doc.should have_nodes(facet_xpath, 1)
+ web_facet_xpath = "#{facet_xpath}[@type='web', @name='Web']"
+ doc.should have_xpath(web_facet_xpath)
+ doc.should have_xpath("#{web_facet_xpath}/configuration/webroots/root[@url='file://$MODULE_DIR$/src/main/webapp2', @realtive='/']")
+ doc.should have_xpath("#{web_facet_xpath}/configuration/webroots/root[@url='file://$MODULE_DIR$/src/main/css', @realtive='/css']")
+ end
+
+ it "generates a web facet with jsf facet enabled" do
+ doc = xml_document(@foo._("foo.iml"))
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
+ doc.should have_nodes(facet_xpath, 1)
+ web_facet_xpath = "#{facet_xpath}[@type='web', @name='Web']"
+ doc.should have_xpath(web_facet_xpath)
+ doc.should have_xpath("#{web_facet_xpath}/facet[@type='jsf', @name='JSF']")
+ end
+ end
+
+ describe "using add_ejb_facet" do
+ before do
+ write "src/main/java/com/bin/foo.java"
+ write "src/main/resources/WEB-INF/ejb-jar.xml"
+
+ @foo = define "foo" do
+ iml.add_ejb_facet
+ end
+ invoke_generate_task
+ end
+
+ it "generates an ejb facet with appropriate deployment descriptors" do
+ doc = xml_document(@foo._("foo.iml"))
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
+ doc.should have_nodes(facet_xpath, 1)
+ web_facet_xpath = "#{facet_xpath}[@type='ejb', @name='EJB']"
+ doc.should have_xpath(web_facet_xpath)
+ deployment_descriptor_xpath = "#{web_facet_xpath}/configuration/descriptors/deploymentDescriptor"
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='ejb-jar.xml', url='file://$MODULE_DIR$/src/main/resources/WEB-INF/ejb-jar.xml']")
+ end
+
+ it "generates an ejb facet with derived ejbRoots" do
+ doc = xml_document(@foo._("foo.iml"))
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
+ doc.should have_nodes(facet_xpath, 1)
+ web_facet_xpath = "#{facet_xpath}[@type='ejb', @name='EJB']"
+ doc.should have_xpath(web_facet_xpath)
+ doc.should have_xpath("#{web_facet_xpath}/configuration/ejbRoots/root[@url='file://$MODULE_DIR$/src/main/java']")
+ doc.should have_xpath("#{web_facet_xpath}/configuration/ejbRoots/root[@url='file://$MODULE_DIR$/src/main/resources']")
+ end
+ end
+
+
+ describe "using add_ejb_facet specifying parameters" do
+ before do
+ @foo = define "foo" do
+ iml.add_ejb_facet(:ejb_roots => ["generated/main/java","generated/main/resources"],
+ :deployment_descriptors => ["generated/main/resources/WEB-INF/ejb-jar.xml"])
+ end
+ invoke_generate_task
+ end
+
+ it "generates an ejb facet with appropriate deployment descriptors" do
+ doc = xml_document(@foo._("foo.iml"))
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
+ doc.should have_nodes(facet_xpath, 1)
+ web_facet_xpath = "#{facet_xpath}[@type='ejb', @name='EJB']"
+ doc.should have_xpath(web_facet_xpath)
+ deployment_descriptor_xpath = "#{web_facet_xpath}/configuration/descriptors/deploymentDescriptor"
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='ejb-jar.xml', url='file://$MODULE_DIR$/generated/main/resources/WEB-INF/ejb-jar.xml']")
+ end
+
+ it "generates an ejb facet with derived ejbRoots" do
+ doc = xml_document(@foo._("foo.iml"))
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
+ doc.should have_nodes(facet_xpath, 1)
+ web_facet_xpath = "#{facet_xpath}[@type='ejb', @name='EJB']"
+ doc.should have_xpath(web_facet_xpath)
+ doc.should have_xpath("#{web_facet_xpath}/configuration/ejbRoots/root[@url='file://$MODULE_DIR$/generated/main/java']")
+ doc.should have_xpath("#{web_facet_xpath}/configuration/ejbRoots/root[@url='file://$MODULE_DIR$/generated/main/resources']")
+ end
+ end
+
+ describe "using add_jruby_facet" do
+ before do
+
+ @foo = define "foo" do
+ iml.add_jruby_facet
+ end
+ invoke_generate_task
+ end
+
+ it "generates a jruby facet with appropriate sdk" do
+ doc = xml_document(@foo._("foo.iml"))
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
+ doc.should have_nodes(facet_xpath, 1)
+ jruby_facet_xpath = "#{facet_xpath}[@type='JRUBY', @name='JRuby']"
+ doc.should have_xpath(jruby_facet_xpath)
+ doc.should have_xpath("#{jruby_facet_xpath}/configuration/JRUBY_FACET_CONFIG_ID[@NAME='JRUBY_SDK_NAME', VALUE='jruby-1.6.7.2']")
+ end
+
+ it "generates a jruby facet with appropriate paths" do
+ doc = xml_document(@foo._("foo.iml"))
+ prefix = "/module/component[@name='FacetManager']/facet[@type='JRUBY', @name='JRuby']/configuration"
+ doc.should have_xpath("#{prefix}/LOAD_PATH[@number='0']")
+ doc.should have_xpath("#{prefix}/I18N_FOLDERS[@number='0']")
+ end
+ end
+
+ describe "using add_jruby_facet with .ruby-version specified" do
+ before do
+
+ write ".ruby-version", "jruby-1.7.2"
+
+ @foo = define "foo" do
+ iml.add_jruby_facet
+ end
+ invoke_generate_task
+ end
+
+ it "generates a jruby facet with appropriate sdk" do
+ doc = xml_document(@foo._("foo.iml"))
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
+ doc.should have_nodes(facet_xpath, 1)
+ jruby_facet_xpath = "#{facet_xpath}[@type='JRUBY', @name='JRuby']"
+ doc.should have_xpath(jruby_facet_xpath)
+ doc.should have_xpath("#{jruby_facet_xpath}/configuration/JRUBY_FACET_CONFIG_ID[@NAME='JRUBY_SDK_NAME', VALUE='rbenv: jruby-1.7.2']")
+ end
+
+ it "generates a jruby facet with appropriate paths" do
+ doc = xml_document(@foo._("foo.iml"))
+ prefix = "/module/component[@name='FacetManager']/facet[@type='JRUBY', @name='JRuby']/configuration"
+ doc.should have_xpath("#{prefix}/LOAD_PATH[@number='0']")
+ doc.should have_xpath("#{prefix}/I18N_FOLDERS[@number='0']")
+ end
+ end
+
describe "with artifacts added to root project" do
before do
@foo = define "foo" do