Spotless gradle plugin not working on closed system

I am using gradle 5.4.1. I am using spotless-plugin-gradle 3.25.0.

My build.gradle contains

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

I have spotless in nexus on my closed system (it cannot reach the internet). The gav for spotless in my nexus repository is ‘com.diffplug.spotless:spotless-plugin-gradle:3.25.0’.

My settings.gradle file contains:

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

When I do a “./gradlew dependencies” I get the following error:

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

the stacktrace didn’t seem to help much. I tried the old approach (buildscript block) but that results in the same error. Can someone point out what I am doing wrong? On a system where I have direct access to the internet (and thus don’t need to add any entries to the settings.gradle file) everything works just fine.

Answer

Bjorn Vester hit the nail on the head:

It looks like a missing class definition to me. Did you upload all the plugin’s dependencies and its original pom file?

Leave a Reply

Your email address will not be published. Required fields are marked *