Spotless gradle 插件无法在封闭系统上运行
Spotless gradle plugin not working on closed system
我正在使用 gradle 5.4.1。我正在使用 spotless-plugin-gradle 3.25.0.
我的build.gradle包含
plugins {
id 'java'
id 'eclipse'
id 'maven-publish'
id 'com.github.johnrengelman.plugin-shadow' version '2.0.3'
id 'org.sonarqube' version '2.7.1'
id 'com.diffplug.gradle.spotless' version '3.25.0'
}
我的封闭系统上的 nexus 一尘不染(它无法连接到互联网)。我的 nexus 存储库中一尘不染的 gav 是 'com.diffplug.spotless:spotless-plugin-gradle:3.25.0'.
我的 settings.gradle 文件包含:
pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == "org" && requested.id.name == "sonarqube") {
useModule("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${requested.version})
}
if (requested.id.namespace == "com.github.johnrengelman" && requested.id.name == "plugin-shadow") {
useModule("com.github.johnrengelman.gradle.plugins:shadow:${requested.version})
}
if (requested.id.namespace == "com.diffplug.gradle" && requested.id.name == "spotless") {
useModule("com.diffplug.spotless:spotless-plugin-gradle:${requested.version})
}
}
}
repositories {
maven {
url "http://nexus:8081/repository/jcenter"
}
}
}
当我执行“./gradlew dependencies”时,出现以下错误:
An exception occurred applying plugin request [id: 'com.diffplug.gradle.spotless' version: '3.25.0', artifact: 'com.diffplug.spotless:spotless-plugin-gradle:3.25.0']
> Failed to apply plugin [id: 'com.diffplug.gradle.spotless']
> Could not create an instance of type com.diffplug.gradle.spotless.SpotlessExtension
> Could not generate a decorated class for class com.diffplug.gradle.spotless.SpotlessExtension
> com/diffplug/spotless/LineEnding
堆栈跟踪似乎没有太大帮助。我尝试了旧方法(buildscript 块),但导致了同样的错误。有人可以指出我做错了什么吗?在我可以直接访问互联网的系统上(因此不需要向 settings.gradle 文件添加任何条目)一切正常。
Bjorn Vester 一针见血:
It looks like a missing class definition to me. Did you upload all the plugin's dependencies and its original pom file?
我正在使用 gradle 5.4.1。我正在使用 spotless-plugin-gradle 3.25.0.
我的build.gradle包含
plugins {
id 'java'
id 'eclipse'
id 'maven-publish'
id 'com.github.johnrengelman.plugin-shadow' version '2.0.3'
id 'org.sonarqube' version '2.7.1'
id 'com.diffplug.gradle.spotless' version '3.25.0'
}
我的封闭系统上的 nexus 一尘不染(它无法连接到互联网)。我的 nexus 存储库中一尘不染的 gav 是 'com.diffplug.spotless:spotless-plugin-gradle:3.25.0'.
我的 settings.gradle 文件包含:
pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == "org" && requested.id.name == "sonarqube") {
useModule("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${requested.version})
}
if (requested.id.namespace == "com.github.johnrengelman" && requested.id.name == "plugin-shadow") {
useModule("com.github.johnrengelman.gradle.plugins:shadow:${requested.version})
}
if (requested.id.namespace == "com.diffplug.gradle" && requested.id.name == "spotless") {
useModule("com.diffplug.spotless:spotless-plugin-gradle:${requested.version})
}
}
}
repositories {
maven {
url "http://nexus:8081/repository/jcenter"
}
}
}
当我执行“./gradlew dependencies”时,出现以下错误:
An exception occurred applying plugin request [id: 'com.diffplug.gradle.spotless' version: '3.25.0', artifact: 'com.diffplug.spotless:spotless-plugin-gradle:3.25.0']
> Failed to apply plugin [id: 'com.diffplug.gradle.spotless']
> Could not create an instance of type com.diffplug.gradle.spotless.SpotlessExtension
> Could not generate a decorated class for class com.diffplug.gradle.spotless.SpotlessExtension
> com/diffplug/spotless/LineEnding
堆栈跟踪似乎没有太大帮助。我尝试了旧方法(buildscript 块),但导致了同样的错误。有人可以指出我做错了什么吗?在我可以直接访问互联网的系统上(因此不需要向 settings.gradle 文件添加任何条目)一切正常。
Bjorn Vester 一针见血:
It looks like a missing class definition to me. Did you upload all the plugin's dependencies and its original pom file?