Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Enaium/gradle-plugin-transform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Transform

img release

Install

plugins {
    id "cn.enaium.transform" version "1.2"
}

repositories {
  gradlePluginPortal()
}

dependencies {
    compileOnly('cn.enaium:transform:1.2')
}

or

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "cn.enaium:transform:1.2"
  }
}

apply plugin: "cn.enaium.transform"

Example

transformExtend {
    transform = new ITransform() {
        @Override
        byte[] transform(byte[] basic) {
            ClassReader classReader = new ClassReader(basic)
            ClassWriter classWriter = new ClassWriter(0);
            classReader.accept(new ClassVisitor(Opcodes.ASM5, classWriter) {
                @Override
                void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
                    println name
                    super.visit(version, access, name, signature, superName, interfaces)
                }
            }, 0)
            return classWriter.toByteArray()
        }
    }
}

compileJava.finalizedBy(transformTask)