jason810496 opened a new pull request, #74096: URL: https://github.com/apache/airflow/pull/74096
- related: #71929, #73723 Builds on #71190 ([new commits only](https://github.com/apache/airflow/compare/eb662eac6fc...jason/java-sdk/pack-dag-sources); the commits below them are from #71189 and #71190). Merge after it. ## Why Airflow can parse native Java Dags (#74036), and its Code view needs the Dag's source. A bundle JAR carried at most one hand-picked file, so a Dag declared in another class had no source of its own. This follows #73723 for TypeScript: pack each Dag's source file once, map every Dag to its file, and always keep the entrypoint as a fallback. ## What changes - The Gradle plugin's new `packDagSources` task packs the source of `mainClass` and of each class that declares a Dag in Java into the bundle JAR, and indexes them in `sources.json`. Nothing to configure. - To learn which class declares each Dag, the task runs `mainClass` once at build time. If that run fails, the build logs a warning and packs only the `mainClass` source. - A Dag built by a `@Builder.Dag` class maps to that class, not to the generated builder. Task handlers for a Python Dag are not listed. - `.java`, `.kt` and `.scala` sources all work. The bundle JAR now holds: ``` META-INF/MANIFEST.MF Main-Class: org.apache.airflow.example.ExampleBundleBuilder Airflow-Java-SDK-Sources: META-INF/airflow/sources.json META-INF/airflow/sources.json META-INF/airflow/sources/org/apache/airflow/example/ExampleBundleBuilder.java META-INF/airflow/sources/org/apache/airflow/example/nativedag/AnnotationExample.java META-INF/airflow/sources/org/apache/airflow/example/nativedag/InterfaceExample.java ``` ```json { "entrypoint_path": "org/apache/airflow/example/ExampleBundleBuilder.java", "dag_source_paths": { "java_native_annotation_example": "org/apache/airflow/example/nativedag/AnnotationExample.java", "java_native_interface_example": "org/apache/airflow/example/nativedag/InterfaceExample.java" } } ``` ## How to test ```bash cd java-sdk && ./gradlew :sdk:test :processor:test :plugin:test ``` --- ##### Was generative AI tooling used to co-author this PR? - [x] Yes, with help of Claude Code Opus 5.5 following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
