forked from eclipse-score/score
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dash: Integrate DASH tool in Bazel build
This commit adds support for the DASH tool within the S-CORE Bazel build system. The integration includes: - Defining custom Bazel rules to handle the DASH tool's setup and execution. - Adding necessary dependencies in BUILD files to ensure compatibility with existing project requirements. - Validating the integration with the current CI pipeline to maintain a seamless build and deployment process. - Updating documentation (if applicable) to reflect the addition of DASH in the Bazel workflow. This enhancement simplifies the workflow by consolidating tools into the Bazel build system, improving build automation and traceability. Issue-ref: see eclipse-score#126
- Loading branch information
1 parent
872caac
commit 6f9fd0f
Showing
8 changed files
with
422 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
test --test_output=errors | ||
|
||
build --java_language_version=17 | ||
build --tool_java_language_version=17 | ||
build --java_runtime_version=remotejdk_17 | ||
build --tool_java_runtime_version=remotejdk_17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# ******************************************************************************* | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License Version 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# ******************************************************************************* | ||
|
||
load("//tools/dash:dash.bzl", "dash_license_checker") | ||
|
||
dash_license_checker( | ||
name = "check_python_licenses", | ||
src = "//docs:requirements_lock", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# ******************************************************************************* | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License Version 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# ******************************************************************************* | ||
|
||
load("@rules_java//java:java_binary.bzl", "java_binary") | ||
load("//tools/dash/formatters:dash_format_converter.bzl", "dash_format_converter") | ||
|
||
def dash_license_checker( | ||
name, | ||
src, | ||
visibility): | ||
""" | ||
Defines a Bazel macro for creating a `java_binary` target that integrates the DASH license checker. | ||
Args: | ||
name (str): | ||
The name of the `java_binary` target to be created. This will serve as the identifier | ||
for the generated Bazel target. | ||
src (str): | ||
The path to the dependency list file required by the DASH license checker. | ||
This file should specify the dependencies to be validated. | ||
visibility (list[str]): | ||
A list defining the visibility of the created target. It determines which packages | ||
can depend on this target. | ||
This macro simplifies the process of setting up the DASH license checker by creating a reusable | ||
`java_binary` target that adheres to the Bazel build rules and supports consistent license | ||
validation across projects. | ||
""" | ||
dash_format_converter( | ||
name = "formatted_deps", | ||
requirement_file = src, | ||
) | ||
|
||
java_binary( | ||
name = name, | ||
main_class = "org.eclipse.dash.licenses.cli.Main", | ||
runtime_deps = [ | ||
"@dash_license_tool//jar", | ||
], | ||
args = ["$(location :formatted_deps)"], | ||
data = [ | ||
":formatted_deps", | ||
], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# ******************************************************************************* | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License Version 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# ******************************************************************************* | ||
|
||
py_binary( | ||
name = "dash_format_converter", | ||
srcs = [ | ||
"dash_format_converter.py", | ||
], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# ******************************************************************************* | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License Version 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# ******************************************************************************* | ||
|
||
""" Bazel rule for generating dash formatted requirements file | ||
""" | ||
|
||
def _impl(ctx): | ||
""" The implementation function of the rule. | ||
""" | ||
|
||
output = ctx.actions.declare_file("formatted.txt") | ||
args = ctx.actions.args() | ||
args.add("-i", ctx.file.requirement_file) | ||
args.add("-o", output) | ||
|
||
ctx.actions.run( | ||
inputs = [ctx.file.requirement_file], | ||
outputs = [output], | ||
arguments = [args], | ||
progress_message = "Generating Dash formatted dependency file ...", | ||
mnemonic = "DashFormat", | ||
executable = ctx.executable._tool, | ||
) | ||
return DefaultInfo(files = depset([output])) | ||
|
||
dash_format_converter = rule( | ||
implementation = _impl, | ||
attrs = { | ||
"requirement_file": attr.label( | ||
mandatory = True, | ||
allow_single_file = True, | ||
doc = "The requirement (requirement_lock.txt) input file which holds deps", | ||
), | ||
"_tool": attr.label( | ||
default = Label("//tools/dash/converters:dash_format_converter"), | ||
executable = True, | ||
cfg = "exec", | ||
doc = "", | ||
), | ||
}, | ||
) |
Oops, something went wrong.