Skip to content

Fail by default if junit/mockito in deps #208

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

Merged
merged 1 commit into from
Oct 29, 2024
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
10 changes: 5 additions & 5 deletions springboot/springboot.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ def _banneddeps_rule_impl(ctx):
if found_banned:
ctx.actions.write(output, "FAIL", is_executable = False)
fail("Found banned jars in the springboot rule [" + ctx.label.name
+ "] dependency list:\n" + banned_filenames
+ "\nSee the deps_banned attribute on this rule for the matched patterns.")
+ "] dependency list. Filenames:\n" + banned_filenames
+ "\nYou can ignore these by setting deps_banned = [] on the springboot() rule.\n")
else:
ctx.actions.write(output, "SUCCESS", is_executable = False)
return [DefaultInfo(files = depset(outputs))]
Expand Down Expand Up @@ -367,7 +367,7 @@ def springboot(
boot_app_class,
boot_launcher_class = "org.springframework.boot.loader.JarLauncher",
deps = None,
deps_banned = None,
deps_banned = [ "junit", "mockito", ], # detects common mistake of test dep pollution
deps_exclude = None,
deps_exclude_paths = None,
deps_index_file = None,
Expand Down Expand Up @@ -409,10 +409,10 @@ def springboot(
Ex: *com.sample.SampleMain*
deps: Optional. An additional set of Java dependencies to add to the executable.
Normally all dependencies are set on the *java_library*.
deps_banned: Optional. A list of strings to match against the jar filenams in the transitive graph of
deps_banned: Optional. A list of strings to match against the jar filenames in the transitive graph of
dependencies for this springboot app. If any of these strings is found within any jar name, the rule will fail.
This is useful for detecting jars that should never go to production. The list of dependencies is
obtained after the deps_exclude processing has run.
obtained after the deps_exclude processing has run. Default: [ "junit", "mockito" ]
deps_exclude: Optional. A list of jar labels that will be omitted from the final packaging step.
This is a manual option for eliminating a problematic dependency that cannot be eliminated upstream.
Ex: *["@maven//:commons_cli_commons_cli"]*.
Expand Down
2 changes: 1 addition & 1 deletion springboot/springboot_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Note that the rule README has more detailed usage instructions for each attribut
| boot_app_class | **Required**. The fully qualified name of the class annotated with @SpringBootApplication. Ex: *com.sample.SampleMain* | none |
| boot_launcher_class | **Optional**. Allows you to switch to the new *org.springframework.boot.loader.launch.JarLauncher* introduced in Boot 3.2.0. Defaults to the old launcher. | *org.springframework.boot.loader.JarLauncher* |
| deps | Optional. An additional set of Java dependencies to add to the executable. Normally all dependencies are set on the *java_library*. | <code>None</code> |
| deps_banned| Optional. A list of strings to match against the jar filenames in the transitive graph of dependencies for this springboot app. If any of these strings is found within any jar name, the rule will fail. This is useful for detecting jars that should never go to production. The list of dependencies is obtained after the deps_exclude processing has run. | <code>None</code> |
| deps_banned| Optional. A list of strings to match against the jar filenames in the transitive graph of dependencies for this springboot app. If any of these strings is found within any jar name, the rule will fail. This is useful for detecting jars that should never go to production. The list of dependencies is obtained after the deps_exclude processing has run. | <code>[ "junit", "mockito" ]</code> |
| deps_exclude | Optional. This attribute provides a list of partial paths that will be omitted from the final packaging step if the string is contained within the dep filename. This is a more raw method than deps_exclude for eliminating a problematic dependency/file that cannot be eliminated upstream. Ex: [*jackson-databind-*]. | <code>None</code> |
| deps_exclude_paths | <p align="center"> - </p> | <code>None</code> |
| deps_index_file | Optional. Uses Spring Boot's [classpath index feature](https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-executable-jar-format.html#executable-jar-war-index-files-classpath) to define classpath order. This feature is not commonly used, as the application must be extracted from the jar file for it to work. Ex: *my_classpath_index.idx* | <code>None</code> |
Expand Down