Module | Buildr::Package |
In: |
lib/buildr/packaging/package.rb
(CVS)
|
package_as_tar | -> | package_as_tgz |
group | [RW] | Group used for packaging. Inherited from parent project. Defaults to the top-level project name. |
version | [RW] | Version used for packaging. Inherited from parent project. |
The project‘s identifier. Same as the project name, with colons replaced by dashes. The ID for project foo:bar is foo-bar.
Defines and returns a package created by this project.
The first argument declares the package type. For example, :jar to create a JAR file. The package is an artifact that takes its artifact specification from the project. You can override the artifact specification by passing various options in the second argument, for example:
package(:zip, :classifier=>'sources')
Packages that are ZIP files provides various ways to include additional files, directories, and even merge ZIPs together. Have a look at ZipTask for more information. In case you‘re wondering, JAR and WAR packages are ZIP files.
You can also enhance a JAR package using the ZipTask#with method that accepts the following options:
The WAR package supports the same options and adds a few more:
For example:
define 'project' do define 'beans' do package :jar end define 'webapp' do compile.with project('beans') package(:war).with :libs=>MYSQL_JDBC end package(:zip, :classifier=>'sources').include path_to('.') end
Two other packaging types are:
A package is also an artifact. The following tasks operate on packages created by the project:
buildr upload # Upload packages created by the project buildr install # Install packages created by the project buildr package # Create packages buildr uninstall # Remove previously installed packages
If you want to add additional packaging types, implement a method with the name package_as_[type] that accepts a file name and returns an appropriate Rake task. For example:
def package_as_zip(file_name) #:nodoc: ZipTask.define_task(file_name) end
The file name is determined from the specification passed to the package method, however, some packagers need to override this. For example, package(:sources) produces a file with the extension ‘jar’ and the classifier ‘sources’. If you need to overwrite the default implementation, you should also include a method named package_as_[type]_spec. For example:
def package_as_sources_spec(spec) #:nodoc: # Change the source distribution to .zip extension spec.merge({ :type=>:zip, :classifier=>'sources' }) end
Returns all packages created by this project. A project may create any number of packages.
This method is used whenever you pass a project to Buildr#artifact or any other method that accepts artifact specifications and projects. You can use it to list all packages created by the project. If you want to return a specific package, it is often more convenient to call package with the type.