You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Dieter Vrancken <di...@luciad.com> on 2015/01/16 14:13:43 UTC
dependencies for Buildr modules
Hi list,
I was wondering about how to specify dependencies in Buildr modules.
If we look at e.g. the Checkstyle module (addon/buildr/checkstyle.rb),
it lists a bunch of artifacts at the top which are needed for the
module's operation:
# The specs for requirements
def dependencies
[
'com.puppycrawl.tools:checkstyle:jar:6.0',
'antlr:antlr:jar:2.7.7',
'org.antlr:antlr4-runtime:jar:4.3',
'com.google.guava:guava:jar:18.0',
'commons-cli:commons-cli:jar:1.2',
'commons-beanutils:commons-beanutils-core:jar:1.8.3',
'commons-logging:commons-logging:jar:1.1.1'
]
end
The same pattern is replicated in a other modules as well. It seems
rather cumbersome to have to hunt down all the appropriate dependencies
and their specific version numbers. Also, in the example above, it is
not really possible to make the checkstyle version a build parameter
because its dependencies might change across versions.
Listing the dependency transitively would solve both my concerns, so I
tried doing the following and it seems to work just fine:
def dependencies
Buildr::transitive 'com.puppycrawl.tools:checkstyle:jar:6.2'
end
Is there are a reason this is not done?
One possible reason I can think of is that the transitive method is not
actually documented, but seeing it recommended on this list recently, it
sounds safe enough to start using...
Thanks,
Dieter
Re: dependencies for Buildr modules
Posted by Dieter Vrancken <Di...@luciad.com>.
Hi,
----- Peter Donald <pe...@realityforge.org> wrote:
>
> On Sat, Jan 17, 2015 at 12:13 AM, Dieter Vrancken <
> dieter.vrancken@luciad.com> wrote:
>
> > Listing the dependency transitively would solve both my concerns, so I
> > tried doing the following and it seems to work just fine:
> >
> > def dependencies
> > Buildr::transitive 'com.puppycrawl.tools:checkstyle:jar:6.2'
> > end
> >
> > Is there are a reason this is not done?
> >
>
> The main reason is that it is not stable and repeatable. Depending on how
> the pom's are authored, that could result in different set's of
> dependencies being included. i.e. If the Pom for
> com.puppycrawl.tools:checkstyle:jar:6.2 lists version ranges, and a new
> version of a dependency is released that fit's in the dependency range,
> then the set of dependencies will change.
>
> This means coming back to a project 2 years after it was last touched can
> actually result in the project not working or not compiling. Rather than
> have that, listing out all the dependencies means it will still work into
> the future.
Your reasoning makes perfect sense. We have a more controlled repo at work,
but not for these kinds of dependencies. Something to think about.
> FWIW I often do something like
>
> puts
> transitive('com.puppycrawl.tools:checkstyle:jar:6.2').collect{|d|d.to_spec}.inspect
>
> To collect the set of dependencies needed.
Very useful advice! I keep forgetting that we can just do these sort of
things programmatically...
Thanks,
Dieter
Re: dependencies for Buildr modules
Posted by Peter Donald <pe...@realityforge.org>.
Hi,
On Sat, Jan 17, 2015 at 12:13 AM, Dieter Vrancken <
dieter.vrancken@luciad.com> wrote:
> The same pattern is replicated in a other modules as well. It seems
> rather cumbersome to have to hunt down all the appropriate dependencies
> and their specific version numbers. Also, in the example above, it is
> not really possible to make the checkstyle version a build parameter
> because its dependencies might change across versions.
>
It is somewhat problematic. There are some modules that do support changing
the version but they tend to hard code the versions of the dependencies for
each version of the module.
> Listing the dependency transitively would solve both my concerns, so I
> tried doing the following and it seems to work just fine:
>
> def dependencies
> Buildr::transitive 'com.puppycrawl.tools:checkstyle:jar:6.2'
> end
>
> Is there are a reason this is not done?
>
The main reason is that it is not stable and repeatable. Depending on how
the pom's are authored, that could result in different set's of
dependencies being included. i.e. If the Pom for
com.puppycrawl.tools:checkstyle:jar:6.2 lists version ranges, and a new
version of a dependency is released that fit's in the dependency range,
then the set of dependencies will change.
This means coming back to a project 2 years after it was last touched can
actually result in the project not working or not compiling. Rather than
have that, listing out all the dependencies means it will still work into
the future.
FWIW I often do something like
puts
transitive('com.puppycrawl.tools:checkstyle:jar:6.2').collect{|d|d.to_spec}.inspect
To collect the set of dependencies needed.
--
Cheers,
Peter Donald