Have you declared the package in the file where your discriminant is? Kotlin packages are not inferred from the package structure (although they typically match).
Basically, you need to put the class tree you want to access to your class path and remember that in java and kotlin package equals directory. If you want to access lesson.task.discriminant function, then you you must have a directory or jar on your classpath that has directory lesson/task inside it and some compiled kotlin class with top level function inside this directory.
Probably you want not to link the package, but to compile two classes together, remembering that package == path.
Anyway, I believe that build tools are one of the best things in java ecosystem, so instead of reinventing the wheel, you should look into that.