+

+ class Buildr::IntellijIdea::IdeaProject +

+ +
+ +

IdeaModule represents an .ipr file

+ +
+ + + + +
+ + + + + + + +
+
+

Attributes

+
+ + +
+
+ artifacts[RW] +
+ +
+ + + +
+
+ +
+
+ configurations[RW] +
+ +
+ + + +
+
+ +
+
+ data_sources[RW] +
+ +
+ + + +
+
+ +
+
+ extra_modules[RW] +
+ +
+ + + +
+
+ +
+
+ jdk_version[W] +
+ +
+ + + +
+
+ +
+
+ version[W] +
+ +
+ + + +
+
+ +
+ + + +
+
+

Public Class Methods

+
+ + +
+ +
+ new(buildr_project) + + click to toggle source + +
+ + +
+ + + + +
+ Calls superclass method + Buildr::IntellijIdea::IdeaFile.new +
+ + + +
+
# File lib/buildr/ide/idea.rb, line 698
+def initialize(buildr_project)
+  super()
+  @buildr_project = buildr_project
+  @extra_modules = []
+  @artifacts = []
+  @data_sources = []
+  @configurations = []
+end
+
+ +
+ + + + +
+ + +
+ +
+
+

Public Instance Methods

+
+ + +
+ +
+ add_artifact(name, type, build_on_make = false) { |xml| ... } + + click to toggle source + +
+ + +
+ + + + + + +
+
# File lib/buildr/ide/idea.rb, line 715
+def add_artifact(name, type, build_on_make = false)
+  add_to_composite_component(self.artifacts) do |xml|
+    xml.artifact(:name => name, :type => type, 'build-on-make' => build_on_make) do |xml|
+      yield xml if block_given?
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ add_configuration(name, type, factory_name, default = false, options = {}) { |xml| ... } + + click to toggle source + +
+ + +
+ + + + + + +
+
# File lib/buildr/ide/idea.rb, line 723
+def add_configuration(name, type, factory_name, default = false, options = {})
+  add_to_composite_component(self.configurations) do |xml|
+    params = options.dup
+    params[:type] = type
+    params[:factoryName] = factory_name
+    params[:name] = name unless default
+    params[:default] = true if default
+    xml.configuration(params) do |xml|
+      yield xml if block_given?
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ add_data_source(name, options = {}) + + click to toggle source + +
+ + +
+ + + + + + +
+
# File lib/buildr/ide/idea.rb, line 799
+def add_data_source(name, options = {})
+  add_to_composite_component(self.data_sources) do |xml|
+    data_source_options = {
+      :source => 'LOCAL',
+      :name => name,
+      :uuid => Buildr::Util.uuid
+    }
+    classpath = options[:classpath] || []
+    xml.tag!('data-source', data_source_options) do |xml|
+      xml.tag!('synchronize', (options[:synchronize]||'true'))
+      xml.tag!('jdbc-driver', options[:driver]) if options[:driver]
+      xml.tag!('jdbc-url', options[:url]) if options[:url]
+      xml.tag!('user-name', options[:username]) if options[:username]
+      xml.tag!('user-password', encrypt(options[:password])) if options[:password]
+      xml.tag!('schema-pattern', options[:schema_pattern]) if options[:schema_pattern]
+      xml.tag!('default-schemas', options[:default_schemas]) if options[:default_schemas]
+      xml.tag!('table-pattern', options[:table_pattern]) if options[:table_pattern]
+      xml.tag!('default-dialect', options[:dialect]) if options[:dialect]
+
+      xml.libraries do |xml|
+        classpath.each do |classpath_element|
+          a = Buildr.artifact(classpath_element)
+          a.invoke
+          xml.library do |xml|
+            xml.tag!('url', resolve_path(a.to_s))
+          end
+        end
+      end if classpath.size > 0
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ add_default_configuration(type, factory_name) { |xml| ... } + + click to toggle source + +
+ + +
+ + + + + + +
+
# File lib/buildr/ide/idea.rb, line 736
+def add_default_configuration(type, factory_name)
+  add_configuration(nil, type, factory_name, true) do |xml|
+    yield xml if block_given?
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ add_default_testng_configuration(options = {}) + + click to toggle source + +
+ + +
+ + + + + + +
+
# File lib/buildr/ide/idea.rb, line 1155
+def add_default_testng_configuration(options = {})
+  jvm_args = options[:jvm_args] || '-ea'
+  dir = options[:dir] || '$PROJECT_DIR$'
+
+  add_default_configuration('TestNG', 'TestNG') do |xml|
+    xml.extension(:name => 'coverage', :enabled => 'false', :merge => 'false', :sample_coverage => 'true', :runner => 'idea')
+    xml.module(:name => '')
+    xml.option(:name => 'ALTERNATIVE_JRE_PATH_ENABLED', :value => 'false')
+    xml.option(:name => 'ALTERNATIVE_JRE_PATH')
+    xml.option(:name => 'SUITE_NAME')
+    xml.option(:name => 'PACKAGE_NAME')
+    xml.option(:name => 'MAIN_CLASS_NAME')
+    xml.option(:name => 'METHOD_NAME')
+    xml.option(:name => 'GROUP_NAME')
+    xml.option(:name => 'TEST_OBJECT', :value => 'CLASS')
+    xml.option(:name => 'VM_PARAMETERS', :value => jvm_args)
+    xml.option(:name => 'PARAMETERS')
+    xml.option(:name => 'WORKING_DIRECTORY', :value => dir)
+    xml.option(:name => 'OUTPUT_DIRECTORY')
+    xml.option(:name => 'ANNOTATION_TYPE')
+    xml.option(:name => 'ENV_VARIABLES')
+    xml.option(:name => 'PASS_PARENT_ENVS', :value => 'true')
+    xml.option(:name => 'TEST_SEARCH_SCOPE') do |opt|
+      opt.value(:defaultName => 'moduleWithDependencies')
+    end
+    xml.option(:name => 'USE_DEFAULT_REPORTERS', :value => 'false')
+    xml.option(:name => 'PROPERTIES_FILE')
+    xml.envs
+    xml.properties
+    xml.listeners
+    xml.method
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ add_exploded_ear_artifact(project, options ={}) + + click to toggle source + +
+ + +
+ + + + + + +
+
# File lib/buildr/ide/idea.rb, line 870
+def add_exploded_ear_artifact(project, options ={})
+  artifact_name = to_artifact_name(project, options)
+
+  add_artifact(artifact_name, 'exploded-ear', build_on_make(options)) do |xml|
+    dependencies = (options[:dependencies] || ([project] + project.compile.dependencies)).flatten
+    libraries, projects = partition_dependencies(dependencies)
+
+    emit_output_path(xml, artifact_name, options)
+    xml.root :id => 'root' do
+      emit_module_output(xml, projects)
+      xml.element :id => 'directory', :name => 'lib' do
+        emit_libraries(xml, libraries)
+      end
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ add_exploded_ejb_artifact(project, options = {}) + + click to toggle source + +
+ + +
+ + + + + + +
+
# File lib/buildr/ide/idea.rb, line 903
+def add_exploded_ejb_artifact(project, options = {})
+  artifact_name = to_artifact_name(project, options)
+
+  add_artifact(artifact_name, 'exploded-ejb', build_on_make(options)) do |xml|
+    dependencies = (options[:dependencies] || [project]).flatten
+    libraries, projects = partition_dependencies(dependencies)
+    raise "Unable to add non-project dependencies (#{libraries.inspect}) to ejb artifact" if libraries.size > 0
+
+    emit_output_path(xml, artifact_name, options)
+    xml.root :id => 'root' do
+      artifact_content(xml, project, projects, options)
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ add_exploded_war_artifact(project, options = {}) + + click to toggle source + +
+ + +
+ + + + + + +
+
# File lib/buildr/ide/idea.rb, line 831
+def add_exploded_war_artifact(project, options = {})
+  artifact_name = to_artifact_name(project, options)
+  artifacts = options[:artifacts] || []
+
+  add_artifact(artifact_name, 'exploded-war', build_on_make(options)) do |xml|
+    dependencies = (options[:dependencies] || ([project] + project.compile.dependencies)).flatten
+    libraries, projects = partition_dependencies(dependencies)
+
+    emit_output_path(xml, artifact_name, options)
+    xml.root :id => 'root' do
+      xml.element :id => 'directory', :name => 'WEB-INF' do
+        xml.element :id => 'directory', :name => 'classes' do
+          artifact_content(xml, project, projects, options)
+        end
+        xml.element :id => 'directory', :name => 'lib' do
+          emit_libraries(xml, libraries)
+          emit_jar_artifacts(xml, artifacts)
+        end
+      end
+
+      if options[:enable_war].nil? || options[:enable_war] || (options[:war_module_names] && options[:war_module_names].size > 0)
+        module_names = options[:war_module_names] || [project.iml.name]
+        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] || (options[:gwt_module_names] && options[:gwt_module_names].size > 0)
+        module_names = options[:gwt_module_names] || [project.iml.name]
+        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
+
+ +
+ + + + +
+ + +
+ +
+ add_glassfish_configuration(project, options = {}) + + click to toggle source + +
+ + +
+ + + + + + +
+
# File lib/buildr/ide/idea.rb, line 1017
+def add_glassfish_configuration(project, options = {})
+  artifact_name = options[:name] || project.iml.id
+  version = options[:version] || '4.1.0'
+  server_name = options[:server_name] || "GlassFish #{version}"
+  configuration_name = options[:configuration_name] || server_name
+  domain_name = options[:domain] || project.iml.id
+  domain_port = options[:port] || '9009'
+  packaged = options[:packaged] || {}
+  exploded = options[:exploded] || {}
+
+  add_to_composite_component(self.configurations) do |xml|
+    xml.configuration(:name => configuration_name, :type => 'GlassfishConfiguration', :factoryName => 'Local', :default => false, :APPLICATION_SERVER_NAME => server_name) do |xml|
+      xml.option(:name => 'OPEN_IN_BROWSER', :value => 'false')
+      xml.option(:name => 'UPDATING_POLICY', :value => 'restart-server')
+
+      xml.deployment do |deployment|
+        packaged.each do |name, deployable|
+          artifact = Buildr.artifact(deployable)
+          artifact.invoke
+          deployment.file(:path => resolve_path(artifact.to_s)) do |file|
+            file.settings do |settings|
+              settings.option(:name => 'contextRoot', :value => "/#{name}")
+              settings.option(:name => 'defaultContextRoot', :value => 'false')
+            end
+          end
+        end
+        exploded.each do |deployable_name|
+          deployment.artifact(:name => deployable_name) do |artifact|
+            artifact.settings
+          end
+        end
+      end
+
+      xml.tag! 'server-settings' do |server_settings|
+        server_settings.option(:name => 'VIRTUAL_SERVER')
+        server_settings.option(:name => 'DOMAIN', :value => domain_name.to_s)
+        server_settings.option(:name => 'PRESERVE', :value => 'false')
+        server_settings.option(:name => 'USERNAME', :value => 'admin')
+        server_settings.option(:name => 'PASSWORD', :value => '')
+      end
+
+      xml.predefined_log_file(:id => 'GlassFish', :enabled => 'true')
+
+      xml.extension(:name => 'coverage', :enabled => 'false', :merge => 'false', :sample_coverage => 'true', :runner => 'idea')
+
+      xml.RunnerSettings(:RunnerId => 'Cover')
+
+      add_glassfish_runner_settings(xml, 'Cover')
+      add_glassfish_configuration_wrapper(xml, 'Cover')
+
+      add_glassfish_runner_settings(xml, 'Debug', {
+        :DEBUG_PORT => domain_port.to_s,
+        :TRANSPORT => '0',
+        :LOCAL => 'true',
+      })
+      add_glassfish_configuration_wrapper(xml, 'Debug')
+
+      add_glassfish_runner_settings(xml, 'Run')
+      add_glassfish_configuration_wrapper(xml, 'Run')
+
+      xml.method do |method|
+        method.option(:name => 'BuildArtifacts', :enabled => 'true') do |option|
+          option.artifact(:name => artifact_name)
+        end
+      end
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ add_glassfish_remote_configuration(project, options = {}) + + click to toggle source + +
+ + +
+ + + + + + +
+
# File lib/buildr/ide/idea.rb, line 1086
+def add_glassfish_remote_configuration(project, options = {})
+  artifact_name = options[:name] || project.iml.id
+  version = options[:version] || '4.1.0'
+  server_name = options[:server_name] || "GlassFish #{version}"
+  configuration_name = options[:configuration_name] || "Remote #{server_name}"
+  domain_port = options[:port] || '9009'
+  packaged = options[:packaged] || {}
+  exploded = options[:exploded] || {}
+
+  add_to_composite_component(self.configurations) do |xml|
+    xml.configuration(:name => configuration_name, :type => 'GlassfishConfiguration', :factoryName => 'Remote', :default => false, :APPLICATION_SERVER_NAME => server_name) do |xml|
+      xml.option(:name => 'LOCAL', :value => 'false')
+      xml.option(:name => 'OPEN_IN_BROWSER', :value => 'false')
+      xml.option(:name => 'UPDATING_POLICY', :value => 'hot-swap-classes')
+
+      xml.deployment do |deployment|
+        packaged.each do |name, deployable|
+          artifact = Buildr.artifact(deployable)
+          artifact.invoke
+          deployment.file(:path => resolve_path(artifact.to_s)) do |file|
+            file.settings do |settings|
+              settings.option(:name => 'contextRoot', :value => "/#{name}")
+              settings.option(:name => 'defaultContextRoot', :value => 'false')
+            end
+          end
+        end
+        exploded.each do |deployable_name|
+          deployment.artifact(:name => deployable_name) do |artifact|
+            artifact.settings
+          end
+        end
+      end
+
+      xml.tag! 'server-settings' do |server_settings|
+        server_settings.option(:name => 'VIRTUAL_SERVER')
+        server_settings.data do |data|
+          data.option(:name => 'adminServerHost', :value => '')
+          data.option(:name => 'clusterName', :value => '')
+          data.option(:name => 'stagingRemotePath', :value => '')
+          data.option(:name => 'transportHostId')
+          data.option(:name => 'transportStagingTarget') do |option|
+            option.TransportTarget do |tt|
+              tt.option(:name => 'id', :value => 'X')
+            end
+          end
+        end
+      end
+
+      xml.predefined_log_file(:id => 'GlassFish', :enabled => 'true')
+
+      add_glassfish_runner_settings(xml, 'Debug', {
+                                         :DEBUG_PORT => domain_port.to_s,
+                                         :TRANSPORT => '0',
+                                         :LOCAL => 'false',
+                                       })
+      add_glassfish_configuration_wrapper(xml, 'Debug')
+
+      add_glassfish_runner_settings(xml, 'Run')
+      add_glassfish_configuration_wrapper(xml, 'Run')
+
+      xml.method do |method|
+        method.option(:name => 'BuildArtifacts', :enabled => 'true') do |option|
+          option.artifact(:name => artifact_name)
+        end
+      end
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ add_gwt_configuration(project, options = {}) + + click to toggle source + +
+ + +
+ + + + + + +
+
# File lib/buildr/ide/idea.rb, line 982
+def add_gwt_configuration(project, options = {})
+  launch_page = options[:launch_page]
+  name = options[:name] || (launch_page ? "Run #{launch_page}" : "Run #{project.name} DevMode")
+  shell_parameters = options[:shell_parameters]
+  vm_parameters = options[:vm_parameters] || '-Xmx512m'
+  singleton = options[:singleton].nil? ? true : !!options[:singleton]
+  super_dev = options[:super_dev].nil? ? true : !!options[:super_dev]
+  gwt_module = options[:gwt_module]
+
+  start_javascript_debugger = options[:start_javascript_debugger].nil? ? true : !!options[:start_javascript_debugger]
+
+  add_configuration(name, 'GWT.ConfigurationType', 'GWT Configuration', false, :singleton => singleton) do |xml|
+    xml.module(:name => project.iml.name)
+
+    xml.option(:name => 'VM_PARAMETERS', :value => vm_parameters)
+    xml.option(:name => 'RUN_PAGE', :value => launch_page) if launch_page
+    xml.option(:name => 'GWT_MODULE', :value => gwt_module) if gwt_module
+
+    xml.option(:name => 'START_JAVASCRIPT_DEBUGGER', :value => start_javascript_debugger)
+    xml.option(:name => 'USE_SUPER_DEV_MODE', :value => super_dev)
+    xml.option(:name => 'SHELL_PARAMETERS', :value => shell_parameters) if shell_parameters
+
+    xml.RunnerSettings(:RunnerId => 'Debug') do |xml|
+      xml.option(:name => 'DEBUG_PORT', :value => '')
+      xml.option(:name => 'TRANSPORT', :value => 0)
+      xml.option(:name => 'LOCAL', :value => true)
+    end
+
+    xml.RunnerSettings(:RunnerId => 'Run')
+    xml.ConfigurationWrapper(:RunnerId => 'Run')
+    xml.ConfigurationWrapper(:RunnerId => 'Debug')
+    xml.method()
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ add_jar_artifact(project, options = {}) + + click to toggle source + +
+ + +
+ + + + + + +
+
# File lib/buildr/ide/idea.rb, line 887
+def add_jar_artifact(project, options = {})
+  artifact_name = to_artifact_name(project, options)
+
+  dependencies = (options[:dependencies] || [project]).flatten
+  libraries, projects = partition_dependencies(dependencies)
+  raise "Unable to add non-project dependencies (#{libraries.inspect}) to jar artifact" if libraries.size > 0
+
+  jar_name = "#{artifact_name}.jar"
+  add_artifact(jar_name, 'jar', build_on_make(options)) do |xml|
+    emit_output_path(xml, artifact_name, options)
+    xml.root(:id => 'archive', :name => jar_name) do
+      artifact_content(xml, project, projects, options)
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ [... 1029 lines stripped ...]