What Gradle task is equivalent to the jib task's dependencies?

50 views Asked by At

We are looking into migrating our Docker builds to using the Jib Gradle plugin.

In CI, we'd like to make sure we don't push any Docker images to our registry until all of our tests in our repo have passed, which suggests we should have CI first run gradle test, and then run gradle jib.

However, it would be nice to do as much of the "build" part as possible in parallel with the test step. Ideally, we'd like to make sure that we run every task that jib depends on as part of the first gradle run.

We are not using WAR or the 'packaged' containerizing mode, so it looks like Jib gets its dependencies from this code:

          SourceSet mainSourceSet =
              projectAfterEvaluation
                  .getExtensions()
                  .getByType(SourceSetContainer.class)
                  .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
          jibDependencies.add(mainSourceSet.getRuntimeClasspath());
          jibDependencies.add(
              projectAfterEvaluation
                  .getConfigurations()
                  .getByName(jibExtension.getConfigurationName().get()));

So ideally we would be able to run a Gradle task that is equivalent to depending on this runtime classpath and this configuration as part of the first gradle run, so that when we run gradle jib as much as possible will be cached.

Do you have any advice for what we could run that's as close as possible to "the exact dependencies of the jib task"? Or another approach to achieving this goal?

(I figure assemble is probably close, but it would be nice to be precise.)

0

There are 0 answers