buildr-iidea 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,243 +1,243 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
- describe "iidea:generate" do
4
- describe "with a single project definition" do
5
- describe "and default naming" do
6
- before do
7
- @foo = define "foo"
8
- invoke_generate_task
9
- end
10
-
11
- it "generates a single IPR" do
12
- Dir[@foo._("**/*.ipr")].should have(1).entry
13
- end
14
-
15
- it "generate an IPR in the root directory" do
16
- File.should be_exist(@foo._("foo.ipr"))
17
- end
18
-
19
- it "generates a single IML" do
20
- Dir[@foo._("**/*.iml")].should have(1).entry
21
- end
22
-
23
- it "generates an IML in the root directory" do
24
- File.should be_exist(@foo._("foo.iml"))
25
- end
26
-
27
- it "generate an IPR with the reference to correct module file" do
28
- File.should be_exist(@foo._("foo.ipr"))
29
- doc = xml_document(@foo._("foo.ipr"))
30
- module_ref = "$PROJECT_DIR$/foo.iml"
31
- doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
32
- end
33
- end
34
-
35
- describe "with no_iml generation disabled" do
36
- before do
37
- @foo = define "foo" do
38
- project.no_iml
39
- end
40
- invoke_generate_task
41
- end
42
-
43
- it "generates no IML" do
44
- Dir[@foo._("**/*.iml")].should have(0).entry
45
- end
46
-
47
- it "generate an IPR with no references" do
48
- File.should be_exist(@foo._("foo.ipr"))
49
- doc = xml_document(@foo._("foo.ipr"))
50
- doc.should have_nodes("#{xpath_to_module}", 0)
51
- end
52
- end
53
-
54
- describe "with ipr generation disabled" do
55
- before do
56
- @foo = define "foo" do
57
- project.no_ipr
58
- end
59
- invoke_generate_task
60
- end
61
-
62
- it "generates a single IML" do
63
- Dir[@foo._("**/*.iml")].should have(1).entry
64
- end
65
-
66
- it "generate no IPR" do
67
- File.should_not be_exist(@foo._("foo.ipr"))
68
- end
69
- end
70
-
71
- describe "and id overrides" do
72
- before do
73
- @foo = define "foo" do
74
- ipr.id = 'fooble'
75
- iml.id = 'feap'
76
- define "bar" do
77
- iml.id = "baz"
78
- end
79
- end
80
- invoke_generate_task
81
- end
82
-
83
- it "generate an IPR in the root directory" do
84
- File.should be_exist(@foo._("fooble.ipr"))
85
- end
86
-
87
- it "generates an IML in the root directory" do
88
- File.should be_exist(@foo._("feap.iml"))
89
- end
90
-
91
- it "generates an IML in the subproject directory" do
92
- File.should be_exist(@foo._("bar/baz.iml"))
93
- end
94
-
95
- it "generate an IPR with the reference to correct module file" do
96
- File.should be_exist(@foo._("fooble.ipr"))
97
- doc = xml_document(@foo._("fooble.ipr"))
98
- module_ref = "$PROJECT_DIR$/feap.iml"
99
- doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
100
- end
101
- end
102
-
103
- describe "and a suffix defined" do
104
- before do
105
- @foo = define "foo" do
106
- ipr.suffix = '-ipr-suffix'
107
- iml.suffix = '-iml-suffix'
108
- end
109
- invoke_generate_task
110
- end
111
-
112
- it "generate an IPR in the root directory" do
113
- File.should be_exist(@foo._("foo-ipr-suffix.ipr"))
114
- end
115
-
116
- it "generates an IML in the root directory" do
117
- File.should be_exist(@foo._("foo-iml-suffix.iml"))
118
- end
119
-
120
- it "generate an IPR with the reference to correct module file" do
121
- File.should be_exist(@foo._("foo-ipr-suffix.ipr"))
122
- doc = xml_document(@foo._("foo-ipr-suffix.ipr"))
123
- doc.should have_nodes("#{xpath_to_module}", 1)
124
- module_ref = "$PROJECT_DIR$/foo-iml-suffix.iml"
125
- doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
126
- end
127
- end
128
- end
129
-
130
- describe "with a subproject" do
131
- before do
132
- @foo = define "foo" do
133
- define 'bar'
134
- end
135
- invoke_generate_task
136
- end
137
-
138
- it "creates the subproject directory" do
139
- File.should be_exist(@foo._("bar"))
140
- end
141
-
142
- it "generates an IML in the subproject directory" do
143
- File.should be_exist(@foo._("bar/bar.iml"))
144
- end
145
-
146
- it "generate an IPR with the reference to correct module file" do
147
- File.should be_exist(@foo._("foo.ipr"))
148
- doc = xml_document(@foo._("foo.ipr"))
149
- doc.should have_nodes("#{xpath_to_module}", 2)
150
- module_ref = "$PROJECT_DIR$/foo.iml"
151
- doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
152
- module_ref = "$PROJECT_DIR$/bar/bar.iml"
153
- doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
154
- end
155
- end
156
-
157
- describe "with base_dir specified" do
158
- before do
159
- @foo = define "foo" do
160
- define('bar', :base_dir => 'fe') do
161
- define('baz', :base_dir => 'fi') do
162
- define('foe')
163
- end
164
- define('fum')
165
- end
166
- end
167
- invoke_generate_task
168
- end
169
-
170
- it "generates a subproject IML in the specified directory" do
171
- File.should be_exist(@foo._("fe/bar.iml"))
172
- end
173
-
174
- it "generates a sub-subproject IML in the specified directory" do
175
- File.should be_exist(@foo._("fi/baz.iml"))
176
- end
177
-
178
- it "generates a sub-sub-subproject IML that inherits the specified directory" do
179
- File.should be_exist(@foo._("fi/foe/foe.iml"))
180
- end
181
-
182
- it "generates a sub-subproject IML that inherits the specified directory" do
183
- File.should be_exist(@foo._("fe/fum/fum.iml"))
184
- end
185
-
186
- it "generate an IPR with the references to correct module files" do
187
- doc = xml_document(@foo._("foo.ipr"))
188
- doc.should have_nodes("#{xpath_to_module}", 5)
189
- ["foo.iml", "fe/bar.iml", "fi/baz.iml", "fi/foe/foe.iml","fe/fum/fum.iml"].each do |module_ref|
190
- doc.should have_nodes("#{xpath_to_module}[@fileurl='file://$PROJECT_DIR$/#{module_ref}', @filepath='$PROJECT_DIR$/#{module_ref}']", 1)
191
- end
192
- end
193
- end
194
-
195
- describe "with extensive intermodule dependencies" do
196
- before do
197
- mkdir_p 'foo/src/main/resources'
198
- mkdir_p 'foo/src/main/java/foo'
199
- touch 'foo/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
200
- define "root" do
201
- repositories.remote << 'http://mirrors.ibiblio.org/pub/mirrors/maven2/'
202
- project.version = "2.5.2"
203
- define 'foo' do
204
- resources.from _(:source, :main, :resources)
205
- compile.with 'org.slf4j:slf4j-api:jar:1.5.11'
206
- test.using(:junit)
207
- package(:jar)
208
- end
209
-
210
- define 'bar' do
211
- # internally transitive dependencies on foo, both runtime and test
212
- compile.with project('root:foo'), project('root:foo').compile.dependencies
213
- test.using(:junit).with [project('root:foo').test.compile.target,
214
- project('root:foo').test.resources.target,
215
- project('root:foo').test.compile.dependencies].compact
216
- package(:jar)
217
- end
218
- end
219
-
220
- invoke_generate_task
221
- @bar_iml = xml_document(project('root:bar')._('bar.iml'))
222
- @bar_lib_urls = @bar_iml.get_elements("//orderEntry[@type='module-library']/library/CLASSES/root").collect do |root|
223
- root.attribute('url').to_s
224
- end
225
- end
226
-
227
- it "depends on the associated module exactly once" do
228
- @bar_iml.should have_nodes("//orderEntry[@type='module', @module-name='foo']", 1)
229
- end
230
-
231
- it "does not depend on the other project's packaged JAR" do
232
- @bar_lib_urls.grep(%r{#{project('root:foo').packages.first}}).should == []
233
- end
234
-
235
- it "does not depend on the the other project's target/classes directory" do
236
- @bar_lib_urls.grep(%r{foo/target/classes}).should == []
237
- end
238
-
239
- it "depends on the the other project's target/resources directory" do
240
- @bar_lib_urls.grep(%r{file://\$MODULE_DIR\$/../foo/target/resources}).size.should == 1
241
- end
242
- end
243
- end
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+
3
+ describe "iidea:generate" do
4
+ describe "with a single project definition" do
5
+ describe "and default naming" do
6
+ before do
7
+ @foo = define "foo"
8
+ invoke_generate_task
9
+ end
10
+
11
+ it "generates a single IPR" do
12
+ Dir[@foo._("**/*.ipr")].should have(1).entry
13
+ end
14
+
15
+ it "generate an IPR in the root directory" do
16
+ File.should be_exist(@foo._("foo.ipr"))
17
+ end
18
+
19
+ it "generates a single IML" do
20
+ Dir[@foo._("**/*.iml")].should have(1).entry
21
+ end
22
+
23
+ it "generates an IML in the root directory" do
24
+ File.should be_exist(@foo._("foo.iml"))
25
+ end
26
+
27
+ it "generate an IPR with the reference to correct module file" do
28
+ File.should be_exist(@foo._("foo.ipr"))
29
+ doc = xml_document(@foo._("foo.ipr"))
30
+ module_ref = "$PROJECT_DIR$/foo.iml"
31
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
32
+ end
33
+ end
34
+
35
+ describe "with no_iml generation disabled" do
36
+ before do
37
+ @foo = define "foo" do
38
+ project.no_iml
39
+ end
40
+ invoke_generate_task
41
+ end
42
+
43
+ it "generates no IML" do
44
+ Dir[@foo._("**/*.iml")].should have(0).entry
45
+ end
46
+
47
+ it "generate an IPR with no references" do
48
+ File.should be_exist(@foo._("foo.ipr"))
49
+ doc = xml_document(@foo._("foo.ipr"))
50
+ doc.should have_nodes("#{xpath_to_module}", 0)
51
+ end
52
+ end
53
+
54
+ describe "with ipr generation disabled" do
55
+ before do
56
+ @foo = define "foo" do
57
+ project.no_ipr
58
+ end
59
+ invoke_generate_task
60
+ end
61
+
62
+ it "generates a single IML" do
63
+ Dir[@foo._("**/*.iml")].should have(1).entry
64
+ end
65
+
66
+ it "generate no IPR" do
67
+ File.should_not be_exist(@foo._("foo.ipr"))
68
+ end
69
+ end
70
+
71
+ describe "and id overrides" do
72
+ before do
73
+ @foo = define "foo" do
74
+ ipr.id = 'fooble'
75
+ iml.id = 'feap'
76
+ define "bar" do
77
+ iml.id = "baz"
78
+ end
79
+ end
80
+ invoke_generate_task
81
+ end
82
+
83
+ it "generate an IPR in the root directory" do
84
+ File.should be_exist(@foo._("fooble.ipr"))
85
+ end
86
+
87
+ it "generates an IML in the root directory" do
88
+ File.should be_exist(@foo._("feap.iml"))
89
+ end
90
+
91
+ it "generates an IML in the subproject directory" do
92
+ File.should be_exist(@foo._("bar/baz.iml"))
93
+ end
94
+
95
+ it "generate an IPR with the reference to correct module file" do
96
+ File.should be_exist(@foo._("fooble.ipr"))
97
+ doc = xml_document(@foo._("fooble.ipr"))
98
+ module_ref = "$PROJECT_DIR$/feap.iml"
99
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
100
+ end
101
+ end
102
+
103
+ describe "and a suffix defined" do
104
+ before do
105
+ @foo = define "foo" do
106
+ ipr.suffix = '-ipr-suffix'
107
+ iml.suffix = '-iml-suffix'
108
+ end
109
+ invoke_generate_task
110
+ end
111
+
112
+ it "generate an IPR in the root directory" do
113
+ File.should be_exist(@foo._("foo-ipr-suffix.ipr"))
114
+ end
115
+
116
+ it "generates an IML in the root directory" do
117
+ File.should be_exist(@foo._("foo-iml-suffix.iml"))
118
+ end
119
+
120
+ it "generate an IPR with the reference to correct module file" do
121
+ File.should be_exist(@foo._("foo-ipr-suffix.ipr"))
122
+ doc = xml_document(@foo._("foo-ipr-suffix.ipr"))
123
+ doc.should have_nodes("#{xpath_to_module}", 1)
124
+ module_ref = "$PROJECT_DIR$/foo-iml-suffix.iml"
125
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
126
+ end
127
+ end
128
+ end
129
+
130
+ describe "with a subproject" do
131
+ before do
132
+ @foo = define "foo" do
133
+ define 'bar'
134
+ end
135
+ invoke_generate_task
136
+ end
137
+
138
+ it "creates the subproject directory" do
139
+ File.should be_exist(@foo._("bar"))
140
+ end
141
+
142
+ it "generates an IML in the subproject directory" do
143
+ File.should be_exist(@foo._("bar/bar.iml"))
144
+ end
145
+
146
+ it "generate an IPR with the reference to correct module file" do
147
+ File.should be_exist(@foo._("foo.ipr"))
148
+ doc = xml_document(@foo._("foo.ipr"))
149
+ doc.should have_nodes("#{xpath_to_module}", 2)
150
+ module_ref = "$PROJECT_DIR$/foo.iml"
151
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
152
+ module_ref = "$PROJECT_DIR$/bar/bar.iml"
153
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
154
+ end
155
+ end
156
+
157
+ describe "with base_dir specified" do
158
+ before do
159
+ @foo = define "foo" do
160
+ define('bar', :base_dir => 'fe') do
161
+ define('baz', :base_dir => 'fi') do
162
+ define('foe')
163
+ end
164
+ define('fum')
165
+ end
166
+ end
167
+ invoke_generate_task
168
+ end
169
+
170
+ it "generates a subproject IML in the specified directory" do
171
+ File.should be_exist(@foo._("fe/bar.iml"))
172
+ end
173
+
174
+ it "generates a sub-subproject IML in the specified directory" do
175
+ File.should be_exist(@foo._("fi/baz.iml"))
176
+ end
177
+
178
+ it "generates a sub-sub-subproject IML that inherits the specified directory" do
179
+ File.should be_exist(@foo._("fi/foe/foe.iml"))
180
+ end
181
+
182
+ it "generates a sub-subproject IML that inherits the specified directory" do
183
+ File.should be_exist(@foo._("fe/fum/fum.iml"))
184
+ end
185
+
186
+ it "generate an IPR with the references to correct module files" do
187
+ doc = xml_document(@foo._("foo.ipr"))
188
+ doc.should have_nodes("#{xpath_to_module}", 5)
189
+ ["foo.iml", "fe/bar.iml", "fi/baz.iml", "fi/foe/foe.iml","fe/fum/fum.iml"].each do |module_ref|
190
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://$PROJECT_DIR$/#{module_ref}', @filepath='$PROJECT_DIR$/#{module_ref}']", 1)
191
+ end
192
+ end
193
+ end
194
+
195
+ describe "with extensive intermodule dependencies" do
196
+ before do
197
+ mkdir_p 'foo/src/main/resources'
198
+ mkdir_p 'foo/src/main/java/foo'
199
+ touch 'foo/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
200
+ define "root" do
201
+ repositories.remote << 'http://mirrors.ibiblio.org/pub/mirrors/maven2/'
202
+ project.version = "2.5.2"
203
+ define 'foo' do
204
+ resources.from _(:source, :main, :resources)
205
+ compile.with 'org.slf4j:slf4j-api:jar:1.5.11'
206
+ test.using(:junit)
207
+ package(:jar)
208
+ end
209
+
210
+ define 'bar' do
211
+ # internally transitive dependencies on foo, both runtime and test
212
+ compile.with project('root:foo'), project('root:foo').compile.dependencies
213
+ test.using(:junit).with [project('root:foo').test.compile.target,
214
+ project('root:foo').test.resources.target,
215
+ project('root:foo').test.compile.dependencies].compact
216
+ package(:jar)
217
+ end
218
+ end
219
+
220
+ invoke_generate_task
221
+ @bar_iml = xml_document(project('root:bar')._('bar.iml'))
222
+ @bar_lib_urls = @bar_iml.get_elements("//orderEntry[@type='module-library']/library/CLASSES/root").collect do |root|
223
+ root.attribute('url').to_s
224
+ end
225
+ end
226
+
227
+ it "depends on the associated module exactly once" do
228
+ @bar_iml.should have_nodes("//orderEntry[@type='module', @module-name='foo']", 1)
229
+ end
230
+
231
+ it "does not depend on the other project's packaged JAR" do
232
+ @bar_lib_urls.grep(%r{#{project('root:foo').packages.first}}).should == []
233
+ end
234
+
235
+ it "does not depend on the the other project's target/classes directory" do
236
+ @bar_lib_urls.grep(%r{foo/target/classes}).should == []
237
+ end
238
+
239
+ it "depends on the the other project's target/resources directory" do
240
+ @bar_lib_urls.grep(%r{file://\$MODULE_DIR\$/../foo/target/resources}).size.should == 1
241
+ end
242
+ end
243
+ end