buildr-iidea 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +38 -33
- data/LICENSE +203 -203
- data/NOTICE +16 -16
- data/README.rdoc +328 -328
- data/Rakefile +42 -33
- data/buildr-iidea.gemspec +25 -25
- data/lib/buildr/intellij_idea/idea_file.rb +85 -85
- data/lib/buildr/intellij_idea/idea_module.rb +255 -263
- data/lib/buildr/intellij_idea/idea_project.rb +105 -105
- data/lib/buildr/intellij_idea/project_extension.rb +108 -108
- data/lib/buildr/intellij_idea/version.rb +10 -10
- data/lib/buildr_iidea.rb +6 -6
- data/spec/buildr/intellij_idea/clean_spec.rb +37 -37
- data/spec/buildr/intellij_idea/dependency_spec.rb +115 -115
- data/spec/buildr/intellij_idea/extra_modules_spec.rb +24 -24
- data/spec/buildr/intellij_idea/facet_generation_spec.rb +36 -36
- data/spec/buildr/intellij_idea/group_spec.rb +33 -33
- data/spec/buildr/intellij_idea/idea_file_generation_spec.rb +243 -243
- data/spec/buildr/intellij_idea/inform_spec.rb +28 -28
- data/spec/buildr/intellij_idea/initial_components_spec.rb +38 -38
- data/spec/buildr/intellij_idea/module_content_generation_spec.rb +96 -96
- data/spec/buildr/intellij_idea/module_defaults.rb +15 -15
- data/spec/buildr/intellij_idea/module_property_inheritance_spec.rb +27 -27
- data/spec/buildr/intellij_idea/project_extension_spec.rb +96 -96
- data/spec/buildr/intellij_idea/template_spec.rb +233 -233
- data/spec/spec_helper.rb +79 -72
- data/spec/xpath_matchers.rb +108 -108
- metadata +15 -16
- data/spec/spec.opts +0 -1
data/Rakefile
CHANGED
@@ -1,33 +1,42 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/rdoctask'
|
3
|
-
require 'rake/gempackagetask'
|
4
|
-
require 'spec/rake/spectask'
|
5
|
-
require File.expand_path("../lib/buildr/intellij_idea/version", __FILE__)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require 'spec/rake/spectask'
|
5
|
+
require File.expand_path("../lib/buildr/intellij_idea/version", __FILE__)
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'rubygems'
|
9
|
+
gem 'ci_reporter'
|
10
|
+
require 'ci/reporter/rake/rspec'
|
11
|
+
ENV["CI_REPORTS"] = 'tmp/reports'
|
12
|
+
rescue LoadError => e
|
13
|
+
#puts "The ci_reporter gem is not available. Reports will not be generated."
|
14
|
+
end
|
15
|
+
|
16
|
+
gem_spec = Gem::Specification.load(File.expand_path('buildr-iidea.gemspec', File.dirname(__FILE__)))
|
17
|
+
|
18
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
19
|
+
spec.libs << 'lib' << 'spec'
|
20
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
22
|
+
|
23
|
+
task :default => :spec
|
24
|
+
|
25
|
+
desc "Generate RDoc documentation in rdoc/"
|
26
|
+
Rake::RDocTask.new :rdoc do |rdoc|
|
27
|
+
rdoc.rdoc_dir = 'rdoc'
|
28
|
+
rdoc.title = gem_spec.name
|
29
|
+
rdoc.options = gem_spec.rdoc_options.clone
|
30
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
31
|
+
rdoc.rdoc_files.include gem_spec.extra_rdoc_files
|
32
|
+
end
|
33
|
+
|
34
|
+
Rake::GemPackageTask.new(gem_spec).define
|
35
|
+
|
36
|
+
namespace :deploy do
|
37
|
+
desc "Tag release with current version"
|
38
|
+
task :tag do
|
39
|
+
system("git tag -a #{Buildr::IntellijIdea::Version::STRING} -m 'Released #{Buildr::IntellijIdea::Version::STRING}'")
|
40
|
+
puts "Tagged locally. `git push --tags` if you're sure."
|
41
|
+
end
|
42
|
+
end
|
data/buildr-iidea.gemspec
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/lib/buildr/intellij_idea/version')
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = 'buildr-iidea'
|
5
|
-
spec.version = Buildr::IntellijIdea::Version::STRING
|
6
|
-
spec.authors = ['Rhett Sutphin', 'Peter Donald']
|
7
|
-
spec.email = ["rhett@detailedbalance.net","peter@realityforge.org"]
|
8
|
-
spec.homepage = "http://github.com/realityforge/buildr-iidea"
|
9
|
-
spec.summary = "Buildr tasks to generate Intellij IDEA project files"
|
10
|
-
spec.description = <<-TEXT
|
11
|
-
This is a buildr extension that provides tasks to generate Intellij IDEA
|
12
|
-
project files. The iidea task generates the project files based on the
|
13
|
-
settings of each project and extension specific settings.
|
14
|
-
TEXT
|
15
|
-
|
16
|
-
spec.files = Dir['{lib,spec}/**/*', '*.gemspec'] +
|
17
|
-
['LICENSE', 'NOTICE', 'README.rdoc', 'CHANGELOG', 'Rakefile']
|
18
|
-
spec.require_paths = ['lib']
|
19
|
-
|
20
|
-
spec.has_rdoc = true
|
21
|
-
spec.extra_rdoc_files = 'README.rdoc', 'LICENSE', 'NOTICE', 'CHANGELOG'
|
22
|
-
spec.rdoc_options = '--title', "#{spec.name} #{spec.version}", '--main', 'README.rdoc'
|
23
|
-
|
24
|
-
spec.post_install_message = "Thanks for installing the Intellij IDEA extension for Buildr"
|
25
|
-
end
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/lib/buildr/intellij_idea/version')
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'buildr-iidea'
|
5
|
+
spec.version = Buildr::IntellijIdea::Version::STRING
|
6
|
+
spec.authors = ['Rhett Sutphin', 'Peter Donald']
|
7
|
+
spec.email = ["rhett@detailedbalance.net","peter@realityforge.org"]
|
8
|
+
spec.homepage = "http://github.com/realityforge/buildr-iidea"
|
9
|
+
spec.summary = "Buildr tasks to generate Intellij IDEA project files"
|
10
|
+
spec.description = <<-TEXT
|
11
|
+
This is a buildr extension that provides tasks to generate Intellij IDEA
|
12
|
+
project files. The iidea task generates the project files based on the
|
13
|
+
settings of each project and extension specific settings.
|
14
|
+
TEXT
|
15
|
+
|
16
|
+
spec.files = Dir['{lib,spec}/**/*', '*.gemspec'] +
|
17
|
+
['LICENSE', 'NOTICE', 'README.rdoc', 'CHANGELOG', 'Rakefile']
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.has_rdoc = true
|
21
|
+
spec.extra_rdoc_files = 'README.rdoc', 'LICENSE', 'NOTICE', 'CHANGELOG'
|
22
|
+
spec.rdoc_options = '--title', "#{spec.name} #{spec.version}", '--main', 'README.rdoc'
|
23
|
+
|
24
|
+
spec.post_install_message = "Thanks for installing the Intellij IDEA extension for Buildr"
|
25
|
+
end
|
@@ -1,86 +1,86 @@
|
|
1
|
-
module Buildr
|
2
|
-
module IntellijIdea
|
3
|
-
# Abstract base class for IdeaModule and IdeaProject
|
4
|
-
class IdeaFile
|
5
|
-
DEFAULT_SUFFIX = ""
|
6
|
-
|
7
|
-
attr_reader :buildr_project
|
8
|
-
attr_writer :suffix
|
9
|
-
attr_writer :id
|
10
|
-
attr_accessor :template
|
11
|
-
|
12
|
-
def suffix
|
13
|
-
@suffix ||= DEFAULT_SUFFIX
|
14
|
-
end
|
15
|
-
|
16
|
-
def filename
|
17
|
-
buildr_project.path_to("#{name}.#{extension}")
|
18
|
-
end
|
19
|
-
|
20
|
-
def id
|
21
|
-
@id ||= buildr_project.name.split(':').last
|
22
|
-
end
|
23
|
-
|
24
|
-
def add_component(name, attrs = {}, &xml)
|
25
|
-
self.components << create_component(name, attrs, &xml)
|
26
|
-
end
|
27
|
-
|
28
|
-
def write(f)
|
29
|
-
document.write f
|
30
|
-
end
|
31
|
-
|
32
|
-
protected
|
33
|
-
|
34
|
-
def name
|
35
|
-
"#{self.id}#{suffix}"
|
36
|
-
end
|
37
|
-
|
38
|
-
def create_component(name, attrs = {})
|
39
|
-
target = StringIO.new
|
40
|
-
Builder::XmlMarkup.new(:target => target, :indent => 2).component(attrs.merge({ :name => name })) do |xml|
|
41
|
-
yield xml if block_given?
|
42
|
-
end
|
43
|
-
REXML::Document.new(target.string).root
|
44
|
-
end
|
45
|
-
|
46
|
-
def components
|
47
|
-
@components ||= self.default_components.compact
|
48
|
-
end
|
49
|
-
|
50
|
-
def load_document(filename)
|
51
|
-
REXML::Document.new(File.read(filename))
|
52
|
-
end
|
53
|
-
|
54
|
-
def document
|
55
|
-
if File.exist?(self.filename)
|
56
|
-
doc = load_document(self.filename)
|
57
|
-
else
|
58
|
-
doc = base_document
|
59
|
-
inject_components( doc, self.initial_components )
|
60
|
-
end
|
61
|
-
if self.template
|
62
|
-
template_doc = load_document(self.template)
|
63
|
-
REXML::XPath.each(template_doc, "//component") do |element|
|
64
|
-
inject_component(doc, element)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
inject_components( doc, self.components )
|
68
|
-
doc
|
69
|
-
end
|
70
|
-
|
71
|
-
def inject_components(doc, components)
|
72
|
-
components.each do |component|
|
73
|
-
# execute deferred components
|
74
|
-
component = component.call if Proc === component
|
75
|
-
inject_component(doc, component) if component
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# replace overridden component (if any) with specified component
|
80
|
-
def inject_component(doc, component)
|
81
|
-
doc.root.delete_element("//component[@name='#{component.attributes['name']}']")
|
82
|
-
doc.root.add_element component
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
1
|
+
module Buildr
|
2
|
+
module IntellijIdea
|
3
|
+
# Abstract base class for IdeaModule and IdeaProject
|
4
|
+
class IdeaFile
|
5
|
+
DEFAULT_SUFFIX = ""
|
6
|
+
|
7
|
+
attr_reader :buildr_project
|
8
|
+
attr_writer :suffix
|
9
|
+
attr_writer :id
|
10
|
+
attr_accessor :template
|
11
|
+
|
12
|
+
def suffix
|
13
|
+
@suffix ||= DEFAULT_SUFFIX
|
14
|
+
end
|
15
|
+
|
16
|
+
def filename
|
17
|
+
buildr_project.path_to("#{name}.#{extension}")
|
18
|
+
end
|
19
|
+
|
20
|
+
def id
|
21
|
+
@id ||= buildr_project.name.split(':').last
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_component(name, attrs = {}, &xml)
|
25
|
+
self.components << create_component(name, attrs, &xml)
|
26
|
+
end
|
27
|
+
|
28
|
+
def write(f)
|
29
|
+
document.write f
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def name
|
35
|
+
"#{self.id}#{suffix}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_component(name, attrs = {})
|
39
|
+
target = StringIO.new
|
40
|
+
Builder::XmlMarkup.new(:target => target, :indent => 2).component(attrs.merge({ :name => name })) do |xml|
|
41
|
+
yield xml if block_given?
|
42
|
+
end
|
43
|
+
REXML::Document.new(target.string).root
|
44
|
+
end
|
45
|
+
|
46
|
+
def components
|
47
|
+
@components ||= self.default_components.compact
|
48
|
+
end
|
49
|
+
|
50
|
+
def load_document(filename)
|
51
|
+
REXML::Document.new(File.read(filename))
|
52
|
+
end
|
53
|
+
|
54
|
+
def document
|
55
|
+
if File.exist?(self.filename)
|
56
|
+
doc = load_document(self.filename)
|
57
|
+
else
|
58
|
+
doc = base_document
|
59
|
+
inject_components( doc, self.initial_components )
|
60
|
+
end
|
61
|
+
if self.template
|
62
|
+
template_doc = load_document(self.template)
|
63
|
+
REXML::XPath.each(template_doc, "//component") do |element|
|
64
|
+
inject_component(doc, element)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
inject_components( doc, self.components )
|
68
|
+
doc
|
69
|
+
end
|
70
|
+
|
71
|
+
def inject_components(doc, components)
|
72
|
+
components.each do |component|
|
73
|
+
# execute deferred components
|
74
|
+
component = component.call if Proc === component
|
75
|
+
inject_component(doc, component) if component
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# replace overridden component (if any) with specified component
|
80
|
+
def inject_component(doc, component)
|
81
|
+
doc.root.delete_element("//component[@name='#{component.attributes['name']}']")
|
82
|
+
doc.root.add_element component
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
86
|
end
|
@@ -1,264 +1,256 @@
|
|
1
|
-
module Buildr
|
2
|
-
module IntellijIdea
|
3
|
-
class IdeaModule < IdeaFile
|
4
|
-
DEFAULT_TYPE = "JAVA_MODULE"
|
5
|
-
DEFAULT_LOCAL_REPOSITORY_ENV_OVERRIDE = "MAVEN_REPOSITORY"
|
6
|
-
|
7
|
-
attr_accessor :type
|
8
|
-
attr_accessor :local_repository_env_override
|
9
|
-
attr_accessor :group
|
10
|
-
attr_reader :facets
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
@type = DEFAULT_TYPE
|
14
|
-
@local_repository_env_override = DEFAULT_LOCAL_REPOSITORY_ENV_OVERRIDE
|
15
|
-
end
|
16
|
-
|
17
|
-
def buildr_project=(buildr_project)
|
18
|
-
@id = nil
|
19
|
-
@facets = []
|
20
|
-
@skip_content = false
|
21
|
-
@buildr_project = buildr_project
|
22
|
-
end
|
23
|
-
|
24
|
-
def extension
|
25
|
-
"iml"
|
26
|
-
end
|
27
|
-
|
28
|
-
def main_source_directories
|
29
|
-
@main_source_directories ||= [
|
30
|
-
buildr_project.compile.sources,
|
31
|
-
buildr_project.resources.sources
|
32
|
-
].flatten.compact
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_source_directories
|
36
|
-
@test_source_directories ||= [
|
37
|
-
buildr_project.test.compile.sources,
|
38
|
-
buildr_project.test.resources.sources
|
39
|
-
].flatten.compact
|
40
|
-
end
|
41
|
-
|
42
|
-
def excluded_directories
|
43
|
-
@excluded_directories ||= [
|
44
|
-
buildr_project.resources.target,
|
45
|
-
buildr_project.test.resources.target,
|
46
|
-
buildr_project.path_to(:target, :main),
|
47
|
-
buildr_project.path_to(:target, :test),
|
48
|
-
buildr_project.path_to(:reports)
|
49
|
-
].flatten.compact
|
50
|
-
end
|
51
|
-
|
52
|
-
def main_output_dir
|
53
|
-
buildr_project.compile.target || buildr_project.path_to(:target, :main, 'idea')
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_output_dir
|
57
|
-
buildr_project.test.compile.target || buildr_project.path_to(:target, :test, 'idea')
|
58
|
-
end
|
59
|
-
|
60
|
-
def
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
def
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
def skip_content
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
def
|
110
|
-
[
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
fm
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
project_for_dependency
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
end
|
160
|
-
|
161
|
-
def
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
end
|
168
|
-
|
169
|
-
def
|
170
|
-
|
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
|
-
|
204
|
-
|
205
|
-
|
206
|
-
end
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
attribs
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
unless all[0 ... i].find { |other| dir =~ /^#{other}/ }
|
257
|
-
net << dir
|
258
|
-
end
|
259
|
-
end
|
260
|
-
net
|
261
|
-
end
|
262
|
-
end
|
263
|
-
end
|
1
|
+
module Buildr
|
2
|
+
module IntellijIdea
|
3
|
+
class IdeaModule < IdeaFile
|
4
|
+
DEFAULT_TYPE = "JAVA_MODULE"
|
5
|
+
DEFAULT_LOCAL_REPOSITORY_ENV_OVERRIDE = "MAVEN_REPOSITORY"
|
6
|
+
|
7
|
+
attr_accessor :type
|
8
|
+
attr_accessor :local_repository_env_override
|
9
|
+
attr_accessor :group
|
10
|
+
attr_reader :facets
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@type = DEFAULT_TYPE
|
14
|
+
@local_repository_env_override = DEFAULT_LOCAL_REPOSITORY_ENV_OVERRIDE
|
15
|
+
end
|
16
|
+
|
17
|
+
def buildr_project=(buildr_project)
|
18
|
+
@id = nil
|
19
|
+
@facets = []
|
20
|
+
@skip_content = false
|
21
|
+
@buildr_project = buildr_project
|
22
|
+
end
|
23
|
+
|
24
|
+
def extension
|
25
|
+
"iml"
|
26
|
+
end
|
27
|
+
|
28
|
+
def main_source_directories
|
29
|
+
@main_source_directories ||= [
|
30
|
+
buildr_project.compile.sources,
|
31
|
+
buildr_project.resources.sources
|
32
|
+
].flatten.compact
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_source_directories
|
36
|
+
@test_source_directories ||= [
|
37
|
+
buildr_project.test.compile.sources,
|
38
|
+
buildr_project.test.resources.sources
|
39
|
+
].flatten.compact
|
40
|
+
end
|
41
|
+
|
42
|
+
def excluded_directories
|
43
|
+
@excluded_directories ||= [
|
44
|
+
buildr_project.resources.target,
|
45
|
+
buildr_project.test.resources.target,
|
46
|
+
buildr_project.path_to(:target, :main),
|
47
|
+
buildr_project.path_to(:target, :test),
|
48
|
+
buildr_project.path_to(:reports)
|
49
|
+
].flatten.compact
|
50
|
+
end
|
51
|
+
|
52
|
+
def main_output_dir
|
53
|
+
buildr_project.compile.target || buildr_project.path_to(:target, :main, 'idea')
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_output_dir
|
57
|
+
buildr_project.test.compile.target || buildr_project.path_to(:target, :test, 'idea')
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_dependencies
|
61
|
+
main_dependencies_paths = buildr_project.compile.dependencies.map(&:to_s)
|
62
|
+
target_dir = buildr_project.compile.target.to_s
|
63
|
+
buildr_project.test.compile.dependencies.select{|d| d.to_s != target_dir}.collect do |d|
|
64
|
+
dependency_path = d.to_s
|
65
|
+
export = main_dependencies_paths.include?(dependency_path)
|
66
|
+
source_path = nil
|
67
|
+
if d.respond_to?(:to_spec_hash)
|
68
|
+
source_spec = d.to_spec_hash.merge(:classifier => 'sources')
|
69
|
+
source_path = Buildr.artifact(source_spec).to_s
|
70
|
+
source_path = nil unless File.exist?(source_path)
|
71
|
+
end
|
72
|
+
[dependency_path, export, source_path]
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
def base_directory
|
78
|
+
buildr_project.path_to
|
79
|
+
end
|
80
|
+
|
81
|
+
def add_facet(name, type)
|
82
|
+
target = StringIO.new
|
83
|
+
Builder::XmlMarkup.new(:target => target, :indent => 2).facet(:name => name, :type => type) do |xml|
|
84
|
+
yield xml if block_given?
|
85
|
+
end
|
86
|
+
self.facets << REXML::Document.new(target.string).root
|
87
|
+
end
|
88
|
+
|
89
|
+
def skip_content?
|
90
|
+
!!@skip_content
|
91
|
+
end
|
92
|
+
|
93
|
+
def skip_content!
|
94
|
+
@skip_content = true
|
95
|
+
end
|
96
|
+
|
97
|
+
protected
|
98
|
+
|
99
|
+
def base_document
|
100
|
+
target = StringIO.new
|
101
|
+
Builder::XmlMarkup.new(:target => target).module(:version => "4", :relativePaths => "true", :type => self.type)
|
102
|
+
REXML::Document.new(target.string)
|
103
|
+
end
|
104
|
+
|
105
|
+
def initial_components
|
106
|
+
[]
|
107
|
+
end
|
108
|
+
|
109
|
+
def default_components
|
110
|
+
[
|
111
|
+
lambda { module_root_component },
|
112
|
+
lambda { facet_component }
|
113
|
+
]
|
114
|
+
end
|
115
|
+
|
116
|
+
def facet_component
|
117
|
+
return nil if self.facets.empty?
|
118
|
+
fm = self.create_component("FacetManager")
|
119
|
+
self.facets.each do |facet|
|
120
|
+
fm.add_element facet
|
121
|
+
end
|
122
|
+
fm
|
123
|
+
end
|
124
|
+
|
125
|
+
def module_root_component
|
126
|
+
create_component("NewModuleRootManager", "inherit-compiler-output" => "false") do |xml|
|
127
|
+
generate_compile_output(xml)
|
128
|
+
generate_content(xml) unless skip_content?
|
129
|
+
generate_initial_order_entries(xml)
|
130
|
+
project_dependencies = []
|
131
|
+
|
132
|
+
# Note: Use the test classpath since IDEA compiles both "main" and "test" classes using the same classpath
|
133
|
+
self.test_dependencies.each do |dependency_path, export, source_path|
|
134
|
+
project_for_dependency = Buildr.projects.detect do |project|
|
135
|
+
[project.packages, project.compile.target, project.test.compile.target].flatten.
|
136
|
+
detect { |proj_art| proj_art.to_s == dependency_path }
|
137
|
+
end
|
138
|
+
if project_for_dependency
|
139
|
+
if project_for_dependency.iml? && !project_dependencies.include?(project_for_dependency)
|
140
|
+
generate_project_dependency( xml, project_for_dependency.iml.name, export )
|
141
|
+
end
|
142
|
+
project_dependencies << project_for_dependency
|
143
|
+
next
|
144
|
+
else
|
145
|
+
generate_module_lib(xml, url_for_path(dependency_path), export, (source_path ? url_for_path(source_path) : nil))
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
xml.orderEntryProperties
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def jar_path(path)
|
154
|
+
"jar://#{resolve_path(path)}!/"
|
155
|
+
end
|
156
|
+
|
157
|
+
def file_path(path)
|
158
|
+
"file://#{resolve_path(path)}"
|
159
|
+
end
|
160
|
+
|
161
|
+
def url_for_path(path)
|
162
|
+
if path =~ /jar$/i
|
163
|
+
jar_path(path)
|
164
|
+
else
|
165
|
+
file_path(path)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def resolve_path(path)
|
170
|
+
m2repo = Buildr::Repositories.instance.local
|
171
|
+
if path.to_s.index(m2repo) == 0 && !self.local_repository_env_override.nil?
|
172
|
+
return path.sub(m2repo, "$#{self.local_repository_env_override}$")
|
173
|
+
else
|
174
|
+
return "$MODULE_DIR$/#{relative(path)}"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def relative(path)
|
179
|
+
::Buildr::Util.relative_path(File.expand_path(path.to_s), self.base_directory)
|
180
|
+
end
|
181
|
+
|
182
|
+
def generate_compile_output(xml)
|
183
|
+
xml.output(:url => file_path(self.main_output_dir.to_s))
|
184
|
+
xml.tag!("output-test", :url => file_path(self.test_output_dir.to_s))
|
185
|
+
xml.tag!("exclude-output")
|
186
|
+
end
|
187
|
+
|
188
|
+
def generate_content(xml)
|
189
|
+
xml.content(:url => "file://$MODULE_DIR$") do
|
190
|
+
# Source folders
|
191
|
+
{
|
192
|
+
:main => self.main_source_directories,
|
193
|
+
:test => self.test_source_directories
|
194
|
+
}.each do |kind, directories|
|
195
|
+
directories.map { |dir| dir.to_s }.compact.sort.uniq.each do |dir|
|
196
|
+
xml.sourceFolder :url => file_path(dir), :isTestSource => (kind == :test ? 'true' : 'false')
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
# Exclude target directories
|
201
|
+
self.net_excluded_directories.
|
202
|
+
collect { |dir| file_path(dir) }.
|
203
|
+
select{ |dir| relative_dir_inside_dir?(dir) }.
|
204
|
+
sort.each do |dir|
|
205
|
+
xml.excludeFolder :url => dir
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def relative_dir_inside_dir?(dir)
|
211
|
+
!dir.include?("../")
|
212
|
+
end
|
213
|
+
|
214
|
+
def generate_initial_order_entries(xml)
|
215
|
+
xml.orderEntry :type => "sourceFolder", :forTests => "false"
|
216
|
+
xml.orderEntry :type => "inheritedJdk"
|
217
|
+
end
|
218
|
+
|
219
|
+
def generate_project_dependency(xml, other_project, export = true)
|
220
|
+
attribs = {:type => 'module', "module-name" => other_project}
|
221
|
+
attribs[:exported] = '' if export
|
222
|
+
xml.orderEntry attribs
|
223
|
+
end
|
224
|
+
|
225
|
+
def generate_module_lib(xml, path, export, source_path)
|
226
|
+
attribs = {:type => 'module-library'}
|
227
|
+
attribs[:exported] = '' if export
|
228
|
+
xml.orderEntry attribs do
|
229
|
+
xml.library do
|
230
|
+
xml.CLASSES do
|
231
|
+
xml.root :url => path
|
232
|
+
end
|
233
|
+
xml.JAVADOC
|
234
|
+
xml.SOURCES do
|
235
|
+
if source_path
|
236
|
+
xml.root :url => source_path
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
# Don't exclude things that are subdirectories of other excluded things
|
244
|
+
def net_excluded_directories
|
245
|
+
net = []
|
246
|
+
all = self.excluded_directories.map { |dir| buildr_project._(dir.to_s) }.sort_by { |d| d.size }
|
247
|
+
all.each_with_index do |dir, i|
|
248
|
+
unless all[0 ... i].find { |other| dir =~ /^#{other}/ }
|
249
|
+
net << dir
|
250
|
+
end
|
251
|
+
end
|
252
|
+
net
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
264
256
|
end
|