Module: Buildr::Packaging::Java
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
-
#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_aar(file_name) ⇒ Object
:nodoc:.
-
#package_as_ear(file_name) ⇒ Object
:nodoc:.
-
#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.
610 611 612 |
# File 'lib/buildr/java/packaging.rb', line 610 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.
614 615 616 |
# File 'lib/buildr/java/packaging.rb', line 614 def end |
Instance Method Details
#package_as_aar(file_name) ⇒ Object
:nodoc:
692 693 694 695 696 697 698 699 700 |
# File 'lib/buildr/java/packaging.rb', line 692 def package_as_aar(file_name) #:nodoc: Java::AarTask.define_task(file_name).tap do |aar| aar.with :manifest=>manifest, :meta_inf=> aar.with :wsdls=>path_to(:source, :main, :axis2, '*.wsdl') aar.with :services_xml=>path_to(:source, :main, :axis2, 'services.xml') aar.with [compile.target, resources.target].compact aar.with :libs=>compile.dependencies end end |
#package_as_ear(file_name) ⇒ Object
:nodoc:
702 703 704 705 706 707 |
# File 'lib/buildr/java/packaging.rb', line 702 def package_as_ear(file_name) #:nodoc: Java::EarTask.define_task(file_name).tap do |ear| ear.send :associate, self ear.with :display_name=>id, :manifest=>manifest, :meta_inf=> end end |
#package_as_jar(file_name) ⇒ Object
:nodoc:
672 673 674 675 676 677 |
# File 'lib/buildr/java/packaging.rb', line 672 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:
713 714 715 716 717 |
# File 'lib/buildr/java/packaging.rb', line 713 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:
709 710 711 |
# File 'lib/buildr/java/packaging.rb', line 709 def package_as_javadoc_spec(spec) #:nodoc: spec.merge(:type=>:jar, :classifier=>'javadoc') end |
#package_as_war(file_name) ⇒ Object
:nodoc:
679 680 681 682 683 684 685 686 687 688 689 690 |
# File 'lib/buildr/java/packaging.rb', line 679 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 :javadoc on each project/sub-project that has source directories.)
661 662 663 664 665 666 667 668 669 670 |
# File 'lib/buildr/java/packaging.rb', line 661 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.)
633 634 635 636 637 638 639 640 641 642 |
# File 'lib/buildr/java/packaging.rb', line 633 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 |