Using class from applied .gradle file in build.gradle

Hello,
I have following:
gradle/my.gradle:
class MyClass {..}
build.gradle:
apply from: "$rootDir/gradle/my.gradle" smth = new MyClass(..)

unable to resolve class MyClass

Any way to “import” MyClass in build.gradle to make it work?

Classes from a script plugin cannot be referenced currently. If you want to write classes that all your build scripts can see, please use the buildSrc project.

That’s sad. I want this my.gradle to be used in other projects and it is actually fetched into from remote repository, I gave $rootDir/gradle/my.gradle just as an example.
Was expecting to have some preemptive definition.

Is there a possibility of creating my own “real” plugin containing this class?

Of course, just build a plugin and use that instead. That’s recommended over remote scripts anyway :slight_smile: