Skip to content

Commit a56dc2e

Browse files
committed
Fail by default if junit/mockito in deps
1 parent bc879f7 commit a56dc2e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

springboot/springboot.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ def _banneddeps_rule_impl(ctx):
223223
if found_banned:
224224
ctx.actions.write(output, "FAIL", is_executable = False)
225225
fail("Found banned jars in the springboot rule [" + ctx.label.name
226-
+ "] dependency list:\n" + banned_filenames
227-
+ "\nSee the deps_banned attribute on this rule for the matched patterns.")
226+
+ "] dependency list. Filenames:\n" + banned_filenames
227+
+ "\nYou can ignore these by setting deps_banned = [] on the springboot() rule.\n")
228228
else:
229229
ctx.actions.write(output, "SUCCESS", is_executable = False)
230230
return [DefaultInfo(files = depset(outputs))]
@@ -367,7 +367,7 @@ def springboot(
367367
boot_app_class,
368368
boot_launcher_class = "org.springframework.boot.loader.JarLauncher",
369369
deps = None,
370-
deps_banned = None,
370+
deps_banned = [ "junit", "mockito", ], # detects common mistake of test dep pollution
371371
deps_exclude = None,
372372
deps_exclude_paths = None,
373373
deps_index_file = None,
@@ -409,10 +409,10 @@ def springboot(
409409
Ex: *com.sample.SampleMain*
410410
deps: Optional. An additional set of Java dependencies to add to the executable.
411411
Normally all dependencies are set on the *java_library*.
412-
deps_banned: Optional. A list of strings to match against the jar filenams in the transitive graph of
412+
deps_banned: Optional. A list of strings to match against the jar filenames in the transitive graph of
413413
dependencies for this springboot app. If any of these strings is found within any jar name, the rule will fail.
414414
This is useful for detecting jars that should never go to production. The list of dependencies is
415-
obtained after the deps_exclude processing has run.
415+
obtained after the deps_exclude processing has run. Default: [ "junit", "mockito" ]
416416
deps_exclude: Optional. A list of jar labels that will be omitted from the final packaging step.
417417
This is a manual option for eliminating a problematic dependency that cannot be eliminated upstream.
418418
Ex: *["@maven//:commons_cli_commons_cli"]*.

springboot/springboot_doc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Note that the rule README has more detailed usage instructions for each attribut
2828
| boot_app_class | **Required**. The fully qualified name of the class annotated with @SpringBootApplication. Ex: *com.sample.SampleMain* | none |
2929
| 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* |
3030
| 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> |
31-
| 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> |
31+
| 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> |
3232
| 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> |
3333
| deps_exclude_paths | <p align="center"> - </p> | <code>None</code> |
3434
| 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> |

0 commit comments

Comments
 (0)