Module: Buildr::Idea7x
Overview
:nodoc:
Constant Summary collapse
- CLASSIFIER =
"-7x"
- IML_SUFFIX =
CLASSIFIER + ".iml"
- IPR_TEMPLATE =
"idea7x.ipr.template"
- MODULE_DIR =
"$MODULE_DIR$"
- FILE_PATH_PREFIX =
"file://"
- MODULE_DIR_URL =
FILE_PATH_PREFIX + MODULE_DIR
- PROJECT_DIR =
"$PROJECT_DIR$"
- PROJECT_DIR_URL =
FILE_PATH_PREFIX + PROJECT_DIR
Class Method Summary collapse
- .generate_compile_output(project, xml, relative) ⇒ Object
- .generate_content(project, xml, relative) ⇒ Object
- .generate_ipr(project, idea7x, sources) ⇒ Object
- .generate_module_libs(xml, ext_libs) ⇒ Object
- .generate_order_entries(project_libs, xml) ⇒ Object
Methods included from Extension
Class Method Details
.generate_compile_output(project, xml, relative) ⇒ Object
121 122 123 124 125 |
# File 'lib/buildr/ide/idea7x.rb', line 121 def generate_compile_output(project, xml, relative) xml.output(:url=>"#{MODULE_DIR_URL}/#{relative[project.compile.target.to_s]}") if project.compile.target xml.tag!("output-test", :url=>"#{MODULE_DIR_URL}/#{relative[project.test.compile.target.to_s]}") if project.test.compile.target xml.tag!("exclude-output") end |
.generate_content(project, xml, relative) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/buildr/ide/idea7x.rb', line 127 def generate_content(project, xml, relative) xml.content(:url=>"#{MODULE_DIR_URL}") do unless project.compile.sources.empty? srcs = project.compile.sources.map { |src| relative[src.to_s] } srcs.sort.uniq.each do |path| xml.sourceFolder :url=>"#{MODULE_DIR_URL}/#{path}", :isTestSource=>"false" end end unless project.test.compile.sources.empty? test_sources = project.test.compile.sources.map { |src| relative[src.to_s] } test_sources.each do |paths| paths.sort.uniq.each do |path| xml.sourceFolder :url=>"#{MODULE_DIR_URL}/#{path}", :isTestSource=>"true" end end end [project.resources=>false, project.test.resources=>true].each do |resources, test| resources.each do |path| path[0].sources.each do |srcpath| xml.sourceFolder :url=>"#{FILE_PATH_PREFIX}#{srcpath}", :isTestSource=>path[1].to_s end end end xml.excludeFolder :url=>"#{MODULE_DIR_URL}/#{relative[project.resources.target.to_s]}" if project.resources.target xml.excludeFolder :url=>"#{MODULE_DIR_URL}/#{relative[project.test.resources.target.to_s]}" if project.test.resources.target end end |
.generate_ipr(project, idea7x, sources) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/buildr/ide/idea7x.rb', line 171 def generate_ipr(project, idea7x, sources) task_name = project.path_to("#{project.name.gsub(':', '-')}-7x.ipr") idea7x.enhance [ file(task_name) ] file(task_name=>sources) do |task| info "Writing #{task.name}" # Generating just the little stanza that chanages from one project to another partial = StringIO.new xml = Builder::XmlMarkup.new(:target=>partial, :indent=>2) xml.component(:name=>"ProjectModuleManager") do xml.modules do project.projects.each do |subp| module_name = subp.name.gsub(":", "-") module_path = subp.base_dir ? subp.base_dir.gsub(/^#{project.base_dir}\//, '') : subp.name.split(":")[1 .. -1].join(FILE::SEPARATOR) path = "#{module_path}/#{module_name}#{IML_SUFFIX}" xml.module :fileurl=>"#{PROJECT_DIR_URL}/#{path}", :filepath=>"#{PROJECT_DIR}/#{path}" end if package = project.packages.first xml.module :fileurl=>"#{PROJECT_DIR_URL}/#{project.name}#{IML_SUFFIX}", :filepath=>"#{PROJECT_DIR}/#{project.name}#{IML_SUFFIX}" end end end # Loading the whole fairly constant crap template_xml = REXML::Document.new(File.open(File.join(File.dirname(__FILE__), IPR_TEMPLATE))) include_xml = REXML::Document.new(partial.string) template_xml.root.add_element(include_xml.root) File.open task.name, 'w' do |file| template_xml.write file end end end |
.generate_module_libs(xml, ext_libs) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/buildr/ide/idea7x.rb', line 155 def generate_module_libs(xml, ext_libs) ext_libs.each do |path| xml.orderEntry :type=>"module-library" do xml.library do xml.CLASSES do xml.root :url=> path end xml.JAVADOC xml.SOURCES do xml.root :url=>"jar://#{path.sub(/\.jar$/, "-sources.jar")}!/" end end end end end |
.generate_order_entries(project_libs, xml) ⇒ Object
111 112 113 114 115 116 117 118 119 |
# File 'lib/buildr/ide/idea7x.rb', line 111 def generate_order_entries(project_libs, xml) xml.orderEntry :type=>"sourceFolder", :forTests=>"false" xml.orderEntry :type=>"inheritedJdk" # Classpath elements from other projects project_libs.map(&:id).sort.uniq.each do |project_id| xml.orderEntry :type=>'module', "module-name"=>"#{project_id}#{CLASSIFIER}" end end |