buildr4osgi 0.9.0 → 0.9.2
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/buildr4osgi.gemspec +2 -2
- data/lib/buildr4osgi/compile/compiler.rb +23 -5
- data/lib/buildr4osgi/compile.rb +1 -1
- data/lib/buildr4osgi/eclipse/feature.rb +206 -65
- data/lib/buildr4osgi/osgi/bundle.rb +5 -7
- data/lib/buildr4osgi/osgi/bundle_package.rb +2 -2
- data/lib/buildr4osgi/osgi/container.rb +5 -0
- data/lib/buildr4osgi/osgi/dependencies.rb +91 -0
- data/lib/buildr4osgi/osgi/library_extension.rb +6 -4
- data/lib/buildr4osgi/osgi/packaging.rb +78 -6
- data/lib/buildr4osgi/osgi/packaging_sources.rb +86 -0
- data/lib/buildr4osgi/osgi/project_extension.rb +9 -115
- data/lib/buildr4osgi/osgi/registry.rb +71 -1
- data/lib/buildr4osgi/osgi/resolving_strategies.rb +4 -2
- data/lib/buildr4osgi/osgi.rb +2 -0
- data/lib/buildr4osgi.rb +0 -1
- data/rakelib/release.rake +3 -0
- data/rakelib/rspec.rake +3 -3
- data/rakelib/stage.rake +7 -0
- data/spec/compile/compiler_spec.rb +40 -8
- data/spec/eclipse/feature_spec.rb +103 -6
- data/spec/osgi/bundle_spec.rb +2 -2
- data/spec/osgi/dependencies_spec.rb +91 -0
- data/spec/osgi/library_extension_spec.rb +17 -0
- data/spec/osgi/packaging_sources_spec.rb +71 -0
- data/spec/osgi/packaging_spec.rb +11 -1
- data/spec/osgi/project_extension_spec.rb +31 -21
- data/spec/osgi/registry_spec.rb +31 -0
- data/spec/osgi/resolving_strategies_spec.rb +116 -0
- data/spec/spec_helpers.rb +2 -2
- data/spec/tmp/remote/log4j/log4j/1.2.15/log4j-1.2.15.jar +0 -0
- data/spec/tmp/remote/log4j/log4j/1.2.15/log4j-1.2.15.pom +478 -0
- metadata +10 -13
- data/lib/buildr4osgi/nature/eclipse.rb +0 -80
- data/lib/buildr4osgi/nature/java.rb +0 -32
- data/lib/buildr4osgi/nature/nature.rb +0 -156
- data/lib/buildr4osgi/nature/osgi.rb +0 -32
- data/lib/buildr4osgi/nature/scala.rb +0 -32
- data/spec/nature/eclipse_spec.rb +0 -46
- data/spec/nature/java_spec.rb +0 -45
- data/spec/nature/osgi_spec.rb +0 -63
- data/spec/nature/scala_spec.rb +0 -45
- data/spec/nature_spec.rb +0 -144
@@ -1,156 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
-
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
-
# work for additional information regarding copyright ownership. The ASF
|
4
|
-
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
-
# "License"); you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations under
|
14
|
-
# the License.
|
15
|
-
|
16
|
-
module Buildr
|
17
|
-
|
18
|
-
# The nature class is extended into project natures.
|
19
|
-
# See for example the JavaNature of the ScalaNature.
|
20
|
-
# A nature defines an unique id amonsgt all natures.
|
21
|
-
#
|
22
|
-
# These fields may be set when initializing an instance:
|
23
|
-
# eclipse_builders
|
24
|
-
# Used by the Eclipse task to output in .project, a builder being an Eclipse-specific background job to build a project.
|
25
|
-
# eclipse_natures
|
26
|
-
# Used by the Eclipse task to output in .classpath,
|
27
|
-
# an Eclipse nature is an Eclipse-specific concept used by the framework to determine the projects features.
|
28
|
-
# classpath_containers
|
29
|
-
# Used by the Eclipse task to output in .classpath,
|
30
|
-
# it is a special container identified by Eclipse for compilation.
|
31
|
-
#
|
32
|
-
class DefaultNature
|
33
|
-
|
34
|
-
class EclipseOptions
|
35
|
-
|
36
|
-
def self.attr_accessor(*names)
|
37
|
-
names.each { |name|
|
38
|
-
module_eval %{
|
39
|
-
attr_reader :#{name}
|
40
|
-
|
41
|
-
def #{name}= (value)
|
42
|
-
@#{name} = value.is_a?(Array) ? value : [value]
|
43
|
-
|
44
|
-
end
|
45
|
-
}
|
46
|
-
}
|
47
|
-
end
|
48
|
-
|
49
|
-
attr_accessor :natures, :builders, :classpath_containers
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
attr_reader :id, :eclipse
|
54
|
-
|
55
|
-
def initialize(id)
|
56
|
-
@id = id
|
57
|
-
@eclipse = EclipseOptions.new
|
58
|
-
end
|
59
|
-
|
60
|
-
# Returns true if the nature applies to the project
|
61
|
-
def applies(project)
|
62
|
-
false
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
module Nature #:nodoc:
|
67
|
-
|
68
|
-
# The natures registry
|
69
|
-
# This class works as a singleton and contains all the available natures.
|
70
|
-
#
|
71
|
-
module Registry
|
72
|
-
|
73
|
-
@registered_natures = Array.new
|
74
|
-
|
75
|
-
# Adds a nature to the registry.
|
76
|
-
# Raises exception if the object provided isn't a Nature
|
77
|
-
# or if a Nature instance is already registered with the same id.
|
78
|
-
def add_nature(nature, before = nil)
|
79
|
-
raise "#{nature} is not a nature!" if (!nature.is_a? DefaultNature)
|
80
|
-
raise "A nature with the same id is already present" if (get(nature.id))
|
81
|
-
if before.nil?
|
82
|
-
@registered_natures << nature
|
83
|
-
else
|
84
|
-
@registered_natures = @registered_natures.insert(@registered_natures.index(get(before)), nature)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
# Returns a nature, from its id.
|
89
|
-
def get(nature)
|
90
|
-
if (nature.is_a? Symbol) then
|
91
|
-
@registered_natures.each {|n|
|
92
|
-
return n if (n.id == nature)
|
93
|
-
}
|
94
|
-
elsif (nature.is_a? String) then
|
95
|
-
@registered_natures.each {|n|
|
96
|
-
return n if (n.id.to_s == nature)
|
97
|
-
}
|
98
|
-
end
|
99
|
-
nil
|
100
|
-
end
|
101
|
-
|
102
|
-
# Returns all available natures
|
103
|
-
def all()
|
104
|
-
return @registered_natures.dup;
|
105
|
-
end
|
106
|
-
|
107
|
-
module_function :all, :get, :add_nature
|
108
|
-
end
|
109
|
-
|
110
|
-
module NatureExtension
|
111
|
-
include Extension
|
112
|
-
# Gives the natures defined on the project
|
113
|
-
# and the ones that apply on the project.
|
114
|
-
def applicable_natures()
|
115
|
-
Registry.all().select {|n| (natures.include?(n.id)) || n.applies(self)}
|
116
|
-
end
|
117
|
-
|
118
|
-
# :call-seq:
|
119
|
-
# natures => [:n1, :n2]
|
120
|
-
#
|
121
|
-
# Returns the project's natures.
|
122
|
-
#
|
123
|
-
# If no natures are defined on the project, the project will look for the
|
124
|
-
# natures defined in the parent's project and return them instead.
|
125
|
-
#
|
126
|
-
def natures
|
127
|
-
if @natures.nil?
|
128
|
-
if parent
|
129
|
-
@natures = parent.natures
|
130
|
-
else
|
131
|
-
@natures = []
|
132
|
-
end
|
133
|
-
end
|
134
|
-
@natures
|
135
|
-
end
|
136
|
-
|
137
|
-
protected
|
138
|
-
|
139
|
-
# :call-seq:
|
140
|
-
# natures = [n1, n2]
|
141
|
-
#
|
142
|
-
# Sets the project's natures. Allows you to specify natures by calling
|
143
|
-
# this accessor, or with the :natures property when calling #define.
|
144
|
-
#
|
145
|
-
# You can only set the natures once for a given project.
|
146
|
-
def natures=(natures)
|
147
|
-
raise 'Cannot set natures twice, or after reading its value' if @natures
|
148
|
-
@natures = (natures.is_a? Array) ? natures : [natures]
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
class Buildr::Project
|
155
|
-
include Buildr::Nature::NatureExtension
|
156
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
-
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
-
# work for additional information regarding copyright ownership. The ASF
|
4
|
-
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
-
# "License"); you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations under
|
14
|
-
# the License.
|
15
|
-
|
16
|
-
module Buildr
|
17
|
-
class OSGiNature < DefaultNature
|
18
|
-
|
19
|
-
def initialize()
|
20
|
-
super(:osgi)
|
21
|
-
eclipse.natures = "org.eclipse.pde.PluginNature"
|
22
|
-
eclipse.builders = ["org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder"]
|
23
|
-
eclipse.classpath_containers = "org.eclipse.pde.core.requiredPlugins"
|
24
|
-
end
|
25
|
-
|
26
|
-
def applies(project)
|
27
|
-
((File.exists? project.path_to("plugin.xml")) || (File.exists? project.path_to("OSGI-INF")))
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
Nature::Registry.add_nature(OSGiNature.new, :java)
|
32
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
-
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
-
# work for additional information regarding copyright ownership. The ASF
|
4
|
-
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
-
# "License"); you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations under
|
14
|
-
# the License.
|
15
|
-
|
16
|
-
module Buildr
|
17
|
-
class ScalaNature < DefaultNature
|
18
|
-
|
19
|
-
def initialize()
|
20
|
-
super(:scala)
|
21
|
-
eclipse.natures = ["ch.epfl.lamp.sdt.core.scalanature", "org.eclipse.jdt.core.javanature"]
|
22
|
-
eclipse.builders = "ch.epfl.lamp.sdt.core.scalabuilder"
|
23
|
-
eclipse.classpath_containers = ["ch.epfl.lamp.sdt.launching.SCALA_CONTAINER", "org.eclipse.jdt.launching.JRE_CONTAINER"]
|
24
|
-
end
|
25
|
-
|
26
|
-
def applies(project)
|
27
|
-
File.exists? project.path_to(:src, :main, :scala)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
Nature::Registry.add_nature(ScalaNature.new, :java)
|
32
|
-
end
|
data/spec/nature/eclipse_spec.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
-
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
-
# work for additional information regarding copyright ownership. The ASF
|
4
|
-
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
-
# "License"); you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations under
|
14
|
-
# the License.
|
15
|
-
|
16
|
-
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
17
|
-
|
18
|
-
describe Buildr::Nature::Eclipse do
|
19
|
-
after :all do
|
20
|
-
#empty the registry.
|
21
|
-
module Buildr
|
22
|
-
module Nature
|
23
|
-
module Registry
|
24
|
-
@registered_natures = DEFAULT.dup
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should replace the default Eclipse object' do
|
31
|
-
define('foo').eclipse.should be_instance_of(Buildr::Nature::Eclipse::Eclipse)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should use project natures to define Eclipse options' do
|
35
|
-
class DummyNature < Buildr::DefaultNature
|
36
|
-
def initialize()
|
37
|
-
super(:dummy)
|
38
|
-
eclipse.natures = 'MyNature'
|
39
|
-
end
|
40
|
-
end
|
41
|
-
Buildr::Nature::Registry.add_nature(DummyNature.new)
|
42
|
-
define('foo', :natures => :dummy).eclipse.options.natures.should == ['MyNature']
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
end
|
data/spec/nature/java_spec.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
-
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
-
# work for additional information regarding copyright ownership. The ASF
|
4
|
-
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
-
# "License"); you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations under
|
14
|
-
# the License.
|
15
|
-
|
16
|
-
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
17
|
-
|
18
|
-
describe 'Buildr::JavaNature' do
|
19
|
-
|
20
|
-
it 'should be registered as :java' do
|
21
|
-
Buildr::Nature::Registry.get(:java).should_not be_nil
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should define some Eclipse options' do
|
25
|
-
java = Buildr::Nature::Registry.get(:java)
|
26
|
-
java.eclipse.natures.should include("org.eclipse.jdt.core.javanature")
|
27
|
-
java.eclipse.builders.should include("org.eclipse.jdt.core.javabuilder")
|
28
|
-
java.eclipse.classpath_containers.should include("org.eclipse.jdt.launching.JRE_CONTAINER")
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should apply when a java source folder is present' do
|
32
|
-
foo = define('foo') {write('src/main/java')}
|
33
|
-
java = Buildr::Nature::Registry.get(:java)
|
34
|
-
java.applies(foo).should be_true
|
35
|
-
foo.applicable_natures.should include(java)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should not apply when no java source folder is present' do
|
39
|
-
bar = define('bar') {write('src/main/c++')}
|
40
|
-
java = Buildr::Nature::Registry.get(:java)
|
41
|
-
java.applies(bar).should_not be_true
|
42
|
-
bar.applicable_natures.should_not include(java)
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
data/spec/nature/osgi_spec.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
-
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
-
# work for additional information regarding copyright ownership. The ASF
|
4
|
-
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
-
# "License"); you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations under
|
14
|
-
# the License.
|
15
|
-
|
16
|
-
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
17
|
-
|
18
|
-
describe 'Buildr::OSGiNature' do
|
19
|
-
|
20
|
-
it 'should be registered as :osgi' do
|
21
|
-
Buildr::Nature::Registry.get(:osgi).should_not nil
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should define some Eclipse options' do
|
25
|
-
osgi = Buildr::Nature::Registry.get(:osgi)
|
26
|
-
osgi.eclipse.natures.should include("org.eclipse.pde.PluginNature")
|
27
|
-
osgi.eclipse.builders.should == ["org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder"]
|
28
|
-
osgi.eclipse.classpath_containers.should include("org.eclipse.pde.core.requiredPlugins")
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should apply when a plugin.xml file is present' do
|
32
|
-
foo = define('foo') {write('plugin.xml')}
|
33
|
-
osgi = Buildr::Nature::Registry.get(:osgi)
|
34
|
-
osgi.applies(foo).should be_true
|
35
|
-
foo.applicable_natures.should include(osgi)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should apply when a OSGi-INF directory is present' do
|
39
|
-
foo = define('foo') {write('OSGi-INF')}
|
40
|
-
osgi = Buildr::Nature::Registry.get(:osgi)
|
41
|
-
osgi.applies(foo).should be_true
|
42
|
-
foo.applicable_natures.should include(osgi)
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should not apply when no OSGi specific files are present' do
|
46
|
-
bar = define('bar') {write('src/main/c++')}
|
47
|
-
osgi = Buildr::Nature::Registry.get(:osgi)
|
48
|
-
osgi.applies(bar).should_not be_true
|
49
|
-
bar.applicable_natures.should_not include(osgi)
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should write the right .project file' do
|
53
|
-
pending "waiting for the fix for BUILDR-300"
|
54
|
-
foo = define('foo') do
|
55
|
-
Buildr::write "plugin.xml", ""
|
56
|
-
Buildr::write "src/main/java/Hello.java", "public class Hello{}"
|
57
|
-
end
|
58
|
-
foo.task("eclipse").invoke
|
59
|
-
(File.exists? ".project").should be_true
|
60
|
-
File.read(".project").should match(/org.eclipse.pde.PluginNature/)
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
data/spec/nature/scala_spec.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
-
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
-
# work for additional information regarding copyright ownership. The ASF
|
4
|
-
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
-
# "License"); you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations under
|
14
|
-
# the License.
|
15
|
-
|
16
|
-
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
17
|
-
|
18
|
-
describe 'Buildr::ScalaNature' do
|
19
|
-
|
20
|
-
it 'should be registered as :scala' do
|
21
|
-
Buildr::Nature::Registry.get(:scala).should_not nil
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should define some Eclipse options' do
|
25
|
-
scala = Buildr::Nature::Registry.get(:scala)
|
26
|
-
scala.eclipse.natures.should == ["ch.epfl.lamp.sdt.core.scalanature", "org.eclipse.jdt.core.javanature"]
|
27
|
-
scala.eclipse.builders.should include("ch.epfl.lamp.sdt.core.scalabuilder")
|
28
|
-
scala.eclipse.classpath_containers.should == ["ch.epfl.lamp.sdt.launching.SCALA_CONTAINER", "org.eclipse.jdt.launching.JRE_CONTAINER"]
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should apply when a scala source folder is present' do
|
32
|
-
foo = define('foo') {write('src/main/scala')}
|
33
|
-
scala = Buildr::Nature::Registry.get(:scala)
|
34
|
-
scala.applies(foo).should be_true
|
35
|
-
foo.applicable_natures.should include(scala)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should not apply when no scala source folder is present' do
|
39
|
-
bar = define('bar') {write('src/main/c++')}
|
40
|
-
scala = Buildr::Nature::Registry.get(:scala)
|
41
|
-
scala.applies(bar).should_not be_true
|
42
|
-
bar.applicable_natures.should_not include(scala)
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
data/spec/nature_spec.rb
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
-
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
-
# work for additional information regarding copyright ownership. The ASF
|
4
|
-
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
-
# "License"); you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations under
|
14
|
-
# the License.
|
15
|
-
|
16
|
-
require File.join(File.dirname(__FILE__), '/spec_helpers')
|
17
|
-
|
18
|
-
|
19
|
-
describe Buildr::Nature do
|
20
|
-
|
21
|
-
before :all do
|
22
|
-
class DummyNature < Buildr::DefaultNature
|
23
|
-
def initialize()
|
24
|
-
super(:dummy)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
@dummy = DummyNature.new
|
28
|
-
class OtherDummyNature < Buildr::DefaultNature
|
29
|
-
def initialize()
|
30
|
-
super(:otherdummy)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
@otherdummy = OtherDummyNature.new
|
34
|
-
class InvalidNature < Buildr::DefaultNature
|
35
|
-
def initialize()
|
36
|
-
super(:dummy)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
@invalid = InvalidNature.new
|
40
|
-
end
|
41
|
-
|
42
|
-
after :all do
|
43
|
-
#empty the registry.
|
44
|
-
module Buildr
|
45
|
-
module Nature
|
46
|
-
module Registry
|
47
|
-
@registered_natures = DEFAULT.dup
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should accept new natures' do
|
54
|
-
lambda { Buildr::Nature::Registry.add_nature(@dummy) }.should_not raise_error
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should accept new natures to be placed before registered ones' do
|
58
|
-
lambda { Buildr::Nature::Registry.add_nature(@otherdummy, :dummy) }.should_not raise_error
|
59
|
-
lambda {Buildr::Nature::Registry.all().index(@otherdummy) <
|
60
|
-
Buildr::Nature::Registry.all().index(@otherdummy)}.should be_true
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should not accept incorrect objects' do
|
64
|
-
lambda { Buildr::Nature::Registry.add_nature(define('uh')) }.should raise_error(RuntimeError, /uh is not a nature!/)
|
65
|
-
end
|
66
|
-
it 'should not accept duplicate natures' do
|
67
|
-
lambda { Buildr::Nature::Registry.add_nature(@invalid) }.should raise_error(RuntimeError, /A nature with the same id is already present/)
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'should list all available natures' do
|
71
|
-
# We also have the Java and Scala natures in there.
|
72
|
-
Buildr::Nature::Registry.all().should include(@dummy)
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'should make natures available' do
|
76
|
-
Buildr::Nature::Registry.get(:dummy).should eql(@dummy)
|
77
|
-
Buildr::Nature::Registry.get("dummy").should eql(@dummy)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe Buildr::DefaultNature do
|
82
|
-
|
83
|
-
before :all do
|
84
|
-
class DummyNature < Buildr::DefaultNature
|
85
|
-
def initialize()
|
86
|
-
super(:dummy)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
@dummy = DummyNature.new
|
90
|
-
Buildr::Nature::Registry.add_nature(@dummy)
|
91
|
-
end
|
92
|
-
|
93
|
-
after :all do
|
94
|
-
#empty the registry.
|
95
|
-
module Buildr
|
96
|
-
module Nature
|
97
|
-
module Registry
|
98
|
-
@registered_natures = DEFAULT.dup
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'should never apply by default' do
|
105
|
-
default = Buildr::DefaultNature.new(:somenature)
|
106
|
-
default.applies(define('foo')).should eql(false)
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'should determine project natures from the applies method' do
|
110
|
-
class DummyNatureAlwaysApply < Buildr::DefaultNature
|
111
|
-
def initialize()
|
112
|
-
super(:always)
|
113
|
-
end
|
114
|
-
def applies(project)
|
115
|
-
true # always applies
|
116
|
-
end
|
117
|
-
end
|
118
|
-
always = DummyNatureAlwaysApply.new
|
119
|
-
Buildr::Nature::Registry.add_nature(always)
|
120
|
-
foo = define('foo')
|
121
|
-
foo.applicable_natures.should include(always)
|
122
|
-
#By default applies return false.
|
123
|
-
foo.applicable_natures.should_not include(@dummy)
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'should let projects define their natures' do
|
127
|
-
foo = define('foo', :natures => :dummy)
|
128
|
-
foo.applicable_natures.should include(@dummy)
|
129
|
-
bar = define('bar', :natures => [:dummy])
|
130
|
-
bar.applicable_natures.should include(@dummy)
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'should use the parent natures if no nature is defined on this project' do
|
134
|
-
dummy = @dummy
|
135
|
-
foo = define('foo', :natures => :dummy) do
|
136
|
-
bar = define('bar')
|
137
|
-
bar.applicable_natures.should include(dummy)
|
138
|
-
end
|
139
|
-
foo = define('foo2', :natures => :dummy) do
|
140
|
-
bar = define('bar', :natures => [])
|
141
|
-
bar.applicable_natures.should_not include(dummy)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|