public static FileCollection generatePathingJar(final Project project, final String taskName, final FileCollection classpath,
    boolean alwaysUsePathingJar) throws IOException {
    //There is a bug in the Scala nsc compiler that does not parse the dependencies of JARs in the JAR manifest
    //As such, we disable pathing for any libraries compiling docs for Scala resources
    if (!alwaysUsePathingJar && !classpath.filter(f -> f.getAbsolutePath().contains("restli-tools-scala")).isEmpty()) {
      LOG.info("Compiling Scala resource classes. Disabling pathing jar for " + taskName + " to avoid breaking Scala compilation");
      return classpath;
    }

    //We extract the classpath from the target task here, in the configuration phase
    //Note that we don't invoke getFiles() here because that would trigger dependency resolution in configuration phase
    FileCollection filteredClasspath = classpath.filter(f -> !f.isDirectory());
    File destinationDir = new File(project.getBuildDir(), taskName);
    destinationDir.mkdirs();
    File pathingJarPath = new File(destinationDir, project.getName() + "-pathing.jar");
    OutputStream pathingJar = new FileOutputStream(pathingJarPath);

    //Classpath manifest does not support directories and needs to contain relative paths
    String cp = ClasspathManifest.relativeClasspathManifest(destinationDir, filteredClasspath.getFiles());

    //Create the JAR
    Manifest manifest = new Manifest();
    manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
    manifest.getMainAttributes().put(Attributes.Name.CLASS_PATH, cp);
    JarOutputStream jarOutputStream = new JarOutputStream(pathingJar, manifest);
    jarOutputStream.close();

    return classpath.filter(File::isDirectory).plus(project.files(pathingJarPath));
  }
@Test
  public void testCreatesGeneratesPathingJar() throws IOException
  {
    //setup
    createTempDir();
    Project project = ProjectBuilder.builder().withProjectDir(temp).build();
    String taskName = "myTaskName";
    project.getBuildDir().mkdir();
    System.out.println(project.getBuildDir().getAbsolutePath());
    File tempFile = new File(project.getBuildDir(), "temp1.class");
    GFileUtils.touch(tempFile);
    FileCollection files = project.files(tempFile);

    //when
    PathingJarUtil.generatePathingJar(project, taskName, files, true);
    File pathingJar = new File(project.getBuildDir(), taskName + '/' + project.getName() + "-pathing.jar");
    assertTrue(pathingJar.exists());
    JarInputStream jarStream = new JarInputStream(new FileInputStream(pathingJar));
    Manifest manifest = jarStream.getManifest();
    assertTrue(manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH).contains("temp1.class"));

    cleanupTempDir();
  }