Thorntail plugin not found

I’ve created this project:

frontoffice
├── gradle.properties
├── build.gradle
├── gradle
│   └── thorntail.gradle

thorntail.gradle is:

buildscript {
  String thorntailVersion = System.getProperty('thorntailVersion') ?: VERSION_THORNTAIL

  repositories {
    mavenLocal()
    mavenCentral()
    maven {
      url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
  }

  dependencies {
    classpath "io.thorntail:thorntail-gradle-plugin:$thorntailVersion"
  }
}

and build.gradle:

apply from: "$projectDir/gradle/thorntail.gradle"
apply plugin: 'thorntail'

I’m getting:

➜  prjt git:(master) ✗ gradle clean compile

FAILURE: Build failed with an exception.

* Where:
Build file '/home/jeusdi/projects/espaidoc/frontoffice/build.gradle' line: 10

* What went wrong:
A problem occurred evaluating project ':frontoffice'.
**> Plugin with id 'thorntail' not found.**

Any ideas?

After research, this seems to be caused by incorrect placement of “apply … thorntail.gradle”.

Adding apply to buildscript and using ‘to buildscript’, seems to work for me:

buildscript {
    apply {
        from ‘thorntail.gradle’
        to buildscript
    }
}

I found these in kotlin-dsl Github repository, where I found (an issue and a pull request related to applying a script to buildscript.