Search code examples
groovyimportproject

How to import from one level above the current package in groovy


My project structure is as follows:

groovy / action / TestDataHelper
groovy / SharedState

I'm trying to import my SharedState script from my TestDataHelper.

If I use

package action

in TestDataHelper, that class itself is happy, but can't see SharedState. If I don't use a package, the class itself is unhappy, but can see SharedState

I haven't been able to find an answer on google yet. How do I handle this in groovy?


Solution

  • Nevermind :-)

    I found out that I can't import from the main package, in my case groovy. To solve it, I put the SharedState into a package - and then imported that package from TestDataHelper.

    I do find it weird though, that that should be necessary.