buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject svn commit: r1242276 - in /buildr/trunk: CHANGELOG lib/buildr/ide/idea.rb
Date Thu, 09 Feb 2012 11:02:56 GMT
Author: donaldp
Date: Thu Feb  9 11:02:56 2012
New Revision: 1242276

URL: http://svn.apache.org/viewvc?rev=1242276&view=rev
Log:
Add several utility methods to IDEA extension for defining artifacts and configurations.

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/lib/buildr/ide/idea.rb

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1242276&r1=1242275&r2=1242276&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Thu Feb  9 11:02:56 2012
@@ -1,4 +1,5 @@
 1.4.8 (Pending)
+* Added:  Add several utility methods to IDEA extension for defining artifacts and configurations.
 * Change: Make minimumTokenCount and encoding configurable for the PMD/CPD action
           and default encoding to UTF-8 for compatibility with external tools (i.e. Jenkins)
 * Fixed:  BUILDR-617 pom exclusion does not work (Kafka Liu)

Modified: buildr/trunk/lib/buildr/ide/idea.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/ide/idea.rb?rev=1242276&r1=1242275&r2=1242276&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/ide/idea.rb (original)
+++ buildr/trunk/lib/buildr/ide/idea.rb Thu Feb  9 11:02:56 2012
@@ -238,6 +238,107 @@ module Buildr
         @skip_content = true
       end
 
+
+      def add_gwt_facet(modules = {}, options = {})
+        name = options[:name] || "GWT"
+        settings =
+          {
+            :webFacet => "Web",
+            :compilerMaxHeapSize => "512",
+            :compilerParameters => "-draftCompile -localWorkers 2",
+            :gwtSdkUrl => "file://$GWT_TOOLS$",
+            :gwtScriptOutputStyle => "PRETTY"
+          }.merge(options[:settings] || {})
+
+        add_facet(name, "gwt") do |f|
+          f.configuration do |c|
+            settings.each_pair do |k, v|
+              c.setting :name => k.to_s, :value => v.to_s
+            end
+            c.packaging do |d|
+              modules.each_pair do |k, v|
+                d.module :name => v, :path => k
+              end
+            end
+          end
+        end
+      end
+
+      def add_web_facet(options = {})
+        name = options[:name] || "Web"
+        url_base = options[:url_base] || "/"
+        webroot = options[:webroot] || buildr_project._(:source, :main, :webapp)
+        web_xml = options[:web_xml] || "#{webroot}/WEB-INF/web.xml"
+        version = options[:version] || "3.0"
+
+        add_facet(name, "web") do |f|
+          f.configuration do |c|
+            c.descriptors do |d|
+              d.deploymentDescriptor :name => 'web.xml', :url => file_path(web_xml),
:optional => "true", :version => version
+            end
+            c.webroots do |w|
+              w.root :url => file_path(webroot), :relative => url_base
+            end
+          end
+        end
+      end
+
+
+      def add_jruby_facet(options = {})
+        name = options[:name] || "JRuby"
+        jruby_version = options[:jruby_version] || "jruby-1.5.2-p249"
+        add_facet(name, "JRUBY") do |f|
+          f.configuration(:number => 0) do |c|
+            c.JRUBY_FACET_CONFIG_ID :NAME => "JRUBY_SDK_NAME", :VALUE => jruby_version
+          end
+        end
+      end
+
+      def add_jpa_facet(options = {})
+        name = options[:name] || "JPA"
+        factory_entry = options[:factory_entry] || buildr_project.name.to_s
+        validation_enabled = options[:validation_enabled].nil? ? true : options[:validation_enabled]
+        provider_enabled = options[:provider_enabled] || 'Hibernate'
+        persistence_xml = options[:persistence_xml] || buildr_project._(:source, :main, :resources,
"META-INF/persistence.xml")
+        orm_xml = options[:orm_xml] || buildr_project._(:source, :main, :resources, "META-INF/orm.xml")
+        add_facet(name, "jpa") do |f|
+          f.configuration do |c|
+            c.setting :name => "validation-enabled", :value => validation_enabled
+            c.setting :name => "provider-name", :value => provider_enabled
+            c.tag!('datasource-mapping') do |ds|
+              ds.tag!('factory-entry', :name => factory_entry)
+            end
+            if File.exist?(persistence_xml)
+              c.deploymentDescriptor :name => 'persistence.xml', :url => file_path(persistence_xml)
+            end
+            if File.exist?(orm_xml)
+              c.deploymentDescriptor :name => 'orm.xml', :url => file_path(orm_xml)
+            end
+          end
+        end
+      end
+
+      def add_ejb_facet(options = {})
+        name = options[:name] || "EJB"
+        ejb_xml = options[:ejb_xml] || buildr_project._(:source, :main, :resources, "WEB-INF/ejb-jar.xml")
+        ejb_roots = options[:ejb_roots] || [buildr_project.packages, buildr_project.compile.target,
buildr_project.resources.target].flatten
+
+        add_facet(name, "ejb") do |facet|
+          facet.configuration do |c|
+            c.descriptors do |d|
+              if File.exist?(ejb_xml)
+                d.deploymentDescriptor :name => 'ejb-jar.xml', :url => ejb_xml
+              end
+            end
+            c.ejbRoots do |e|
+              ejb_roots.each do |ejb_root|
+                e.root :url => file_path(ejb_root)
+              end
+            end
+          end
+        end
+      end
+
       protected
 
       def test_dependency_details
@@ -445,6 +546,76 @@ module Buildr
         end
       end
 
+      def add_exploded_war_artifact(project, options = {})
+        artifact_name = options[:name] || project.iml.id
+        build_on_make = options[:build_on_make].nil? ? false : options[:build_on_make]
+
+        add_artifact(artifact_name, "exploded-war", build_on_make) do |xml|
+          dependencies = (options[:dependencies] || ([project] + project.compile.dependencies)).flatten
+          libraries, projects = partition_dependencies(dependencies)
+
+          ## The content here can not be indented
+          output_dir = options[:output_dir] || project._(:artifacts, artifact_name)
+          xml.tag!('output-path', output_dir)
+
+          xml.root :id => "root" do
+            xml.element :id => "directory", :name => "WEB-INF" do
+              xml.element :id => "directory", :name => "classes" do
+                projects.each do |p|
+                  xml.element :id => "module-output", :name => p.iml.id
+                end
+                if options[:enable_jpa]
+                  module_names = options[:jpa_module_names] || [project.iml.id]
+                  module_names.each do |module_name|
+                    facet_name = options[:jpa_facet_name] || "JPA"
+                    xml.element :id => "jpa-descriptors", :facet => "#{module_name}/jpa/#{facet_name}"
+                  end
+                end
+              end
+              xml.element :id => "directory", :name => "lib" do
+                libraries.each(&:invoke).map(&:to_s).each do |dependency_path|
+                  xml.element :id => "file-copy", :path => resolve_path(dependency_path)
+                end
+              end
+            end
+
+            if options[:enable_war].nil? || options[:enable_war]
+              module_names = options[:war_module_names] || [project.iml.id]
+              module_names.each do |module_name|
+                facet_name = options[:war_facet_name] || "Web"
+                xml.element :id => "javaee-facet-resources", :facet => "#{module_name}/web/#{facet_name}"
+              end
+            end
+
+            if options[:enable_gwt]
+              module_names = options[:gwt_module_names] || [project.iml.id]
+              module_names.each do |module_name|
+                facet_name = options[:gwt_facet_name] || "GWT"
+                xml.element :id => "gwt-compiler-output", :facet => "#{module_name}/gwt/#{facet_name}"
+              end
+            end
+          end
+        end
+      end
+
+      def add_gwt_configuration(launch_page, project, options = {})
+        name = options[:name] || "Run #{launch_page}"
+        shell_parameters = options[:shell_parameters] || ""
+        vm_parameters = options[:vm_parameters] || "-Xmx512m"
+
+        add_configuration(name, "GWT.ConfigurationType", "GWT Configuration") do |xml|
+          xml.module(:name => project.iml.id)
+          xml.option(:name => "RUN_PAGE", :value => launch_page)
+          xml.option(:name => "SHELL_PARAMETERS", :value => shell_parameters)
+          xml.option(:name => "VM_PARAMETERS", :value => vm_parameters)
+
+          xml.RunnerSettings(:RunnerId => "Run")
+          xml.ConfigurationWrapper(:RunnerId => "Run")
+          xml.method()
+        end
+      end
+
+
       protected
 
       def extension



Mime
View raw message