Class ByteboxPlugin

java.lang.Object
dev.gmitch215.bytebox.gradle.ByteboxPlugin
All Implemented Interfaces:
org.gradle.api.Plugin<org.gradle.api.Project>

public class ByteboxPlugin extends Object implements org.gradle.api.Plugin<org.gradle.api.Project>
Compiles a Java workspace into a Cloudflare Worker.

Applying this plugin registers the bytebox { } block and a pipeline that ends in a deployable Worker:

  1. generateNpmBindings writes Java for the npm packages a project names, read from their TypeScript types.
  2. generateEntryPoint writes the class the module exports its handlers from, deriving which handlers from the interfaces the handler class implements.
  3. generateCodecs writes a JSON codec for every type annotated @JSONType.
  4. compileWasm runs the compiler, which is TeaVM's own task.
  5. packWasm puts the module where the Worker imports it, and enforces the size budget.
  6. generateWorkerScaffold writes the Wrangler configuration, the JavaScript entry point and the package manifest.
  7. buildWorker depends on all of it.

Everything up to and including buildWorker runs with no Cloudflare credentials. Only the commands that reach the account need a login, and each says so.

Since:
1.0.0
  • Field Details

    • GROUP

      public static final String GROUP
      The task group every task this plugin registers belongs to.
      See Also:
    • WORKER_DIRECTORY

      public static final String WORKER_DIRECTORY
      Where the generated Worker project is written, under the build directory.
      See Also:
    • GENERATED_SOURCE_SET

      public static final String GENERATED_SOURCE_SET
      The source set the generated entry point and codecs are compiled in.
      See Also:
    • NPM_PACKAGE

      public static final String NPM_PACKAGE
      The Java package generated npm bindings live in.
      See Also:
    • BUFFER_HEAP_MEGABYTES

      public static final int BUFFER_HEAP_MEGABYTES
      Megabytes of linear memory the interop stages arrays through, which cannot be zero.

      TeaVM's own default is two. One is enough for the staging buffer, which is four kilobytes, and the heap grows from there when a program needs more.

      See Also:
  • Constructor Details

    • ByteboxPlugin

      public ByteboxPlugin()
  • Method Details

    • apply

      public void apply(org.gradle.api.Project project)
      Specified by:
      apply in interface org.gradle.api.Plugin<org.gradle.api.Project>