简体   繁体   中英

Gradle plugin dependency (NoClassDefFoundError)

I am trying to write gradle plugin, which is dependent on RPM nebula plugin (it basically wraps it). I compile the plugin without any issues. In generated ivy.xml I have

  <dependencies>
      <dependency org="com.netflix.nebula" name="gradle-ospackage-plugin" rev="4.1.0" conf="compile-&gt;default"/>
  </dependencies>

Which feels ok, but when I apply my plugin in application, I get

Caused by: java.lang.NoClassDefFoundError: com/netflix/gradle/plugins/rpm/RpmPlugin
    at com.cisco.td.gradle.rpm.ServiceRpmPlugin$_configureProject_closure2.doCall(ServiceRpmPlugin.groovy:27)
    at com.cisco.td.gradle.rpm.ServiceRpmPlugin.configureProject(ServiceRpmPlugin.groovy:26)

When executing this section of code

    project.plugins.with {
        apply RpmPlugin
    }

I have tried to add the dependency on build classpath from my plugin class using

    project.buildscript.dependencies {
        classpath "com.netflix.nebula:gradle-ospackage-plugin:4.1.0"
    }

But this throws:

Caused by: org.gradle.api.InvalidUserDataException: Cannot change dependencies of configuration ':classpath' after it has been resolved.
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.validateMutation(DefaultConfiguration.java:631)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$2.run(DefaultConfiguration.java:174)
    at org.gradle.api.internal.DefaultDomainObjectCollection.assertMutable(DefaultDomainObjectCollection.java:274)

It works, when I add the nebula dependency directly to the application project as a buildscript dependency, but this is not how I think it should work - the plugin should download all its dependencies and the client should not care...

Thanks in advance!

After few hours - the problem was, that pom.xml was not generated. When created using

uploadArchives {
  repositories {
      mavenDeployer {
        repository(url: mavenLocal().url)
      }
  }
}

it works as expected...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM