Reputation: 2325
I have two files:
Constants.groovy
:
class Constants
{
static String foo = "bar";
}
utils.groovy
:
import Constants
void func()
{
assert Constants.foo == "bar"
}
From within utils.groovy
, I would like to import the Constants
class. Here is the directory structure that the files reside within:
.
└── vars
├── Constants.groovy
└── utils.groovy
This current setup does not work, and results in the following exception:
No such property: Constants for class: utils
Upvotes: 0
Views: 583
Reputation: 2325
The solution is to append .*
to the import:
import Constants.*
void func()
{
assert Constants.foo == "bar"
}
I feel a bit silly, but the solution is simple!
Upvotes: 1