tree: 482679afb2b6d444ac781904881469223521a75d [search]
  1. adr/
  2. bom/
  3. buildSrc/
  4. example/
  5. gradle/
  6. jpl/
  7. jul/
  8. log4j2/
  9. plugin/
  10. processor/
  11. scala_spark_example/
  12. scripts/
  13. sdk/
  14. slf4j/
  15. .editorconfig
  16. .gitattributes
  17. .gitignore
  18. build.gradle.kts
  19. capabilities.yaml
  20. DEVELOPMENT.md
  21. gradle.properties
  22. gradlew
  23. gradlew.bat
  24. LICENSE
  25. NOTICE
  26. README.md
  27. settings.gradle.kts
java-sdk/README.md

Airflow Java SDK

Write Apache Airflow Dags and tasks in Java, Kotlin, Scala or any other JVM language.

Status: Experimental · API may change · Java 11+

Installation

Apply the Gradle plugin, and add the SDK and its annotation processor:

plugins {
    id("org.apache.airflow.sdk") version "<version>"
}

dependencies {
    annotationProcessor("org.apache.airflow:airflow-sdk-processor:<version>")
    implementation("org.apache.airflow:airflow-sdk:<version>")
}

airflowBundle {
    mainClass = "com.mycompany.airflow.hello.Main"
}

Replace <version> with a release from Maven Central. See the guide for Maven.

Quick start

Declare a Dag:

package com.mycompany.airflow.hello;

import org.apache.airflow.sdk.*;

@Airflow.Dag(id = "java_hello", schedule = "@daily", queue = "java")
public class HelloDag {

  @Airflow.Task
  public long extract() {
    return 42L;
  }

  @Airflow.Task
  public void report(long rows) {
    System.out.println("extracted " + rows + " rows");
  }

  @Airflow.Deps
  static class Wiring implements HelloDagDeps {
    void depends() {
      report(extract());
    }
  }
}

Serve it from the main class:

package com.mycompany.airflow.hello;

import org.apache.airflow.sdk.Bundle;
import org.apache.airflow.sdk.Server;

public class Main {
  public static void main(String[] args) {
    Server.create(args).serve(new Bundle().register(HelloDag.class));
  }
}

Build the bundle into build/bundle/:

./gradlew bundle

Copy build/bundle/ into a Dag bundle, such as the default dags-folder bundle, and send the java queue to the Java coordinator in airflow.cfg:

[sdk]
coordinators = {"java": {"classpath": "airflow.sdk.coordinators.java.JavaCoordinator"}}
queue_to_coordinator = {"java": "java"}

Airflow reads the bundle like any other Dag file: java_hello shows up in the UI, runs on its schedule, and report receives the value extract returned.

Learn more

The Java SDK guide covers:

TopicGuide section
Task inputs, options, order-only dependencies, task groups, branching, triggering another DagDeclaring a Dag in Java
@Airflow.TaskHandler for the @task.stub tasks of a Python Dag, and how arguments bindImplementing stub tasks of a Python Dag
Client, Context, and what a task returnsWriting tasks
Building a bundle with Gradle or MavenBuilding a bundle
Where to deploy a bundle, and the JavaCoordinator optionsDeploying
What a Dag declared in Java cannot do yetLimitations

See example/ for a working project.

Compatibility matrix

Which Airflow TaskInstance states and capabilities this SDK supports. This table is generated from capabilities.yaml; the conformance dimensions are defined in the Language SDK conformance spec. Do not edit the table by hand — edit capabilities.yaml and let the update-java-sdk-readme-matrix prek hook regenerate it.

Min. Airflow version: 3.5.0 · supervisor schema: 2027-02-28

DimensionTierSupportedSince (Airflow)Since (SDK)Notes
TaskInstance states
state: successMUST✓3.4.01.0.0
state: failedMUST✓3.4.01.0.0
state: up_for_retryMUST✓3.4.01.0.0RetryTask
state: skippedSHOULD✓3.4.01.0.0a TriggerDagRun task that skips an existing run
state: deferredMAY✓3.4.01.0.0a TriggerDagRun task that waits with deferrable
state: up_for_rescheduleMAY✗––runtime does not emit RescheduleTask yet
state: awaiting_inputMAY✗––runtime does not emit AwaitInputTask yet
state: removedMAY✓3.4.01.0.0
Task runtime
capability: task-loggingMUST✓3.4.01.0.0SLF4J + JPL bridged to the task log
capability: xcom-read-writeMUST✓3.4.01.0.0
capability: custom-xcom-backendMAY✓3.5.01.0.0the supervisor runs the configured [core] xcom_backend
capability: connection-readMUST✓3.4.01.0.0
capability: variable-read-writeMUST✓3.4.01.0.0
capability: self-contained-bundleMUST✓3.4.01.0.0Airflow metadata embedded in the jar artifact
capability: retry-policyMAY✗––no task-facing retry-policy API yet
capability: task-state-storeMAY✓3.4.01.0.0Client.getTaskStateStore() get/set/delete/clear
capability: asset-state-storeMAY✗––no task-facing asset state-store API yet
capability: asset-event-emitMAY✗––runtime does not emit asset events yet
capability: asset-event-readMAY✗––no task-facing asset-event API yet
capability: object-storeMAY✗––no object-storage API yet
capability: listenersMAY✗––no hook into the Python listener API, so a task emits no OpenLineage facets of its own
Dag definition
capability: dag-definition-authoringSHOULD✓3.4.01.0.0
capability: dag-argsMUST †✓3.4.01.0.0
capability: task-argsMUST †✓3.4.01.0.0
capability: dag-paramsMUST †✗––
capability: dag-callbacksMAY †✗––
capability: explicit-dependenciesMUST †✓3.4.01.0.0before / after, or @Airflow.Deps
capability: edge-labelsMAY †✓3.4.01.0.0Label.of(text).on(task)
capability: taskflow-dependenciesMUST †✓3.4.01.0.0
capability: task-groupMAY †✓3.4.01.0.0
capability: task-loopsMAY †✗––
capability: if-else-branchingSHOULD †✓3.4.01.0.0DagDef.If or @Airflow.If
capability: switch-case-branchingSHOULD †✓3.4.01.0.0DagDef.Switch or @Airflow.Switch
capability: trigger-dag-runMAY †✓3.4.01.0.0TriggerDagRun
capability: dynamic-dag-generationMAY †✓3.4.01.0.0
capability: human-in-the-loopMAY †✗––
capability: dag-testSHOULD †✗––
capability: asset-definitionMAY †✗––
capability: asset-schedulingMAY †✗––
capability: mapped-tasksMAY †✗––
capability: asset-inlets-outletsMAY †✗––
capability: task-callbacksMAY †✗––no SDK-defined task callbacks
Python Dag with stub TaskHandler
capability: mixed-lang-stub-targetMUST✓3.4.01.0.0@task.stub
capability: taskflow-bindingMUST✓3.4.01.0.0mapped stubs excluded
capability: mapped-tasksMAY✗––Airflow does not bind arguments to mapped stubs yet
capability: asset-inlets-outletsMAY✗––runtime does not report task outlets yet
capability: task-callbacksMAY✗––a Python-declared task callback does not run for a stub task

Marks: ✓ supported · ✗ not supported · n/a not applicable. A tier marked † applies only when dag-definition-authoring is supported.

Links