Does the java-library plugin actually do anything Gradle can't do natively?

Hello everyone,

I’m using Gradle 6.0.1 and I had Gradle generate a default Kotlin library project for me, which adds the java-library plugin. According to the documentation, this adds the implementation() and api() functions to use in the dependencies block. However, even if I remove this plugin, I am still able to call both api() and implementation() and run all tasks normally. In other words, it doesn’t actually seem the plugin is doing anything, which seems strange. Am I missing something?

Kind regards,


For anyone interested:

In other words, apart from marking certain configurations as deprecated, it behaves exactly like the Java plugin. Since the Kotlin plugin extends the Java plugin (, it seem that including java-library in a Kotlin project is redundant from a functionality standpoint.

I will add however that I was mistaken in the OP when I implied that Gradle includes the api/implementation functions natively - it is the Java (and therefore Kotlin) plugin that does that.

This is not quite correct.

The Java plugin adds the ability to declare dependencies on the implementation configuration, but not the api configuration. It does add the ability to properly consume other modules that have api dependencies though (it adds the apiElements configuration for this).

The Kotlin plugin itself is actually adding the api configuration that you can add dependencies to and it does set up a few additional items if the java-library plugin is applied. Will you notice the difference? Depending on what you are doing, maybe not.

1 Like

Hey James,

thank you very much for the insight. I went through the source of the Kotlin plugin and could only find this part of the code, but I couldn’t figure out what it does - do you know?

I recently wrote an article on Medium where I mentioned this. I added your input to the relevant section.

Thanks again!


When you use the Java Library plugin, consumers (which resolve the apiElements configuration) only have the classes directory (not the entire JAR) put on the compilation classpath. This code is registering the output directory for the compiled Kotlin classes as an additional artifact as well as that it is built by the Kotlin compilation task. This causes the Kotlin compilation to correctly occur before the other project uses the result of resolving apiElements for its own compilation.

1 Like