Module: Buildr::Packaging::Java

Includes:
Extension
Included in:
Buildr::Project
Defined in:
lib/buildr/java/packaging.rb

Overview

Adds packaging for Java projects: JAR, WAR, AAR, EAR, Javadoc.

Defined Under Namespace

Modules: WithManifest Classes: AarTask, EarTask, JarTask, Manifest, WarTask

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Extension

included

Instance Attribute Details

#manifestObject

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.



616
617
618
# File 'lib/buildr/java/packaging.rb', line 616

def manifest
  @manifest
end

#meta_infObject

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.



620
621
622
# File 'lib/buildr/java/packaging.rb', line 620

def meta_inf
  @meta_inf
end

Instance Method Details

#package_with_javadoc(options = nil) ⇒ Object

:call-seq:

package_with_javadoc(options?)

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 :javadoc on each project/sub-project that has source directories.)



667
668
669
670
671
672
673
674
675
676
# File 'lib/buildr/java/packaging.rb', line 667

def package_with_javadoc(options = nil)
  options ||= {}
  enhance do
    selected = options[:only] ? projects(options[:only]) :
      options[:except] ? ([self] + projects - projects(options[: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(options?)

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.)



639
640
641
642
643
644
645
646
647
648
# File 'lib/buildr/java/packaging.rb', line 639

def package_with_sources(options = nil)
  options ||= {}
  enhance do
    selected = options[:only] ? projects(options[:only]) :
      options[:except] ? ([self] + projects - projects(options[:except])) :
      [self] + projects
    selected.reject { |project| project.compile.sources.empty? && project.resources.target.nil? }.
      each { |project| project.package(:sources) }
  end
end