Skip to content

Commit

Permalink
[internal] add JvmToolBase for lockfile handling for JVM tools (#13777
Browse files Browse the repository at this point in the history
)

Add `JvmToolBase` as base class for subsystems that handle lockfiles for JVM tools. Adds `jvm-generate-lockfiles` goal for rebuilding JVM tool lockfiles.

Port the junit test goal to use `JvmToolBase`.
  • Loading branch information
Tom Dyas authored Dec 4, 2021
1 parent 4b64c83 commit d1486c4
Show file tree
Hide file tree
Showing 9 changed files with 1,109 additions and 58 deletions.
3 changes: 2 additions & 1 deletion src/python/pants/backend/experimental/java/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pants.jvm import util_rules as jvm_util_rules
from pants.jvm.dependency_inference import symbol_mapper
from pants.jvm.goals import coursier
from pants.jvm.resolve import coursier_fetch, coursier_setup
from pants.jvm.resolve import coursier_fetch, coursier_setup, jvm_tool
from pants.jvm.target_types import JvmArtifact, JvmDependencyLockfile


Expand Down Expand Up @@ -53,4 +53,5 @@ def rules():
*jvm_util_rules.rules(),
*jdk_rules.rules(),
*target_types_rules(),
*jvm_tool.rules(),
]
3 changes: 2 additions & 1 deletion src/python/pants/backend/experimental/scala/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pants.jvm import classpath, jdk_rules
from pants.jvm import util_rules as jvm_util_rules
from pants.jvm.goals import coursier
from pants.jvm.resolve import coursier_fetch, coursier_setup
from pants.jvm.resolve import coursier_fetch, coursier_setup, jvm_tool
from pants.jvm.target_types import JvmArtifact, JvmDependencyLockfile


Expand Down Expand Up @@ -55,4 +55,5 @@ def rules():
*jdk_rules.rules(),
*dep_inf_rules.rules(),
*target_types_rules(),
*jvm_tool.rules(),
]
16 changes: 13 additions & 3 deletions src/python/pants/backend/java/subsystems/junit.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from pants.jvm.resolve.jvm_tool import JvmToolBase
from pants.option.custom_types import shell_str
from pants.option.subsystem import Subsystem
from pants.util.docutil import git_url


class JUnit(Subsystem):
class JUnit(JvmToolBase):
options_scope = "junit"
help = "The JUnit test framework (https://junit.org)"

default_version = "5.7.2"
default_artifacts = [
"org.junit.platform:junit-platform-console:1.7.2",
"org.junit.jupiter:junit-jupiter-engine:{version}",
"org.junit.vintage:junit-vintage-engine:{version}",
]
default_lockfile_resource = ("pants.backend.java.test", "junit.default.lockfile.txt")
default_lockfile_path = "src/python/pants/backend/java/test/junit.default.lockfile.txt"
default_lockfile_url = git_url(default_lockfile_path)

@classmethod
def register_options(cls, register):
super().register_options(register)
Expand Down
4 changes: 3 additions & 1 deletion src/python/pants/backend/java/test/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_sources()
python_sources(dependencies=[":lockfiles"])
python_tests(name="tests", timeout=240)

resources(name="lockfiles", sources=["*.lockfile.txt"])
Loading

0 comments on commit d1486c4

Please sign in to comment.