Code Monkey home page Code Monkey logo

kraal's Introduction

Kraal

Download Build Status

Attempting to use GraalVM and Kotlin coroutines together fails due to a limitation of GraalVM - it cannot handle some perfectly valid bytecode produced by the Kotlin compiler.

Kraal performs "node splitting" on Java bytecode in order to eliminate the irreducible loops produced by the Kotlin compiler that GraalVM doesn't handle. The result is a functionally-equivalent bytecode which can be successfully processed with GraalVM.

Eventually, GraalVM may support irreducible loops, or the Kotlin compiler may add a flag to produce bytecode without them. Until then, Kraal allows the usage of these two technologies together.

Usage

Gradle

Using the Kotlin DSL:

plugins {
    id("com.hpe.kraal") version "0.0.15"
}

The Kraal Gradle plugin by default takes all jars produced by the build and their runtime dependencies, processes them to remove irreducible loops, and leaves processed copies of the jars under build/kraal.

The kraal extension is provided for convenient configuration of the default execution of KraalTask:

kraal {
    input = files(...) // *replace* set of input files
    from(...)          // or, *add* to set of input files

    outputDirectory = file(...)
}

The task and extension expose properties that create a Provider of a zipTree of the processed versions of all of the files. This can be used as a convenient way to create a "fat jar" of the processed classes:

val fatjar by tasks.creating(Jar::class) {
    from(kraal.outputZipTrees) {
        exclude("META-INF/*.SF")
        exclude("META-INF/*.DSA")
        exclude("META-INF/*.RSA")
    }
}

See the example directory for a complete working example with Ktor and GraalVM.

Maven

Use the exec-maven-plugin to execute the Kraal driver application com.hpe.kraal.MainKt:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.6.0</version>
    <dependencies>
        <dependency>
            <groupId>com.hpe.kraal</groupId>
            <artifactId>kraal</artifactId>
            <version>0.0.15</version>
        </dependency>
    </dependencies>
    <executions>
        <execution>
            <goals>
                <goal>java</goal>
            </goals>
            <phase>package</phase>
            <configuration>
                <mainClass>com.hpe.kraal.MainKt</mainClass>
                <arguments>
                    <argument>${project.build.directory}/${project.build.finalName}.${project.packaging}</argument>
                </arguments>
                <includePluginDependencies>true</includePluginDependencies>
            </configuration>
        </execution>
    </executions>
</plugin>

See the maven-example directory for a complete working example with Ktor and GraalVM.

kraal's People

Contributors

bradnewman avatar wx-yz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.