Module: Buildr::Packaging::Java
Overview
Adds packaging for Java projects: JAR, WAR, AAR, EAR, Javadoc.
Defined Under Namespace
Modules: WithManifest Classes: JarTask, Manifest, WarTask
Instance Attribute Summary collapse
-
#manifest ⇒ Object
Manifest used for packaging.
-
#meta_inf ⇒ Object
Files to always include in the package META-INF directory.
Instance Method Summary collapse
-
#package_as_jar(file_name) ⇒ Object
:nodoc:.
-
#package_as_javadoc(file_name) ⇒ Object
:nodoc:.
-
#package_as_javadoc_spec(spec) ⇒ Object
:nodoc:.
-
#package_as_war(file_name) ⇒ Object
:nodoc:.
-
#package_with_javadoc(options = nil) ⇒ Object
:call-seq: package_with_javadoc(options?).
-
#package_with_sources(options = nil) ⇒ Object
:call-seq: package_with_sources(options?).
Methods included from Extension
Instance Attribute Details
#manifest ⇒ Object
Manifest used for packaging. Inherited from parent project. The default value is a hash that includes the Build-By, Build-Jdk, Implementation-Title and Implementation-Version values. The later are taken from the project’s comment (or name) and version number.
296 297 298 |
# File 'lib/buildr/java/packaging.rb', line 296 def manifest @manifest end |
#meta_inf ⇒ Object
Files to always include in the package META-INF directory. The default value include the LICENSE file if one exists in the project’s base directory.
300 301 302 |
# File 'lib/buildr/java/packaging.rb', line 300 def end |
Instance Method Details
#package_as_jar(file_name) ⇒ Object
:nodoc:
358 359 360 361 362 363 |
# File 'lib/buildr/java/packaging.rb', line 358 def package_as_jar(file_name) #:nodoc: Java::JarTask.define_task(file_name).tap do |jar| jar.with :manifest=>manifest, :meta_inf=> jar.with [compile.target, resources.target].compact end end |
#package_as_javadoc(file_name) ⇒ Object
:nodoc:
382 383 384 385 386 |
# File 'lib/buildr/java/packaging.rb', line 382 def package_as_javadoc(file_name) #:nodoc: ZipTask.define_task(file_name).tap do |zip| zip.include :from=>doc.target end end |
#package_as_javadoc_spec(spec) ⇒ Object
:nodoc:
378 379 380 |
# File 'lib/buildr/java/packaging.rb', line 378 def package_as_javadoc_spec(spec) #:nodoc: spec.merge(:type=>:jar, :classifier=>'javadoc') end |
#package_as_war(file_name) ⇒ Object
:nodoc:
365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/buildr/java/packaging.rb', line 365 def package_as_war(file_name) #:nodoc: Java::WarTask.define_task(file_name).tap do |war| war.with :manifest=>manifest, :meta_inf=> # Add libraries in WEB-INF lib, and classes in WEB-INF classes war.with :classes=>[compile.target, resources.target].compact war.with :libs=>compile.dependencies webapp = path_to(:source, :main, :webapp) war.with webapp if File.exist?(webapp) war.enhance([assets]) war.include assets.to_s, :as => '.' unless assets.paths.empty? end end |
#package_with_javadoc(options = nil) ⇒ Object
:call-seq:
package_with_javadoc()
Call this when you want the project (and all its sub-projects) to create a JavaDoc distribution. You can use the JavaDoc distribution in an IDE when coding against the API.
A JavaDoc distribution is a ZIP package with the classifier ‘javadoc’, which includes all the sources used by the compile task.
Packages use the project’s manifest and meta_inf properties, which you can override by passing different values (e.g. false to exclude the manifest) in the options.
To create JavaDoc distributions only for specific projects, use the :only and :except options, for example:
package_with_javadoc :only=>['foo:bar', 'foo:baz']
(Same as calling package :doc on each project/sub-project that has source directories.)
347 348 349 350 351 352 353 354 355 356 |
# File 'lib/buildr/java/packaging.rb', line 347 def package_with_javadoc( = nil) ||= {} enhance do selected = [:only] ? projects([:only]) : [:except] ? ([self] + projects - projects([:except])) : [self] + projects selected.reject { |project| project.compile.sources.empty? }. each { |project| project.package(:javadoc) } end end |
#package_with_sources(options = nil) ⇒ Object
:call-seq:
package_with_sources()
Call this when you want the project (and all its sub-projects) to create a source distribution. You can use the source distribution in an IDE when debugging.
A source distribution is a jar package with the classifier ‘sources’, which includes all the sources used by the compile task.
Packages use the project’s manifest and meta_inf properties, which you can override by passing different values (e.g. false to exclude the manifest) in the options.
To create source distributions only for specific projects, use the :only and :except options, for example:
package_with_sources :only=>['foo:bar', 'foo:baz']
(Same as calling package :sources on each project/sub-project that has source directories.)
319 320 321 322 323 324 325 326 327 328 |
# File 'lib/buildr/java/packaging.rb', line 319 def package_with_sources( = nil) ||= {} enhance do selected = [:only] ? projects([:only]) : [:except] ? ([self] + projects - projects([:except])) : [self] + projects selected.reject { |project| project.compile.sources.empty? && project.resources.target.nil? }. each { |project| project.package(:sources) } end end |