Set<File> (@NotNull SourceSet sourceSet, String... languages) { List<String> jvmLanguages = Lists.newArrayList(languages); final String sourceSetCompileTaskPrefix = sourceSet.getName().equals("main") ? "" : sourceSet.getName(); List<String> compileTaskNames = new ArrayList<>(jvmLanguages.size()); for (String language : jvmLanguages) { compileTaskNames.add("compile" + capitalize(sourceSetCompileTaskPrefix) + language); } Set<File> compileClasspathFiles = new LinkedHashSet<>(); for (String task : compileTaskNames) { Task compileTask = myProject.getTasks().findByName(task); if (compileTask instanceof AbstractCompile) { try { List<File> files = new ArrayList<>(((AbstractCompile)compileTask).getClasspath().getFiles()); // TODO is this due to ordering? files.removeAll(compileClasspathFiles); compileClasspathFiles.addAll(files); } catch (Exception e) { // ignore } } } try { compileClasspathFiles = compileClasspathFiles.isEmpty() ? new LinkedHashSet<>(sourceSet.getCompileClasspath().getFiles()) : compileClasspathFiles; } catch (Exception e) { // ignore } return compileClasspathFiles; }