添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
爱跑步的电影票  ·  Using Gradle for CI - ...·  1 月前    · 
不要命的铁链  ·  Proxy Error when ...·  1 月前    · 
强健的土豆  ·  Gradle jar ...·  3 周前    · 
近视的砖头  ·  博客來-SANA ...·  3 月前    · 
犯傻的绿茶  ·  C# 之 ...·  1 年前    · 
淡定的小刀  ·  springboot ...·  1 年前    · 

Gradle plugin jar is missing classes #758

Closed
@ohad7

Description

I experienced a few challenges using the gradle plugin.

  • Gradle complains if you just put the plain plugin
  • * What went wrong:
    Plugin [id: 'net.bytebuddy.byte-buddy-gradle-plugin'] was not found in any of the following sources:
    - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
    - Plugin Repositories (plugin dependency must include a version number for this source)
    

    It's possible to overcome by adding a version:

    id 'net.bytebuddy.byte-buddy-gradle-plugin' version '1.10.2'

  • Gradle throws a class not found exception when invoking the plugin:
  • Caused by: java.lang.NoClassDefFoundError: net/bytebuddy/dynamic/scaffold/inline/MethodNameTransformer
            at org.gradle.internal.reflect.ClassInspector.inspectClass(ClassInspector.java:69)
            at org.gradle.internal.reflect.ClassInspector.visitGraph(ClassInspector.java:55)
            at org.gradle.internal.reflect.ClassInspector.inspect(ClassInspector.java:35)
            at org.gradle.internal.instantiation.AbstractClassGenerator.inspectType(AbstractClassGenerator.java:213)
            at org.gradle.internal.instantiation.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:161)
            ... 157 more
    Caused by: java.lang.ClassNotFoundException: net.bytebuddy.dynamic.scaffold.inline.MethodNameTransformer
            ... 162 more
    

    The reason is that the jar that's published in maven contains only the plugin classes. Not sure if the right thing to do is to fatjar the missing classes, I was able to overcome it by adding it into the configuration :

    buildscript {
      repositories {
        maven {
          url "https://plugins.gradle.org/m2/"
      dependencies {
        classpath "gradle.plugin.net.bytebuddy:byte-buddy-gradle-plugin:1.10.1"
        classpath "net.bytebuddy:byte-buddy-dep:1.10.1"
    
  • It's awesome that you can configure the plugin, could be that it's worth while to add an example for configuring a plugin with an argument:
  • configurations {
      examplePlugin
    dependencies {
      examplePlugin "foo:bar:1.0"
    byteBuddy {
      transformation {
        plugin = "com.yahoo.MyPlugin"
        classPath = configurations.examplePlugin
        argument { value = 'Some parameter' }