Hi Jean-Philippe,
On May 7, 2010, at 7:01 AM, Jean-Philippe Caruana wrote:
> Hi,
>
> I would like to use transitive dependancies in buildr but only for my
> projects and not for external libs, so compile.with
> transitive('org.apache.wicket:wicket:jar:1.4-rc6') is not what i'm looking
> for (1.4-rc6, what a cool version name !)
>
> If I have to projects A & B with B depending from A. B is a war, so I need to
> have all dependancies needed by A, otherwise I'll have a NoClassDefFoundError
> in runtime
>
> define 'myProject' do
> define 'A' do
> compile.with DEP_A_1, DEP_A_2, DEP_A_3
> package :jar
> end
>
> define 'B' do
> compile.with project('A'), DEP_A_1, DEP_A_2, DEP_A_3
> compile.with DEP_B_1, DEP_B_2
> package :war
> end
> end
>
> I know I can write
> compile.with project('A'), project('A').compile.dependancies
> but I find it quite verbose and not very convinient when there are not 1 but
> 7 projects or more. I have 60 modules in my project and there are a lot of
> duplications.
>
> I would like to write it that way :
>
> define 'myProject' do
> define 'A' do
> compile.with DEP_A_1, DEP_A_2, DEP_A_3
> package :jar
> end
>
> define 'B' do
> compile.with transitive(project('A'))
> compile.with DEP_B_1, DEP_B_2
> package :war
> end
> end
>
> and even better "compile.with transitive(projects('A', 'other'))"
>
>
> this didn't work (under buildr 1.3.5)
>
> Buildr aborted!
> undefined method `invoke' for nil:NilClass
> /mypath/buildfile:188
> /var/lib/gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:400:in
> `raw_load_buildfile'
> /var/lib/gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:218:in
> `load_buildfile'
> /var/lib/gems/1.8/gems/buildr-1.3.5/lib/buildr/core/application.rb:213:in
> `load_buildfile'
>
>
> despite inside artifact/package.rb there is a "when Project" in the
> transitive method
>
> def transitive(*specs)
> specs.flatten.inject([]) do |set, spec|
> case spec
> when /([^:]+:){2,4}/ # A spec as opposed to a file name.
> artifact = artifact(spec)
> set |= [artifact] unless artifact.type == :pom
> set |= POM.load(artifact.pom).dependencies.map { |spec| artifact(spec)
> }
> when Hash
> set |= [transitive(spec)]
> when String # Must always expand path.
> set |= transitive(file(File.expand_path(spec)))
> when Project
> set |= transitive(spec.packages)
> when Rake::Task
> set |= spec.respond_to?(:to_spec) ? transitive(spec.to_spec) : [spec]
> when Struct
> set |= transitive(spec.values)
> else
> fail "Invalid artifact specification in: #{specs.to_s}"
> end
> end
> end
>
>
> I know I could write some my_transitive method, but I would imagine this
> could be done in buildr right away. Is there any way to do this ?
I don't know if there's a way to do it in buildr alone, but here's my version
of "my_transitive":
# Adds some methods for cleaner dependency on another project and its deps
class Buildr::Project
def and_dependencies
[self, self.compile.dependencies].compact
end
def test_dependencies
[self.test.compile.target, self.test.resources.target,
self.test.compile.dependencies].compact
end
end
Use it like this:
define 'myProject' do
define 'A' do
compile.with DEP_A_1, DEP_A_2, DEP_A_3
package :jar
end
define 'B' do
compile.with project('A').and_dependencies, DEP_B_1, DEP_B_2
package :war
end
end
Rhett
>
> Thanks
>
> -- Jean-Philippe Caruana
> ********************************
> Ce message et toutes les pieces jointes (ci-apres le "message") sont
> confidentiels et etablis a l'attention exclusive de ses destinataires.
> Toute utilisation ou diffusion non autorisee est interdite.
> Tout message electronique est susceptible d'alteration. Multimedia Business
> Services decline
> toute responsabilite au titre de ce message s'il a ete altere, deforme
> ou falsifie.
> Si vous n'etes pas destinataire de ce message, merci de le detruire
> immediatement et d'avertir l'expediteur.
> *********************************
> This message and any attachments (the "message") are confidential and
> intended solely for the addressees. Any unauthorised use or
> dissemination is prohibited.
> Messages are susceptible to alteration. Multimedia Business Services shall
> not be liable for the
> message if altered, changed or falsified.
> If you are not the intended addressee of this message, please cancel it
> immediately and inform the sender..
> ********************************