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 2014/07/31 07:12:35 UTC

[21/50] git commit: Add add_default_configuration utility method to ipr project

Add add_default_configuration utility method to ipr project

git-svn-id: https://svn.apache.org/repos/asf/buildr/trunk@1537619 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/buildr/repo
Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/7728d4ea
Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/7728d4ea
Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/7728d4ea

Branch: refs/heads/master
Commit: 7728d4ea8ba9117eac9c8c824c177fbc53b182da
Parents: dfede00
Author: Peter Donald <do...@apache.org>
Authored: Thu Oct 31 20:16:28 2013 +0000
Committer: Peter Donald <do...@apache.org>
Committed: Thu Oct 31 20:16:28 2013 +0000

----------------------------------------------------------------------
 lib/buildr/ide/idea.rb |  9 ++++++++-
 spec/ide/idea_spec.rb  | 25 +++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/buildr/blob/7728d4ea/lib/buildr/ide/idea.rb
----------------------------------------------------------------------
diff --git a/lib/buildr/ide/idea.rb b/lib/buildr/ide/idea.rb
index cade709..e380dee 100644
--- a/lib/buildr/ide/idea.rb
+++ b/lib/buildr/ide/idea.rb
@@ -647,12 +647,19 @@ module Buildr #:nodoc:
 
       def add_configuration(name, type, factory_name, default = false)
         add_to_composite_component(self.configurations) do |xml|
-          xml.configuration(:name => name, :type => type, :factoryName => factory_name, :default => default) do |xml|
+          options = {:type => type, :factoryName => factory_name}
+          options[:name] = name unless default
+          options[:default] = true if default
+          xml.configuration(options) do |xml|
             yield xml if block_given?
           end
         end
       end
 
+      def add_default_configuration(type, factory_name)
+        add_configuration(nil, type, factory_name)
+      end
+
       def add_postgres_data_source(name, options = {})
         if options[:url].nil? && options[:database]
          default_url = "jdbc:postgresql://#{(options[:host] || "127.0.0.1")}:#{(options[:port] || "5432")}/#{options[:database]}"

http://git-wip-us.apache.org/repos/asf/buildr/blob/7728d4ea/spec/ide/idea_spec.rb
----------------------------------------------------------------------
diff --git a/spec/ide/idea_spec.rb b/spec/ide/idea_spec.rb
index b6ebd83..1e62fb8 100644
--- a/spec/ide/idea_spec.rb
+++ b/spec/ide/idea_spec.rb
@@ -1076,6 +1076,31 @@ describe Buildr::IntellijIdea do
       end
     end
 
+    describe "with default configuration added to root project" do
+      before do
+        @foo = define "foo" do
+          ipr.add_default_configuration("GWT.ConfigurationType", "GWT Configuration") do |xml|
+            xml.module(:name => project.iml.id)
+            xml.option(:name => "RUN_PAGE", :value => "Planner.html")
+            xml.option(:name => "compilerParameters", :value => "-draftCompile -localWorkers 2")
+            xml.option(:name => "compilerMaxHeapSize", :value => "512")
+
+            xml.RunnerSettings(:RunnerId => "Run")
+            xml.ConfigurationWrapper(:RunnerId => "Run")
+            xml.tag! :method
+          end
+        end
+        invoke_generate_task
+      end
+
+      it "generates an IPR with default configuration" do
+        doc = xml_document(@foo._("foo.ipr"))
+        facet_xpath = "/project/component[@name='ProjectRunConfigurationManager']/configuration"
+        doc.should have_nodes(facet_xpath, 1)
+        doc.should have_xpath("#{facet_xpath}[@type='GWT.ConfigurationType' AND @factoryName='GWT Configuration' AND @default='true']")
+      end
+    end
+
     describe "with iml.group specified" do
       before do
         @foo = define "foo" do