Class GenerateNPMBindingsTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
dev.gmitch215.bytebox.gradle.GenerateNPMBindingsTask
All Implemented Interfaces:
Comparable<org.gradle.api.Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.TaskInternal, org.gradle.api.Named, org.gradle.api.plugins.ExtensionAware, org.gradle.api.Task, org.gradle.util.Configurable<org.gradle.api.Task>

@DisableCachingByDefault(because="reads node_modules, which is not a declared input") public abstract class GenerateNPMBindingsTask extends org.gradle.api.DefaultTask
Writes Java bindings for the npm packages a project asks for, from their TypeScript types.

The reading is done by bytebox-bindgen, which ships with the bytebox npm package, because the thing that understands a package's types is the TypeScript compiler and it does not run on the JVM. This task resolves that command, runs it, and puts what it writes on the main source set so a project calls the bindings like any other class.

Declared packages are not generated for unless they are also asked for by name. Generation needs the package installed and a JavaScript runtime on PATH, and neither is true of every build that merely depends on a package.

Since:
1.0.0
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.gradle.api.Named

    org.gradle.api.Named.Namer
  • Field Summary

    Fields inherited from interface org.gradle.api.Task

    TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
  • Constructor Summary

    Constructors
    Constructor
    Description
    GenerateNPMBindingsTask(org.gradle.process.ExecOperations exec)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Runs the generator.
    abstract org.gradle.api.provider.Property<Boolean>
    Returns whether the generator may import a package to read exports it cannot see.
    abstract org.gradle.api.provider.Property<String>
    Returns the Java package the generated classes live in.
    abstract org.gradle.api.file.DirectoryProperty
    Returns the directory holding node_modules.
    abstract org.gradle.api.file.DirectoryProperty
    Returns where the generated source goes.
    abstract org.gradle.api.provider.ListProperty<String>
    Returns the package specifiers to bind, each optionally naming a subpath export.
    abstract org.gradle.api.provider.Property<String>
    Returns the pinned runner, or empty to search.

    Methods inherited from class org.gradle.api.DefaultTask

    compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService

    Methods inherited from class org.gradle.api.internal.AbstractTask

    acceptServiceReferences, appendParallelSafeAction, doNotTrackState, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, setImpliesSubProjects

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.gradle.api.Task

    doNotTrackState, notCompatibleWithConfigurationCache
  • Constructor Details

    • GenerateNPMBindingsTask

      @Inject public GenerateNPMBindingsTask(org.gradle.process.ExecOperations exec)
      Parameters:
      exec - Gradle's process runner
  • Method Details

    • getPackages

      @Input public abstract org.gradle.api.provider.ListProperty<String> getPackages()
      Returns the package specifiers to bind, each optionally naming a subpath export.
      Returns:
      the package specifiers to bind, each optionally naming a subpath export
    • getJavaPackage

      @Input public abstract org.gradle.api.provider.Property<String> getJavaPackage()
      Returns the Java package the generated classes live in.
      Returns:
      the Java package the generated classes live in
    • getIntrospect

      @Input public abstract org.gradle.api.provider.Property<Boolean> getIntrospect()
      Returns whether the generator may import a package to read exports it cannot see.
      Returns:
      whether the generator may import a package to read exports it cannot see
    • getNodeDirectory

      @Internal public abstract org.gradle.api.file.DirectoryProperty getNodeDirectory()
      Returns the directory holding node_modules.
      Returns:
      the directory holding node_modules
    • getRunner

      @Input @Optional public abstract org.gradle.api.provider.Property<String> getRunner()
      Returns the pinned runner, or empty to search.
      Returns:
      the pinned runner, or empty to search
    • getOutputDirectory

      @OutputDirectory public abstract org.gradle.api.file.DirectoryProperty getOutputDirectory()
      Returns where the generated source goes.
      Returns:
      where the generated source goes
    • generate

      public void generate()
      Runs the generator.