void (String moduleName, boolean useCompileClasspathPackaging) { Module module = getModule(moduleName); String sourceSetName = getSourceSetName(module); assertNotNull("Can not find the sourceSet for the module", sourceSetName); ExternalSystemTaskExecutionSettings settings = new ExternalSystemTaskExecutionSettings(); settings.setExternalProjectPath(getExternalProjectPath(module)); String id = getExternalProjectId(module); String gradlePath = id.startsWith(":") ? trimEnd(trimEnd(id, sourceSetName), ":") : ""; settings.setTaskNames(Collections.singletonList(gradlePath + ":print" + capitalize(sourceSetName) + "CompileDependencies")); settings.setExternalSystemIdString(GradleConstants.SYSTEM_ID.getId()); settings.setScriptParameters("--quiet"); if (useCompileClasspathPackaging) { // use jars instead of class folders for everything on the compile classpath // https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_classes_usage if (isJavaLibraryPluginSupported() && isGradleOlderThan("5.6.1")) { return; } settings.setVmOptions("-Dorg.gradle.java.compile-classpath-packaging=true"); } ExternalSystemProgressNotificationManager notificationManager = ApplicationManager.getApplication().getService(ExternalSystemProgressNotificationManager.class); StringBuilder gradleClasspath = new StringBuilder(); ExternalSystemTaskNotificationListenerAdapter listener = new ExternalSystemTaskNotificationListenerAdapter() { @Override public void onTaskOutput(@NotNull ExternalSystemTaskId id, @NotNull String text, boolean stdOut) { if (!stdOut || text.isBlank()) return; if (text.contains("Gradle Daemon")) return; gradleClasspath.append(text); } }; notificationManager.addNotificationListener(listener); try { ExternalSystemUtil.runTask(settings, DefaultRunExecutor.EXECUTOR_ID, myProject, GradleConstants.SYSTEM_ID, null, ProgressExecutionMode.NO_PROGRESS_SYNC); } finally { notificationManager.removeNotificationListener(listener); } List<String> ideClasspath = new ArrayList<>(); ModuleRootManager.getInstance(module).orderEntries().withoutSdk().withoutModuleSourceEntries().compileOnly().productionOnly().forEach( entry -> { if (entry instanceof ModuleOrderEntry) { Module moduleDep = ((ModuleOrderEntry)entry).getModule(); String sourceSetDepName = getSourceSetName(moduleDep); // for simplicity, only project dependency on 'default' configuration allowed here assert "main".equals(sourceSetDepName); String gradleProjectDepName = trimStart(trimEnd(getExternalProjectId(moduleDep), ":main"), ":"); String version = getExternalProjectVersion(moduleDep); version = "unspecified".equals(version) ? "" : "-" + version; ideClasspath.add(gradleProjectDepName + version + ".jar"); } else { ideClasspath.add(entry.getFiles(OrderRootType.CLASSES)[0].getName()); } return true; }); assertEquals(join(ideClasspath, " "), gradleClasspath.toString().trim()); }