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
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ tasks.rat {
// Ignore poetry autogenerated files.
"**/poetry.lock",

// Ignore Cargo lock files.
"sdks/rust/Cargo.lock",

// DuetAI training prompts
"learning/prompts/**/*.md",

Expand Down
4 changes: 4 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,9 @@ gradlePlugin {
id = "org.apache.beam.vendor-java"
implementationClass = "org.apache.beam.gradle.VendorJavaPlugin"
}
create("beamRust") {
id = "org.apache.beam.rust"
implementationClass = "org.apache.beam.gradle.rust.BeamRustPlugin"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.beam.gradle.rust

import groovy.transform.CompileStatic
import org.apache.beam.gradle.BeamModulePlugin
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.Exec

/**
* The build of the Rust SDK ({@code :sdks:rust}).
*
* <p>Cargo does the work. The tasks give maintainers the same commands as the other SDKs:
* {@code build}, {@code check}, {@code test}, {@code fmt} and {@code clean}.
*/
@CompileStatic
class BeamRustPlugin implements Plugin<Project> {

@Override
void apply(Project project) {
// BeamModulePlugin sets the project version and adds the lifecycle tasks.
project.pluginManager.apply(BeamModulePlugin)

RustSdkExtension extension = project.extensions.create('rustSdk', RustSdkExtension)
extension.benchmarkPackages.convention(new ArrayList<String>())
extension.benchmarkPackages.finalizeValueOnRead()

RustSdkBuild build = new RustSdkBuild(project, extension)
Map<String, String> cargoEnv = build.versions.cargoEnv()
project.tasks.withType(Exec).configureEach { Exec task -> task.environment(cargoEnv) }

RustLintTasks.register(build)
RustTestTasks.register(build)

project.tasks.named('build').configure { Task task -> task.dependsOn('buildWorkspace') }
project.tasks.named('check').configure { Task task -> task.dependsOn('fmtCheck', 'clippy') }
project.tasks.named('clean').configure { Task task -> task.dependsOn('cleanSdk') }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.beam.gradle.rust

import groovy.transform.CompileStatic
import org.gradle.api.Project

/**
* The Beam versions that each cargo command gets.
*
* <p>All come from gradle.properties, which release/src/main/scripts/set_version.sh bumps.
* A plain {@code cargo} build reads the same keys, so both paths report the same version.
*/
@CompileStatic
class BeamVersions {
/** The Gradle project version, for example X.Y.Z-SNAPSHOT. {@code -Pver} overrides it. */
final String beamVersion
/** The release that it becomes, for example X.Y.Z. {@code -PbeamReleaseVersion} overrides it. */
final String releaseVersion
/** The SDK version in binaries and container tags, for example X.Y.Z.dev. */
final String sdkVersion

BeamVersions(Project project) {
beamVersion = (project.findProperty('ver') ?: project.version).toString()
releaseVersion = (project.findProperty('beamReleaseVersion')
?: beamVersion.replace('-SNAPSHOT', '')).toString()
sdkVersion = project.property('sdk_version').toString()
}

/** The environment variables that carry the versions to cargo. */
Map<String, String> cargoEnv() {
return [
BEAM_SDK_VERSION : sdkVersion,
BEAM_RELEASE_VERSION: releaseVersion,
BEAM_VERSION : beamVersion,
]
}
}
Loading
Loading