Author: donaldp
Date: Thu Sep 26 23:06:59 2013
New Revision: 1526739
URL: http://svn.apache.org/r1526739
Log:
Support deriving facet configuration from main_source_directories configuration
on iml
Modified:
buildr/trunk/lib/buildr/ide/idea.rb
buildr/trunk/spec/ide/idea_spec.rb
Modified: buildr/trunk/lib/buildr/ide/idea.rb
URL:
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/ide/idea.rb?rev=1526739&r1=1526738&r2=1526739&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/ide/idea.rb (original)
+++ buildr/trunk/lib/buildr/ide/idea.rb Thu Sep 26 23:06:59 2013
@@ -354,7 +354,7 @@ module Buildr #:nodoc:
def add_jpa_facet(options = {})
name = options[:name] || "JPA"
- source_roots = [buildr_project.compile.sources,
buildr_project.resources.sources].flatten
+ source_roots = [buildr_project.iml.main_source_directories,
buildr_project.compile.sources,
buildr_project.resources.sources].flatten.compact
default_deployment_descriptors = []
['orm.xml', 'persistence.xml'].
each do |descriptor|
@@ -401,7 +401,7 @@ module Buildr #:nodoc:
def add_ejb_facet(options = {})
name = options[:name] || "EJB"
- default_ejb_roots = [buildr_project.compile.sources,
buildr_project.resources.sources].flatten
+ default_ejb_roots = [buildr_project.iml.main_source_directories,
buildr_project.compile.sources,
buildr_project.resources.sources].flatten.compact
ejb_roots = options[:ejb_roots] || default_ejb_roots
default_deployment_descriptors = []
Modified: buildr/trunk/spec/ide/idea_spec.rb
URL:
http://svn.apache.org/viewvc/buildr/trunk/spec/ide/idea_spec.rb?rev=1526739&r1=1526738&r2=1526739&view=diff
==============================================================================
--- buildr/trunk/spec/ide/idea_spec.rb (original)
+++ buildr/trunk/spec/ide/idea_spec.rb Thu Sep 26 23:06:59 2013
@@ -507,6 +507,28 @@ describe Buildr::IntellijIdea do
end
end
+ describe "using add_jpa_facet derived from main_source_directories" do
+ before do
+ write "src/main/resources2/META-INF/persistence.xml"
+ write "src/main/resources2/META-INF/orm.xml"
+
+ @foo = define "foo" do
+ iml.main_source_directories << "src/main/resources2"
+ iml.add_jpa_facet
+
+ end
+ invoke_generate_task
+ end
+
+ it "generates a jpa facet with appropriate deployment descriptors" do
+ doc = xml_document(@foo._("foo.iml"))
+ facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
+ deployment_descriptor_xpath =
"#{facet_xpath}/configuration/deploymentDescriptor"
+ doc.should
have_xpath("#{deployment_descriptor_xpath}[@name='persistence.xml',
url='file://$MODULE_DIR$/src/main/resources2/META-INF/persistence.xml']")
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='orm.xml',
url='file://$MODULE_DIR$/src/main/resources2/META-INF/orm.xml']")
+ end
+ end
+
describe "using add_jpa_facet with hibernate configured in
persistence.xml" do
before do
write "src/main/resources/META-INF/persistence.xml",
"org.hibernate.ejb.HibernatePersistence"
@@ -595,6 +617,24 @@ describe Buildr::IntellijIdea do
end
end
+ describe "using add_ejb_facet derived from main_source_directories" do
+ before do
+ write "src/main/resources2/WEB-INF/ejb-jar.xml"
+ @foo = define "foo" do
+ iml.main_source_directories << "src/main/resources2"
+ 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"))
+ ejb_facet_xpath = ensure_facet_xpath(doc, 'ejb', 'EJB')
+ deployment_descriptor_xpath =
"#{ejb_facet_xpath}/configuration/descriptors/deploymentDescriptor"
+ doc.should
have_xpath("#{deployment_descriptor_xpath}[@name='ejb-jar.xml',
url='file://$MODULE_DIR$/src/main/resources2/WEB-INF/ejb-jar.xml']")
+ end
+ end
+
describe "using add_jruby_facet" do
before do