lib/buildr4osgi/osgi/registry.rb in buildr4osgi-0.9.2 vs lib/buildr4osgi/osgi/registry.rb in buildr4osgi-0.9.3
- old
+ new
@@ -11,10 +11,12 @@
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
+require File.join(File.dirname(__FILE__), 'execution_environment')
+
module OSGi
OSGI_GROUP_ID = "osgi"
class GroupMatcher
@@ -59,10 +61,14 @@
def containers
unless @containers
@containers = [Buildr.settings.user, Buildr.settings.build].inject([]) { |repos, hash|
repos | Array(hash['osgi'] && hash['osgi']['containers'])
}
+ if ENV['OSGI'] && !ENV['OSGi']
+ warn "The correct constant to define for the OSGi containers is named OSGi"
+ ENV['OSGi'] = ENV['OSGI']
+ end
if ENV['OSGi']
@containers |= ENV['OSGi'].split(';')
end
end
@resolved_containers.nil? ? @containers : @containers.dup.freeze
@@ -78,54 +84,42 @@
@resolved_containers ||= containers.collect { |container| Container.new(container) }
@resolved_containers
end
end
- class OSGi #:nodoc:
-
- attr_reader :options, :registry
-
- def initialize(project)
- if (project.parent)
- @options = project.parent.osgi.options.dup
- @registry = project.parent.osgi.registry.dup
- end
- @options ||= Options.new
- @registry ||= ::OSGi::Registry.new
- end
-
# The options for the osgi.options method
# package_resolving_strategy:
# The package resolving strategy, it should be a symbol representing a module function in the OSGi::PackageResolvingStrategies module.
# bundle_resolving_strategy:
# The bundle resolving strategy, it should be a symbol representing a module function in the OSGi::BundleResolvingStrategies module.
# group_matchers:
# A set of Proc objects to match a bundle to a groupId for maven.
# The array is examined with the latest added Procs first.
# The first proc to return a non-nil answer is used, otherwise the OGSGI_GROUP_ID constant is used.
- class Options
+ class Options < ::OSGi::ExecutionEnvironmentConfiguration
attr_accessor :package_resolving_strategy, :bundle_resolving_strategy
def initialize
+ super
@package_resolving_strategy = :all
@bundle_resolving_strategy = :latest
end
-
end
- end
-
- module OSGiOptions
- include Extension
- # Makes a osgi instance available to the project.
- # The osgi object may be used to access OSGi containers
- # or set options, currently the resolving strategies.
- def osgi
- @osgi ||= OSGi.new(self)
- @osgi
+ # Calls to this method return true if the package name passed as argument
+ # is either part of the packages of the framework given by the execution environment
+ # or part of the extra packages specified by the user.
+ #
+ def is_framework_package?(name)
+ options.current_execution_environment.packages.include?(name) || options.extra_packages.include?(name)
end
+
+
+ def options
+ @options ||= Options.new
end
-end
-
-class Buildr::Project
- include OSGi::OSGiOptions
+
+ def registry
+ @registry ||= ::OSGi::Registry.new
+ end
+
end
\ No newline at end of file