uranusjr commented on code in PR #74096:
URL: https://github.com/apache/airflow/pull/74096#discussion_r4214882387
##########
java-sdk/plugin/src/main/kotlin/org/apache/airflow/sdk/plugin/AirflowSdkPlugin.kt:
##########
@@ -107,21 +120,45 @@ class AirflowSdkPlugin : Plugin<Project> {
ext.fatJar.convention(true)
project.afterEvaluate {
+ val main =
project.extensions.getByType(SourceSetContainer::class.java).getByName("main")
+
+ val packTask =
+ project.tasks.register("packDagSources", PackDagSources::class.java) {
task ->
+ task.group = "build"
+ task.description = "Collects the source file of each Dag and the
entrypoint to pack into the bundle JAR."
+ task.dependsOn(project.tasks.named("classes"))
+ task.onlyIf { ext.mainClass.isPresent }
+ task.mainClass.set(ext.mainClass)
+ task.classesDirs.from(main.output.classesDirs)
+ task.runtimeClasspath.from(main.output, main.runtimeClasspath)
+ task.sourceDirs.from(main.allSource.srcDirs)
+ task.launcher.convention(
+ project.extensions
+ .getByType(JavaToolchainService::class.java)
+
.launcherFor(project.extensions.getByType(JavaPluginExtension::class.java).toolchain),
+ )
+
task.describeFile.set(project.layout.buildDirectory.file("airflow/describe-sources.json"))
+
task.sourcesDir.set(project.layout.buildDirectory.dir("airflow/sources"))
+ }
+
project.tasks.withType(Jar::class.java).configureEach { task ->
task.doFirst {
ext.mainClass.orNull?.let { className ->
task.manifest.attributes(mapOf("Main-Class" to className))
}
}
+ // The sources payload belongs only in the JARs a bundle is assembled
from,
+ // so a sources or javadoc JAR does not carry it.
+ if (ext.mainClass.isPresent && task.name in BUNDLE_JAR_TASKS) {
+ task.dependsOn(packTask)
Review Comment:
```suggestion
```
The next line already carries the dependency with `from`.
--
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]