groovy

Changes to @Grab parameters not detected in Groovy Console

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.6.5
  • Fix Version/s: 1.6.6, 1.7-rc-1
  • Component/s: Grape
  • Labels:
    None
  • Environment:
    Mac OS 10.6.1
    Java 1.6.0_15
  • Testcase included:
    yes
  • Number of attachments :
    0

Description

Try this in Groovy Console:

@Grab(group="junit", module="junit", version="8.5") // version doesn't exist, so error is ok
class Foo {}

1 compilation error:

Exception thrown: Error grabbing Grapes -- [unresolved dependency: junit#junit;8.5: not found]

java.lang.RuntimeException: Error grabbing Grapes -- [unresolved dependency: junit#junit;8.5: not found]
@Grab(group="junit", module="junit", version="4.7") // we fixed the version, but Grapes still looks for 8.5!
class Foo {}

1 compilation error:

Exception thrown: Error grabbing Grapes -- [unresolved dependency: junit#junit;8.5: not found]

java.lang.RuntimeException: Error grabbing Grapes -- [unresolved dependency: junit#junit;8.5: not found]

Activity

Hide
Roshan Dawrani added a comment -

Just want to add that outside the groovyconsole, the issue can also be reproduced using the following script:

def classLoader = new GroovyClassLoader()

try{
    classLoader.parseClass """
        @Grab(group="junit", module="junit", version="8.5")
        class Foo {}
    """
    println "First grab successful"
}catch(ex) {
    // first call correctly fails as it has the version wrong
    println "First grab failed"
    println ex
}

try{
    classLoader.parseClass """
        @Grab(group="junit", module="junit", version="4.7")
        class Foo {}
    """

    println "Second grab successful"
}catch(ex) {
    /* this should not have failed as it has the correct version number but still fails 
       because GraveIvy.groovy maintains some state from the previous grab call, which it should not. */
    println "Second grab failed" 
    println ex
}
Show
Roshan Dawrani added a comment - Just want to add that outside the groovyconsole, the issue can also be reproduced using the following script:
def classLoader = new GroovyClassLoader()

try{
    classLoader.parseClass """
        @Grab(group="junit", module="junit", version="8.5")
        class Foo {}
    """
    println "First grab successful"
}catch(ex) {
    // first call correctly fails as it has the version wrong
    println "First grab failed"
    println ex
}

try{
    classLoader.parseClass """
        @Grab(group="junit", module="junit", version="4.7")
        class Foo {}
    """

    println "Second grab successful"
}catch(ex) {
    /* this should not have failed as it has the correct version number but still fails 
       because GraveIvy.groovy maintains some state from the previous grab call, which it should not. */
    println "Second grab failed" 
    println ex
}
Hide
Roshan Dawrani added a comment -

Fixed.

Show
Roshan Dawrani added a comment - Fixed.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: