Module: Buildr::Compile

Includes:
Extension
Included in:
Project
Defined in:
lib/buildr/core/compile.rb

Overview

Methods added to Project for compiling, handling of resources and generating source documentation.

Instance Method Summary collapse

Methods included from Extension

included

Instance Method Details

#compile(*sources, &block) ⇒ Object

:call-seq:

compile(*sources) => CompileTask
compile(*sources) { |task| .. } => CompileTask

The compile task does what its name suggests. This method returns the project’s CompileTask. It also accepts a list of source directories and files to compile (equivalent to calling CompileTask#from on the task), and a block for any post-compilation work.

The compile task attempts to guess which compiler to use. For example, if it finds any Java files in the src/main/java directory, it will use the Java compiler and create class files in the target/classes directory.

You can also configure it yourself by telling it which compiler to use, pointing it as source directories and chooing a different target directory.

For example:

# Include Log4J and the api sub-project artifacts.
compile.with 'log4j:log4j:jar:1.2', project('api')
# Include Apt-generated source files.
compile.from apt
# For JavaC, force target compatibility.
compile.options.source = '1.6'
# Run the OpenJPA bytecode enhancer after compilation.
compile { open_jpa_enhance }
# Pick a given compiler.
compile.using(:scalac).from('src/scala')

For more information, see CompileTask.



550
551
552
# File 'lib/buildr/core/compile.rb', line 550

def compile(*sources, &block)
  task('compile').from(sources).enhance &block
end

#resources(*prereqs, &block) ⇒ Object

:call-seq:

resources(*prereqs) => ResourcesTask
resources(*prereqs) { |task| .. } => ResourcesTask

The resources task is executed by the compile task to copy resources files from the resource directory into the target directory. By default the resources task copies files from the src/main/resources into the target/resources directory.

This method returns the project’s resources task. It also accepts a list of prerequisites and a block, used to enhance the resources task.

Resources files are copied and filtered (see Buildr::Filter for more information). The default filter uses the profile properties for the current environment.

For example:

resources.from _('src/etc')
resources.filter.using 'Copyright'=>'Acme Inc, 2007'

Or in your profiles.yaml file:

common:
  Copyright: Acme Inc, 2007


575
576
577
# File 'lib/buildr/core/compile.rb', line 575

def resources(*prereqs, &block)
  task('resources').enhance prereqs, &block
end