Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .test-infra/metrics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ext {
cluster = 'metrics'
zone='us-central1-a'
projectName='apache-beam-testing'
kubeConfigPath = project.properties['KUBE_CONFIG_PATH'] ?: '/home/jenkins/.kube/config'
kubeConfigPath = project.findProperty('KUBE_CONFIG_PATH') ?: '/home/jenkins/.kube/config'
}

applyGroovyNature()
Expand Down
21 changes: 9 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,9 @@ tasks.register("pushAllRunnersDockerImages") {

doLast {
if (project.hasProperty("prune-images")) {
exec {
executable("docker")
args("system", "prune", "-a", "--force")
}
providers.exec {
commandLine("docker", "system", "prune", "-a", "--force")
}.result.get()
}
}
}
Expand All @@ -893,10 +892,9 @@ tasks.register("pushAllSdkDockerImages") {

doLast {
if (project.hasProperty("prune-images")) {
exec {
executable("docker")
args("system", "prune", "-a", "--force")
}
providers.exec {
commandLine("docker", "system", "prune", "-a", "--force")
}.result.get()
}
}
}
Expand All @@ -914,10 +912,9 @@ tasks.register("pushAllXlangDockerImages") {

doLast {
if (project.hasProperty("prune-images")) {
exec {
executable("docker")
args("system", "prune", "-a", "--force")
}
providers.exec {
commandLine("docker", "system", "prune", "-a", "--force")
}.result.get()
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ dependencies {
exclude(group="org.codehaus.plexus", module="plexus-xml") // plexus-xml 4.x requires Java17
}
runtimeOnly("org.codehaus.plexus:plexus-xml:3.0.2") // Do not bump to plexus-xml 4.x which requires Java17
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.14")
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:6.0.3")

runtimeOnly("com.google.protobuf:protobuf-gradle-plugin:0.8.13") // Enable proto code generation
runtimeOnly("com.google.protobuf:protobuf-gradle-plugin:0.9.6") // Enable proto code generation
runtimeOnly("com.github.davidmc24.gradle.plugin:gradle-avro-plugin:1.9.1") // Enable Avro code generation. Version 1.1.0 is the last supporting avro 1.10.2
runtimeOnly("com.diffplug.spotless:spotless-plugin-gradle:7.2.1") // Enable a code formatting plugin
runtimeOnly("gradle.plugin.com.dorongold.plugins:task-tree:1.5") // Adds a 'taskTree' task to print task dependency tree
Expand All @@ -77,7 +77,7 @@ dependencies {
runtimeOnly("com.avast.gradle:gradle-docker-compose-plugin:0.16.12") // Enable docker compose tasks
runtimeOnly("ca.cutterslade.gradle:gradle-dependency-analyze:1.8.3") // Enable dep analysis
runtimeOnly("gradle.plugin.net.ossindex:ossindex-gradle-plugin:0.4.11") // Enable dep vulnerability analysis
runtimeOnly("org.checkerframework:checkerframework-gradle-plugin:0.6.56") // Enable enhanced static checking plugin
implementation("org.checkerframework:org.checkerframework.gradle.plugin:1.0.2") // Enable enhanced static checking plugin
}

// Because buildSrc is built and tested automatically _before_ gradle
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package org.apache.beam.gradle
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.BasePluginExtension
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.file.FileTree
import org.gradle.api.publish.maven.MavenPublication
Expand Down Expand Up @@ -74,7 +75,7 @@ class VendorJavaPlugin implements Plugin<Project> {
VendorJavaPluginConfig config = it ? it as VendorJavaPluginConfig : new VendorJavaPluginConfig()

project.apply plugin: 'base'
project.archivesBaseName = config.artifactId
project.extensions.getByType(BasePluginExtension).archivesName.set(config.artifactId)

if (!isRelease(project)) {
config.version += '-SNAPSHOT'
Expand Down Expand Up @@ -303,7 +304,7 @@ artifactId=${project.name}

if (it instanceof ProjectDependency) {
dependencyNode.appendNode('groupId', it.getDependencyProject().mavenGroupId)
dependencyNode.appendNode('artifactId', it.getDependencyProject().archivesBaseName)
dependencyNode.appendNode('artifactId', it.getDependencyProject().extensions.getByType(BasePluginExtension).archivesName.get())
dependencyNode.appendNode('version', it.version)
dependencyNode.appendNode('scope', param.scope)
appendClassifier(it)
Expand Down
4 changes: 2 additions & 2 deletions examples/kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import groovy.json.JsonOutput

plugins { id 'org.apache.beam.module'
id 'org.jetbrains.kotlin.jvm' version '1.6.10'
id 'org.jetbrains.kotlin.jvm' version '2.4.21'
}

applyJavaNature(exportJavadoc: false, automaticModuleName: 'org.apache.beam.examples.kotlin')
Expand All @@ -46,7 +46,7 @@ configurations.sparkRunnerPreCommit {
exclude group: "org.slf4j", module: "slf4j-jdk14"
}

def kotlin_version = "1.6.10"
def kotlin_version = "2.4.21"

dependencies {
implementation enforcedPlatform(library.java.google_cloud_platform_libraries_bom)
Expand Down
4 changes: 3 additions & 1 deletion examples/multi-language/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

apply plugin: 'org.apache.beam.module'
apply plugin: 'application'
mainClassName = "org.apache.beam.sdk.expansion.service.ExpansionService"
application {
mainClass = "org.apache.beam.sdk.expansion.service.ExpansionService"
}

applyJavaNature(
automaticModuleName: 'org.apache.beam.examples.multilanguage',
Expand Down
153 changes: 52 additions & 101 deletions learning/tour-of-beam/frontend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,138 +20,95 @@ evaluationDependsOn(":playground:frontend:playground_components")

tasks.register("generate") {
dependsOn(":playground:frontend:playground_components:generate")

dependsOn("generateCode")

group = "build"
description = "Generates all generated files."
}

tasks.register("analyze") {
tasks.register<org.gradle.api.tasks.Exec>("analyze") {
dependsOn(":playground:frontend:playground_components:generateCode")
dependsOn("generateCode")

group = "verification"
description = "Analyze dart code"

doLast {
exec {
executable("dart")
args("analyze", "lib", "test")
}
}
commandLine("dart", "analyze", "lib", "test")
}

tasks.register("pubGet") {
tasks.register<org.gradle.api.tasks.Exec>("pubGet") {
group = "build"
description = "Get packages for the frontend project"
doLast {
exec {
executable("flutter")
args("pub", "get")
}
}
commandLine("flutter", "pub", "get")
}

tasks.register("format") {
tasks.register<org.gradle.api.tasks.Exec>("format") {
group = "build"
description = "Idiomatically format Dart source code"
doLast {
exec {
executable("dart")
args("format", "lib", "test")
}
}
commandLine("dart", "format", "lib", "test")
}

tasks.register("run") {
tasks.register<org.gradle.api.tasks.Exec>("run") {
group = "application"
description = "Run application on Google Chrome"

doLast {
exec {
executable("flutter")
args("run", "-d", "chrome")
}
}
commandLine("flutter", "run", "-d", "chrome")
}

tasks.register("test") {
tasks.register<org.gradle.api.tasks.Exec>("test") {
dependsOn(":playground:frontend:playground_components:generateCode")
dependsOn("generateCode")

group = "verification"
description = "flutter test"

doLast {
exec {
executable("flutter")
args("test")
}
}
commandLine("flutter", "test")
}

tasks.register("precommit") {
dependsOn(":playground:frontend:playground_components:precommit")

dependsOn("analyze")
dependsOn("test")
}

tasks.register("generateCode") {
dependsOn(":playground:frontend:playground_components:generateCode")

tasks.register<org.gradle.api.tasks.Exec>("generateCode") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High: dependsOn(":playground:frontend:playground_components:generateCode") was removed from generateCode, and no ordering constraint (mustRunAfter) exists between cleanFlutter and pubGet. Without the dependency on playground_components:generateCode and ordering pubGet after cleanFlutter, running generateCode can fail due to missing generated component files or race between cleaning and fetching packages.

dependsOn("cleanFlutter")
dependsOn("pubGet")

group = "build"
description = "Generate code"

doLast {
exec {
executable("flutter")
args("pub", "run", "build_runner", "build", "--delete-conflicting-outputs")
}
}
commandLine(
"flutter", "pub", "run", "build_runner", "build",
"--delete-conflicting-outputs"
)
}

tasks.register("cleanFlutter") {
tasks.register<org.gradle.api.tasks.Exec>("cleanFlutter") {
group = "build"
description = "Remove build artifacts"
commandLine("flutter", "clean")
}

doLast {
exec {
executable("flutter")
args("clean")
val deleteFilesByRegExp: (String) -> Unit = { re ->
val regex = Regex(re)
val matchedFiles = listOf("assets", "lib", "test").flatMap { directory ->
val base = file(directory)
if (base.exists()) {
fileTree(base).files.filter {
regex.matches(it.relativeTo(base).invariantSeparatorsPath)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium: Previously, find assets lib test -regex ... matched against paths prefixed with the directory name (e.g. lib/foo.g.dart). Using it.relativeTo(base) strips the directory prefix (producing foo.g.dart), and println(it) now prints absolute File paths instead of relative paths. While the current patterns start with .*, using it.relativeTo(projectDir).invariantSeparatorsPath would preserve the original regex matching semantics and output format.

Suggested change
regex.matches(it.relativeTo(base).invariantSeparatorsPath)
regex.matches(it.relativeTo(projectDir).invariantSeparatorsPath)

}
} else {
emptyList()
}
}
}.distinct()

matchedFiles.forEach { println(it) }
delete(matchedFiles)
}

tasks.register("cleanGenerated") {
dependsOn(":playground:frontend:playground_components:cleanGenerated")

group = "build"
description = "Remove build artifacts"

doLast {
println("Deleting:")

deleteFilesByRegExp(".*\\.g\\.dart\$")
deleteFilesByRegExp(".*\\.gen\\.dart\$")
deleteFilesByRegExp(".*\\.mocks\\.dart\$")
}
}

val deleteFilesByRegExp: (String) -> Unit = { re ->
// Prints file names.
exec {
executable("find")
args("assets", "lib", "test", "-regex", re)
}
// Actually deletes them.
exec {
executable("find")
args("assets", "lib", "test", "-regex", re, "-delete")
deleteFilesByRegExp(".*\\.g\\.dart$")
deleteFilesByRegExp(".*\\.gen\\.dart$")
deleteFilesByRegExp(".*\\.mocks\\.dart$")
}
}

Expand All @@ -160,30 +117,24 @@ tasks.register("integrationTest") {
dependsOn("integrationTest_welcome_page")
}

tasks.register("integrationTest_tour_page") {
doLast {
runIntegrationTest("tour_page", "/")
}
}
val integrationDeviceId = providers.gradleProperty("deviceId").getOrElse("chrome")

tasks.register("integrationTest_welcome_page") {
doLast {
runIntegrationTest("welcome_page", "/")
}
tasks.register<org.gradle.api.tasks.Exec>("integrationTest_tour_page") {
commandLine(
"flutter", "drive",
"--driver=test_driver/integration_test.dart",
"--target=integration_test/tour_page_test.dart",
"--web-launch-url='/'",
"--device-id=$integrationDeviceId"
)
}

fun runIntegrationTest(path: String, url: String) {
// Run with -PdeviceId=web-server for headless tests.
val deviceId: String = if (project.hasProperty("deviceId")) project.property("deviceId") as String else "chrome"

exec {
executable = "flutter"
args(
"drive",
"--driver=test_driver/integration_test.dart",
"--target=integration_test/${path}_test.dart",
"--web-launch-url='$url'",
"--device-id=$deviceId",
)
}
tasks.register<org.gradle.api.tasks.Exec>("integrationTest_welcome_page") {
commandLine(
"flutter", "drive",
"--driver=test_driver/integration_test.dart",
"--target=integration_test/welcome_page_test.dart",
"--web-launch-url='/'",
"--device-id=$integrationDeviceId"
)
}
Loading
Loading