Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Oliver Libutzki
    @OLibutzki
    Hi 😁
    Oliver Drotbohm
    @odrotbohm
    👋
    Oliver Drotbohm
    @odrotbohm
    We're gonna have our monthly jour fix today at 5:30pm CET. Feel free to join: https://wps-de.zoom.us/j/88670396340?pwd=TWN2UDBRZEtqN2J2a2U5ZUNRcGpjZz09
    Oliver Libutzki
    @OLibutzki
    Would like to join, but I can't on Mondays.
    Oliver Drotbohm
    @odrotbohm
    Monthly Jour fix in T-41m: same Zoom link as above: https://wps-de.zoom.us/j/88670396340?pwd=TWN2UDBRZEtqN2J2a2U5ZUNRcGpjZz09
    Oliver Drotbohm
    @odrotbohm
    itshan
    @MadeInChina
    Hi guys, just raise a issue about kotlin with gradle. seems not working
    xmolecules/jmolecules-examples#6
    itshan
    @MadeInChina

    Hi @odrotbohm, do you have any suggestions on that?

    Task :byteBuddy
    No types were transformed during plugin execution

    Oliver Drotbohm
    @odrotbohm
    Any chance you add a reproducer project to the ticket?
    itshan
    @MadeInChina
    also uploaded the reproducer project to the ticket as well
    itshan
    @MadeInChina
    created a plugin, not working well
    import net.bytebuddy.ClassFileVersion
    import net.bytebuddy.build.EntryPoint
    import net.bytebuddy.build.gradle.ByteBuddyTask
    import net.bytebuddy.build.gradle.Discovery
    import net.bytebuddy.build.gradle.IncrementalResolver
    import org.gradle.api.Plugin
    import org.gradle.api.Project
    import org.gradle.api.file.Directory
    import org.gradle.api.tasks.compile.AbstractCompile
    import org.jmolecules.bytebuddy.JMoleculesPlugin
    
    class ByteBuddyKotlinPlugin implements Plugin<Project> {
    
        @Override
        void apply(Project project) {
            println ("ByteBuddyKotlinPlugin.apply()")
            project.tasks.matching { it.name in ['compileJava', 'compileScala', 'compileKotlin'] }.all {
                def compileTask = it as AbstractCompile
                project.afterEvaluate {
                    if (!compileTask.source.empty) {
                        String instrumentName = compileTask.name.replace('compile', 'instrument')
    
                        ByteBuddyTask byteBuddyTask = project.tasks.create(instrumentName, ByteBuddyTask)
                        byteBuddyTask.group = 'Byte Buddy'
                        byteBuddyTask.description = "Instruments the classes compiled by ${compileTask.name}"
    
                        byteBuddyTask.entryPoint = EntryPoint.Default.REBASE
                        byteBuddyTask.suffix = ''
                        byteBuddyTask.failOnLiveInitializer = true
                        byteBuddyTask.warnOnEmptyTypeSet = true
                        byteBuddyTask.failFast = false
                        byteBuddyTask.extendedParsing = false
                        byteBuddyTask.discovery = Discovery.NONE
                        byteBuddyTask.threads = 0
                        byteBuddyTask.classFileVersion = ClassFileVersion.JAVA_V17
    
                        byteBuddyTask.incrementalResolver = IncrementalResolver.ForChangedFiles.INSTANCE
    
                        // use intermediate 'raw' directory for unprocessed classes
                        Directory classesDir = compileTask.destinationDirectory.get()
                        Directory rawClassesDir = classesDir.dir('../raw/')
    
                        byteBuddyTask.source = rawClassesDir
                        byteBuddyTask.target = classesDir
    
                        compileTask.destinationDir = rawClassesDir.asFile
    
                        byteBuddyTask.classPath.from(project.configurations.compileClasspath + compileTask.destinationDir)
    
                        byteBuddyTask.transformation {
                            it.plugin = JMoleculesPlugin
                            it.argument({ it.value = byteBuddyTask.classPath.collect({ it.toURI() as String }) })
                            it.argument({ it.value = byteBuddyTask.target.get().asFile.path }) // must serialize as String
                        }
    
                        // insert task between compile and jar, and before test*
                        byteBuddyTask.dependsOn(compileTask)
                        project.tasks.named(project.sourceSets.main.classesTaskName).configure {
                            dependsOn(byteBuddyTask)
                        }
                    }
                }
            }
        }
    }