在学习Gradle 时,示例代码中使用了jetty插件:

apply plugin: 'jetty'

然后运行时会报错:

Plugin with id 'jetty' not found.

明明和书上的代码一致,为什么为报错呢?

经查询Gradle的使用指南,找到了原因:

This plugin is deprecated and will be removed in Gradle 4.0. Consider using the more feature-rich Gretty plugin instead.

我看了一下我的 Gradle版本:

λ gradle -version

------------------------------------------------------------
Gradle 4.0
------------------------------------------------------------

Build time:   2017-04-10 13:37:25 UTC
Revision:     b762622a185d59ce0cfc9cbc6ab5dd22469e18a6

Groovy:       2.4.10
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_31 (Oracle Corporation 25.31-b07)
OS:           Windows 8.1 6.3 amd64

所以,jetty插件不可使用.要解决此问题,有两个方案:

  • 降级Gradle版本小于4.0
  • 使用 Gretty插件