0

For my java plugin I'm using a non-default sourceset. How do I tell jib that's where my source files are? With my gradle file as shown below jib responds with:

> Task :jib FAILED
No classes files were found - did you compile your project?

I see that jib defaults to 'main' as the sourceset name - is there a way to override that? https://github.com/GoogleContainerTools/jib/blob/master/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java#L96

apply plugin: "java-library"
apply plugin: "com.google.cloud.tools.jib"

sourceSets {
  custom {
    java {
      srcDirs = ["src"]
    }
  }
}

jib {
  to {
    image = "foo"
  }
}

if I change custom to main in the above, it works fine.

ray
  • 61
  • 6

1 Answers1

1

The plugin does not give you any option to specify which source set to use. So your only option is to ensure your custom source set is added to main:

For example, assuming your custom source set is named custom, something like:

sourceSets {
    main {
        java {
            compileClasspath += sourceSets.custom.output
            runtimeClasspath += sourceSets.custom.output
        }
    }
}
Cisco
  • 20,972
  • 5
  • 38
  • 60
  • That is an option I considered, but I had two concerns: one, are there any other attributes of 'java' I need to copy over (besides compileClasspath and runtimeClasspath)? And two, I did not have immediate success with it because the project is actually comprised of many sub-projects and I got the impression I would have to modify their build files as well as the main one. But I appreciate the confirmation and I will pursue it further. – ray Aug 09 '21 at 23:28