Class: OSGi::BundleTask
- Inherits:
-
Buildr::Packaging::Java::JarTask
- Object
- Buildr::Packaging::Java::JarTask
- OSGi::BundleTask
- Includes:
- BundlePackaging
- Defined in:
- lib/buildr4osgi/osgi/packaging.rb
Overview
The task to package a project as a OSGi bundle.
Instance Attribute Summary collapse
-
#libs ⇒ Object
Artifacts to include under /lib.
Instance Method Summary collapse
-
#initialize(*args) ⇒ BundleTask
constructor
:nodoc:.
- #process_qualifier ⇒ Object
-
#use_bundle_version ⇒ Object
Calls to this method will make the bundle use the bundle manifest version if defined.
Constructor Details
#initialize(*args) ⇒ BundleTask
:nodoc:
123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/buildr4osgi/osgi/packaging.rb', line 123 def initialize(*args) #:nodoc: super @libs = [] prepare do unless @libs.nil? || @libs.empty? artifacts = Buildr.artifacts(@libs) path('lib').include artifacts manifest["Bundle-ClassPath"] = [".", artifacts.collect {|a| "lib/#{File.basename(a.to_s)}"}].flatten.join(",") end end end |
Instance Attribute Details
#libs ⇒ Object
Artifacts to include under /lib.
104 105 106 |
# File 'lib/buildr4osgi/osgi/packaging.rb', line 104 def libs @libs end |
Instance Method Details
#process_qualifier ⇒ Object
136 137 138 139 140 |
# File 'lib/buildr4osgi/osgi/packaging.rb', line 136 def process_qualifier if manifest["Bundle-Version"].match /\.qualifier$/ manifest["Bundle-Version"] = "#{$~.pre_match}.#{Time.now.strftime("%y%m%d%H%M%S")}" end end |
#use_bundle_version ⇒ Object
Calls to this method will make the bundle use the bundle manifest version if defined. An exception will be raised if no manifest file is present or no Bundle-Version is present in it.
111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/buildr4osgi/osgi/packaging.rb', line 111 def use_bundle_version manifest_location = File.join(@project.base_dir, "META-INF", "MANIFEST.MF") if File.exists?(manifest_location) read_m = ::Buildr::Packaging::Java::Manifest.parse(File.read(manifest_location)).main raise "Cannot use use_bundle_version if no Bundle-Version header is specified in the manifest" if read_m["Bundle-Version"].nil? manifest["Bundle-Version"] = read_m["Bundle-Version"] else raise "Cannot use use_bundle_version if no manifest is present in the project" end process_qualifier end |