Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: graalvm artifact mappings #106

Merged
merged 3 commits into from
Sep 8, 2023
Merged
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
8 changes: 8 additions & 0 deletions .github/workflows/module.build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ jobs:
labs: false
skip: false

# Test: Maven Artifacts
- label: Maven Artifacts
target: sample
action: build
directory: "./example/integration_tests/maven-artifacts"
labs: false
skip: false

# Test: Legacy Rules
- label: Legacy Rules
target: sample
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions docs/api/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ bzl_library(
],
)

stardoc(
name = "artifacts",
out = "artifacts.md",
input = "//graalvm/artifacts:maven.bzl",
deps = [
":repo_tools",
],
)

stardoc(
name = "defs",
out = "defs.md",
Expand Down
116 changes: 116 additions & 0 deletions docs/api/artifacts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<!-- Generated with Stardoc: http://skydoc.bazel.build -->

Defines Maven helpers and coordinates for GraalVM artifacts.

<a id="graalvm.artifact"></a>

## graalvm.artifact

<pre>
graalvm.artifact(<a href="#graalvm.artifact-maven">maven</a>, <a href="#graalvm.artifact-artifact">artifact</a>, <a href="#graalvm.artifact-version">version</a>)
</pre>

Helper which declares a Maven artifact using `rules_jvm_external` macros for the provided inputs.

Any struct can be provided as `artifact` which has the `artifact` and `group` properties. For
convenience, well-known GraalVM artifact coordinates are available at `graalvm.catalog`.

Example of use from `WORKSPACE.bazel`:

```starlark
load("@rules_jvm_external//:specs.bzl", "maven")
load("@rules_graalvm//artifacts:maven.bzl", "graalvm")

# ...
graalvm.artifact(
maven,
artifact = graalvm.catalog.SDK,
version = "23.0.1",
)
```

Example of use from Bzlmod:

```starlark
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
graalvm = use_extension("@rules_graalvm//:extensions.bzl", "graalvm")

# ...
graalvm.artifact(
maven,
artifact = graalvm.catalog.SDK,
version = "23.0.1",
)
```


**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="graalvm.artifact-maven"></a>maven | Maven artifact spawn struct provided by `rules_jvm_external`. | none |
| <a id="graalvm.artifact-artifact"></a>artifact | Artifact to use from `MavenArtifacts`, or a `struct` with `artifact` and `group`. | none |
| <a id="graalvm.artifact-version"></a>version | Version of the artifact to declare. | none |

**RETURNS**

Maven artifact specification.


<a id="graalvm_maven_artifact"></a>

## graalvm_maven_artifact

<pre>
graalvm_maven_artifact(<a href="#graalvm_maven_artifact-maven">maven</a>, <a href="#graalvm_maven_artifact-artifact">artifact</a>, <a href="#graalvm_maven_artifact-version">version</a>)
</pre>

Helper which declares a Maven artifact using `rules_jvm_external` macros for the provided inputs.

Any struct can be provided as `artifact` which has the `artifact` and `group` properties. For
convenience, well-known GraalVM artifact coordinates are available at `graalvm.catalog`.

Example of use from `WORKSPACE.bazel`:

```starlark
load("@rules_jvm_external//:specs.bzl", "maven")
load("@rules_graalvm//artifacts:maven.bzl", "graalvm")

# ...
graalvm.artifact(
maven,
artifact = graalvm.catalog.SDK,
version = "23.0.1",
)
```

Example of use from Bzlmod:

```starlark
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
graalvm = use_extension("@rules_graalvm//:extensions.bzl", "graalvm")

# ...
graalvm.artifact(
maven,
artifact = graalvm.catalog.SDK,
version = "23.0.1",
)
```


**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="graalvm_maven_artifact-maven"></a>maven | Maven artifact spawn struct provided by `rules_jvm_external`. | none |
| <a id="graalvm_maven_artifact-artifact"></a>artifact | Artifact to use from `MavenArtifacts`, or a `struct` with `artifact` and `group`. | none |
| <a id="graalvm_maven_artifact-version"></a>version | Version of the artifact to declare. | none |

**RETURNS**

Maven artifact specification.


1 change: 1 addition & 0 deletions example/integration_tests/maven-artifacts/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# No options at this time.
1 change: 1 addition & 0 deletions example/integration_tests/maven-artifacts/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.0-pre.20230816.3
1 change: 1 addition & 0 deletions example/integration_tests/maven-artifacts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazel-*
70 changes: 70 additions & 0 deletions example/integration_tests/maven-artifacts/WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
workspace(name = "rules_graalvm_sample")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

## -- rules_graalvm

local_repository(
name = "rules_graalvm",
path = "../../..",
)

GRAALVM_VERSION = "23.0.1"
GRAALVM_JAVA_VERSION = "20.0.2"

load("@rules_graalvm//graalvm:workspace.bzl", "register_graalvm_toolchains", "rules_graalvm_repositories")

rules_graalvm_repositories()

register_graalvm_toolchains(register_gvm_toolchain = False)

load("@rules_graalvm//graalvm:repositories.bzl", "graalvm_repository")

graalvm_repository(
name = "graalvm",
distribution = "ce",
java_version = "20",
version = GRAALVM_JAVA_VERSION,
components = [
"js",
],
)

## -- rules_jvm_external

RULES_JVM_EXTERNAL_TAG = "4.5"
RULES_JVM_EXTERNAL_SHA = "b17d7388feb9bfa7f2fa09031b32707df529f26c91ab9e5d909eb1676badd9a6"

http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

load("@rules_jvm_external//:defs.bzl", "maven_install")

load("@rules_jvm_external//:specs.bzl", "maven")

load("@rules_graalvm//graalvm/artifacts:maven.bzl", "graalvm")

maven_install(
artifacts = [
graalvm.artifact(
maven,
artifact = graalvm.catalog.SDK,
version = GRAALVM_VERSION,
),
],
repositories = [
"https://maven.pkg.st",
],
)
26 changes: 26 additions & 0 deletions example/integration_tests/maven-artifacts/sample/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@rules_graalvm//graalvm/artifacts:maven.bzl", graalvm = "alias")

java_library(
name = "java",
srcs = ["Main.java"],
deps = [
graalvm.artifact(graalvm.catalog.SDK), # equivalent to targets below
],
)

java_binary(
name = "main",
main_class = "Main",
runtime_deps = [
":java",
"@maven//:org_graalvm_sdk_graal_sdk",

# also equivalent to targets above
# graalvm.alias("org.graalvm.sdk", "graal-sdk"),
],
)

alias(
name = "sample",
actual = "main",
)
9 changes: 9 additions & 0 deletions example/integration_tests/maven-artifacts/sample/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

import org.graalvm.home.Version;


public class Main {
public static void main(String args[]) {
System.out.println("Hello, GraalVM: " + Version.getCurrent().toString());
}
}
6 changes: 5 additions & 1 deletion graalvm/artifacts/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Nothing at this time.
package(default_visibility = ["//visibility:public"])

exports_files([
"maven.bzl",
])
Loading
Loading