Project dependency refers to compiled classes not JAR

I setup a multi-project build. Let’s call my two projects “lib” and “app”. “app” requires services registered through META-INF/services generated from “lib”. It needs to be able to find the JAR generated from “lib” to build up a custom classpath.

Here’s an excerpt of the build.gradle.kts file of “app”.

dependencies {

tasks.create<MyTask>("doSomething") {
    addCompileClasspath = true


In a Gradle plugin I’m also writing, I need to get the Java compile classpath. I get it from within my plugin like this (Java code):


When I dump this out as a classpath, it points to only the compiled classes and not the generated JAR:


This directory does not contain resources or the relevant META-INF/services file, so my services aren’t found when executing “app”.

Why am I getting the compiled classes and not the JAR?

More details if needed:

My settings.gradle.kts looks like this: = "foo"

Then root build.gradle.kts is pretty minimal. Looks like this:

allprojects {
    repositories {

Note that “lib” applies the java-library plugin while app does not.

When I dump this out as a classpath, it points to only the compiled classes

This is desired/expected behavior


Attaching to the “build” task seems a bit late in the lifecycle. Have you considered using the “classes” or “processResources” tasks instead?


Try printing sourceSets.main.output or sourceSets.main.runtimeClasspath these will include the classes directory and the processed resource directory.

If it were me I’d attach the logic to the processResources task


apply plugin: 'java-library' 
task generateResources {
   dependsOn compileJava 
   outputs.dir "$buildDir/generated/resources" 
   doLast {...} 
processResources {
   from generateResources