0

我在这里查看了 thorntail 示例。

我创建了这个项目:

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

thorntail.gradle是:

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"
  }
}

build.gradle

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

我越来越:

➜  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.**

有任何想法吗?

4

1 回答 1

1

AFAIK 插件 ID 不能在外部脚本中使用。这是一个已知的限制。相反,您应该使用完全限定的插件类。例如,在thorntail.gradle

buildscript {
  String thorntailVersion = System.getProperty('thorntailVersion') ?: '2.5.1.Final-SNAPSHOT'
  repositories {
    mavenLocal()
    mavenCentral()
    maven {
      url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
  }
  dependencies {
    classpath "io.thorntail:thorntail-gradle-plugin:$thorntailVersion"
  }
}

apply plugin: 'org.wildfly.swarm.plugin.gradle.PackagePlugin'

build.gradle

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

我知道它看起来不像你所做的,因为apply它在外部脚本中。另一种选择(最接近您想要实现的目标)是您build.gradle输入以下内容:

buildscript {
  apply from: "$projectDir/gradle/thorntail.gradle",
  to: buildscript
}

apply plugin: 'thorntail'

然后在thorntail.gradle删除buildscript块并离开内部块,即:

String thorntailVersion = System.getProperty('thorntailVersion') ?: '2.5.1.Final-SNAPSHOT'
  repositories {
    mavenLocal()
    mavenCentral()
    maven {
      url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
  }
  dependencies {
    classpath "io.thorntail:thorntail-gradle-plugin:$thorntailVersion"
  }
于 2019-08-16T13:30:17.077 回答