Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Home

mguymon edited this page · 11 revisions
Clone this wiki locally

Examples

Resolve Dependencies

require 'buildr/resolver'
Java.load # must be called before Buildr::Resolver.resolve if not using JRuby due to Rjb startup of JVM by Buildr
deps = ['org.apache.activemq:activemq-spring:jar:5.4.2']
deps =  Buildr::Resolver.resolve( deps )
define 'example' do
    project.version = '0.1.0'
    compile.with deps
    package :jar
end

Resolve Dependencies from a POM

require 'buildr/resolver'
Java.load # must be called before Buildr::Resolver.resolve if not using JRuby due to Rjb startup of JVM by Buildr
task :compile => :resolve_deps
task :resolve_deps do |t|
    DEP_EXCLUDES = ['commons-logging', 'log4j', 'logkit']
    resolved_deps = Buildr::Resolver.resolve( {_('pom.xml') => ['compile']}, :download => true, :excludes => DEP_EXCLUDES )
    compile.with( resolved_deps )
end

Repository Auth

Access a remote repository that requires auth using the :repo option:

require 'buildr/resolver'
Java.load # must be called before Buildr::Resolver.resolve if not using JRuby due to Rjb startup of JVM by Buildr
repositories.remote << { :url => 'http://somewhere.repo/m2', :username => 'username', :password => 'password' }
deps = ['org.apache.activemq:activemq-spring:jar:5.4.2']
deps =  Buildr::Resolver.resolve( deps)
define 'example' do
    project.version = '0.1.0'
    compile.with deps
    package :jar
end

Excludes

Exclude commons-logging from the dependencies used in the project using the :excludes option:

require 'buildr/resolver'
Java.load # must be called before Buildr::Resolver.resolve if not using JRuby due to Rjb startup of JVM by Buildr
deps = ['org.apache.activemq:activemq-spring:jar:5.4.2']
deps =  Buildr::Resolver.resolve( deps, :excludes => ['commons-logging'] )
define 'example' do
    project.version = '0.1.0'
    compile.with deps
    package :jar
end

Write a POM

Example task to write a POM based on the project. All dependencies loaded by Buildr::Resolver.resolve are included.

task :pom do |t|
  Buildr::Resolver.write_pom( "com.slackworks:buildr-resolver:jar:0.1, 'pom.xml' )
end
Something went wrong with that request. Please try again.