简体   繁体   English

Gradle插件依赖项(NoClassDefFoundError)

[英]Gradle plugin dependency (NoClassDefFoundError)

I am trying to write gradle plugin, which is dependent on RPM nebula plugin (it basically wraps it). 我正在尝试编写gradle插件,该插件依赖于RPM星云插件(基本上将其包装)。 I compile the plugin without any issues. 我编译插件没有任何问题。 In generated ivy.xml I have 在生成的ivy.xml中,我有

  <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... 当我将星云依赖项作为buildscript依赖项直接添加到应用程序项目中时,它会起作用,但这不是我认为的工作方式-插件应下载其所有依赖项,并且客户端无需关心...

Thanks in advance! 提前致谢!

After few hours - the problem was, that pom.xml was not generated. 几个小时后-问题是没有生成pom.xml。 When created using 使用时创建

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

it works as expected... 它按预期工作...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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