Java plugin generated configurations default visibility is false

The java plugin dynamically generates configurations for source sets. In 2.12 these are:

  • compile
  • runtime
  • testCompile
  • testRuntime

Per the code in JavaBasePlugin.defineConfigurationsForSourceSet all four have their visibility defaulted to false.

There might be a good reason for defaulting to false that I can’t think of. Based on experience with dependency management and my opinion I think the following visibility defaults may be more appropriate:

  • compile - true
  • runtime - true
  • testCompile - false
  • testRuntime - false

Right now in order to change the visibility the configurations must be configured (with maybeCreate for safety) and done so in an order-sensitive way to override the false that is set by the generation code.

I make use of visibility for custom code for generating ivy files and setting the “visibility” attribute on “conf” elements. I do not believe the current version of gradle supports this out of the box yet.