java-stab-gen

a stab in java of class file generator. a tool for workaround of KT-24309.

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.anatawa12.java-stab-gen
ArtifactId

ArtifactId

java-stab-gen
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

java-stab-gen
a stab in java of class file generator. a tool for workaround of KT-24309.
Project URL

Project URL

https://github.com/anatawa12/java-stab-of-class-file
Source Code Management

Source Code Management

https://github.com/anatawa12/java-stab-of-class-file

Download java-stab-gen

Dependencies

compile (1)

Group / Artifact Type Version
com.squareup : javapoet jar 1.13.0

runtime (2)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib jar 1.4.21
org.ow2.asm : asm-tree jar 9.1

Project Modules

There are no modules declared in this project.

java stab of class file generator

This is for a workaround of KT-24309.

How to use

As a Gradle Library

  1. add com.anatawa12.java-stab-gen:gradle-library:1.0.0 to buildscript depencencies.

    kotlin ```groovy buildscript { repositories { mavenCentral() } dependencies { classpath("com.anatawa12.java-stab-gen:gradle-library:1.0.0") } } ```
    groovy ```groovy buildscript { repositories { mavenCentral() } dependencies { classpath "com.anatawa12.java-stab-gen:gradle-library:1.0.0" } } ```
  2. create task with type com.anatawa12.javaStabGen.gradle.ClassesGenerator

    kotlin
    import com.anatawa12.javaStabGen.gradle.GenerateJavaStab
    
    val generateJavaStab by tasks.creating(GenerateJavaStab::class) {
        generatedDir = file("$buildDir/generated/stab")
        classpath = classpath_you_want_to_generate_stab_for
    }
    groovy
    import com.anatawa12.javaStabGen.gradle.GenerateJavaStab
    task generateJavaStab(type: GenerateJavaStab) {
        generatedDir = file("$buildDir/generated/stab")
        classpath = classpath_you_want_to_generate_stab_for
    }

Examples

Workaround of KT-24309

groovy
import com.anatawa12.javaStabGen.gradle.GenerateJavaStab

def theLibraryDependsThisProject = TODO

// generate stab for $theLibraryDependsThisProject
// into "$buildDir/generated/stab"
task generateJavaStab(type: GenerateJavaStab) {
   generatedDir = file("$buildDir/generated/stab")
   classpath = files(theLibraryDependsThisProject)
}
compileKotlin {
   dependsOn(generateJavaStab)
   // add and include generateJavaStab.generatedDir as java source code
   source(generateJavaStab.generatedDir)
   include("**/*.java")
}

Versions

Version
1.0.0