On 2019/03/24 21:01:43, Jochen Theodorou <blackd...@gmx.org> wrote:
> On 24.03.19 15:32, anton.pryamosta...@gmail.com wrote:
> > Dear Groovy Dev Mailing List,
> >
> > When I follow Gradle recommendations in terms of dependency scopes of my
> > Groovy Library, in the end it produces errors when loaded via Grapes from
> > Groovy Console/Groovy Shell:
> >
> > groovy.lang.GroovyRuntimeException: Conflicting module versions. Module
> > [groovy-xml is loaded in version 2.5.6 and you are trying to load version
> > 2.5.4
> >
> > The build.gradle contains nothing more than the below in terms of
> > dependencies:
> >
> > ..
> > dependencies {
> > compile 'org.codehaus.groovy:groovy-all:2.5.4'
> > ..
> > }
> > ..
> >
> > Question: the Gradle documentation has to be fixed, or there is bug in
> > Grapes?
> >
> > Gradle documentation in question:
> > https://guides.gradle.org/building-groovy-libraries/?_ga=2.99509400.76686785.1553433006-920887584.1535023978
>
> setting a compile dependency should not be done with Grapes. And afaik
> it is not done like that in Gradle. You have a class loader that tries
> to init the Groovy system for 2.5.4, while version 2.5.6 modules are
> visible and chosen by the class loading. In a "normal" Gradle setup this
> is not the case. I have used this in dozens of projects and it was never
> a problem because Gradle internally prevents this from happening.
>
> So first of all... What gradle version and is 2.5.6 the groovy version
> in that gradle? If not where does it come from? If you do not even have
> a Groovy on your classpath and your build file contains only that
> dependencies declaration (plus a bit), then this sounds like a bug in
> gradle. But maybe, if you explain a bit more, we can find out if that is
> really the case or not
>
> bye Jochen
>
> bye Jochen
>
>
Hi Jochen!
First of all it is a pleasure to talk with Groovy Core Team, and thanks for
this opportunity to directly interact with you.
Coming to the questions: the Gradle build passes OK.
Gradle version is 5.2.1 and it only has "groovy-all" module with scope
"compile" and version "2.5.4".
It produces JAR which is usable in other Gradle builds as Compile dependency
with no issues - you are right.
However - when I try to load this module in Grapes via Groovy Console or Groovy
shell (with different Groovy version e.g. 2.5.6 - I get the above error.
Here is the sample problematic script:
--
@Grab('io.infinite:supplies:1.1.1')
def i
--
- just try to run it in your Groovy console - you will see the error:
groovy.lang.GroovyRuntimeException: Conflicting module versions. Module
[groovy-xml is loaded in version 2.5.6 and you are trying to load version 2.5.4
Since you mentioned that Gradle resolves this situation automatically - how
difficult is to implement such mechanism in Grapes?
PS: I am not even sure if this mechanism is good or not. As said by Daniel Sun
in Groovy Slack - it is not recommended combination of modules used for
compilation and runtime, which can cause instability. And I agree with him.
However compatibility-wise - it is very important feature in Gradle for Groovy.
Bye (Anton)