Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7097

ScriptBase class can't be resolved if not in current directory even if CompilerConf classpath is set

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.5, 2.3.6, 2.3.7
    • Fix Version/s: 2.4.4
    • Component/s: Compiler
    • Labels:
      None
    • Environment:
      Windows 7 64 bit, Groovy 2.3.6

      Description

      I have following sample DSLScriptBase,groovy file:

      abstract class DSLScriptBase extends Script {
        def login() {
          println 'login'
        }
      }
      

      and following script test.groovy:

      def conf =  new org.codehaus.groovy.control.CompilerConfiguration()
      conf.setScriptBaseClass('DSLScriptBase')
      def shell = new GroovyShell (conf)
      shell.evaluate('login()')
      

      It works if DSLScriptBase.groovy is in the same directory as test.groovy.

      But if I move DSLScriptBase.groovy to another directory (for example D:/Test) and modify test.groovy adding setClasspath:

       def conf =  new org.codehaus.groovy.control.CompilerConfiguration()
       def scriptDir = 'd:/Temp'
       conf.setClasspath(scriptDir)
       conf.setScriptBaseClass('DSLScriptBase')
       def shell = new GroovyShell(conf)
       shell.evaluate('login()')
      

      I've got error: 'unable to resolve class DSLScriptBase'

      It works fine in Grovy 2.1.9, but in 2.3.6 I can't figure any way to define script base classes on comp conf classpath (tried to create shell with ClassLoader, moving scriptbase into some package-subdir, precompile scriptbase - nothing works for me).
      Please help

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pascalschumacher Pascal Schumacher
                Reporter:
                barteczko Christopher Barteczko
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: