Extend Gradle


I am trying to extend the Gradle plugin and I am having difficulties checking if the project is applicable. With Maven I just used the importer extension point from the Maven plugin and did the check like this:

public boolean isApplicable(MavenProject mavenProject) {
return !mavenProject.findDependencies(GROUP_ID, ARTIFACT_ID).isEmpty();

Basically it checks if one of the dependencies of the project matches my dependency, and if it does then this is my project and the resolve() method in  MavenImporter then handles the rest. I can't seem to find where I do the same thing with Gradle. I am assuming I should use the 


extension point in the Gradle plugin, but I can't seem to figure out how I would check the dependencies. I have extended AbstractProjectResolverExtension, but I haven't found a way to access the dependencies of the project to decide if the project is mine or not, and it's not clear to me which method would be the equivalent to MavenImporter#resolve(). Are these two systems totally different? It seems like my assumption that they work the same way is incorrect.

Official comment

Maven plugin is totally different than Gradle.

Gradle plugin uses core IntelliJ external system API which was introduced to unify all such IDE integrations with external build systems.

So, you can use com.intellij.openapi.externalSystem.service.project.manage.ProjectDataService extension point, to extend Gradle plugin project import (and/or other build system plugins based on this API)

public class YourDependencyDataService extends AbstractProjectDataService<LibraryDependencyData, Module> {

public Key<LibraryDependencyData> getTargetDataKey() {
return ProjectKeys.LIBRARY_DEPENDENCY;

public void importData(@NotNull Collection<DataNode<LibraryDependencyData>> toImport,
@Nullable ProjectData projectData,
@NotNull Project project,
@NotNull IdeModifiableModelsProvider modelsProvider) {
if(projectData == null || !projectData.getOwner().equals(GradleConstants.SYSTEM_ID)) return;

for (DataNode<LibraryDependencyData> node : toImport) {
String externalName = node.getData().getExternalName();
if (externalName.startsWith(GROUP_ID + ":" + ARTIFACT_ID)) {
Set<String> paths = node.getData().getTarget().getPaths(LibraryPathType.BINARY);
final String path = ContainerUtil.getFirstItem(paths);
if (path != null) {
final Module module = modelsProvider.findIdeModule(node.getData().getOwnerModule());
if (module != null) {
setupYourFacetOrSomethingElse(module, path, modelsProvider);

Thank you, this solution works for me.


Please sign in to leave a comment.