This is an automated email from the ASF dual-hosted git repository.

jdaugherty pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/grails-intellij-plugin.git

commit dccceea786ae8c31c555a5a3c73b54a9b9df6b73
Author: James Daugherty <[email protected]>
AuthorDate: Sat Jul 18 21:26:56 2026 -0400

    Port Maven importer to MavenWorkspaceConfigurator
---
 maven/resources/intellij.groovy.grails.maven.xml   |  5 +-
 .../groovy/grails/maven/GrailsMavenImporter.java   | 81 ----------------------
 .../maven/GrailsMavenWorkspaceConfigurator.kt      | 36 ++++++----
 3 files changed, 28 insertions(+), 94 deletions(-)

diff --git a/maven/resources/intellij.groovy.grails.maven.xml 
b/maven/resources/intellij.groovy.grails.maven.xml
index 404c188..73942af 100644
--- a/maven/resources/intellij.groovy.grails.maven.xml
+++ b/maven/resources/intellij.groovy.grails.maven.xml
@@ -21,11 +21,14 @@
 
   <extensions defaultExtensionNs="org">
     <intellij.grails.commandExecutor 
implementation="com.intellij.groovy.grails.maven.MavenCommandExecutor" 
order="FIRST"/>
-    <jetbrains.idea.maven.importer 
implementation="com.intellij.groovy.grails.maven.GrailsMavenImporter" 
order="after web"/>
     <intellij.grails.applicationProvider 
implementation="com.intellij.groovy.grails.maven.GrailsMavenApplicationProvider"
 order="first"/>
     <intellij.grails.viewNodeProvider 
implementation="com.intellij.groovy.grails.maven.MavenNodeProvider"/>
   </extensions>
 
+  <extensions defaultExtensionNs="org.jetbrains.idea.maven.importing">
+    <workspaceConfigurator 
implementation="com.intellij.groovy.grails.maven.GrailsMavenWorkspaceConfigurator"/>
+  </extensions>
+
   <extensions defaultExtensionNs="com.intellij">
     <programRunner 
implementation="com.intellij.groovy.grails.maven.GrailsMavenDebuggerRunner" 
order="before grailsDebuggerRunner"/>
   </extensions>
diff --git 
a/maven/src/com/intellij/groovy/grails/maven/GrailsMavenImporter.java 
b/maven/src/com/intellij/groovy/grails/maven/GrailsMavenImporter.java
deleted file mode 100644
index ac315ad..0000000
--- a/maven/src/com/intellij/groovy/grails/maven/GrailsMavenImporter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2000-2026 JetBrains s.r.o. and contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.intellij.groovy.grails.maven;
-
-import com.intellij.facet.ModifiableFacetModel;
-import 
com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider;
-import com.intellij.openapi.module.Module;
-import com.intellij.util.Consumer;
-import com.intellij.util.PairConsumer;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.idea.maven.importing.MavenImporter;
-import org.jetbrains.idea.maven.importing.MavenRootModelAdapter;
-import org.jetbrains.idea.maven.project.MavenProject;
-import org.jetbrains.idea.maven.project.MavenProjectChanges;
-import org.jetbrains.idea.maven.project.MavenProjectsProcessorTask;
-import org.jetbrains.idea.maven.project.MavenProjectsTree;
-import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
-import org.jetbrains.plugins.grails.config.GrailsFramework;
-import org.jetbrains.plugins.grails.util.GrailsFacetProvider;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-final class GrailsMavenImporter extends MavenImporter {
-  private static final Set<String> IMPORTED_ARTIFACT_GROUPS = 
Set.of("javax.servlet", "org.grails");
-
-  GrailsMavenImporter() {
-    super("org.grails", "grails-maven-plugin");
-  }
-
-  @Override
-  public void process(@NotNull IdeModifiableModelsProvider 
modifiableModelsProvider,
-                      @NotNull Module module,
-                      @NotNull MavenRootModelAdapter rootModel,
-                      @NotNull MavenProjectsTree mavenModel,
-                      @NotNull MavenProject mavenProject,
-                      @NotNull MavenProjectChanges changes,
-                      @NotNull Map<MavenProject, String> 
mavenProjectToModuleName,
-                      @NotNull List<MavenProjectsProcessorTask> postTasks) {
-
-    final List<Consumer<ModifiableFacetModel>> actions = new ArrayList<>();
-    for (GrailsFacetProvider provider : 
GrailsFacetProvider.EP_NAME.getExtensions()) {
-      provider.addFacets(actions, module, 
Collections.singletonList(mavenProject.getDirectoryFile()));
-    }
-
-    final ModifiableFacetModel model = 
modifiableModelsProvider.getModifiableFacetModel(module);
-    for (Consumer<ModifiableFacetModel> action : actions) {
-      action.consume(model);
-    }
-  }
-
-  @Override
-  public void collectSourceRoots(MavenProject mavenProject, 
PairConsumer<String, JpsModuleSourceRootType<?>> result) {
-    for (Map.Entry<JpsModuleSourceRootType<?>, Collection<String>> entry : 
GrailsFramework.GRAILS_SOURCE_FOLDERS.entrySet()) {
-      JpsModuleSourceRootType<?> type = entry.getKey();
-
-      for (String path : entry.getValue()) {
-        result.consume(path, type);
-      }
-    }
-  }
-
-}
diff --git 
a/maven/src/com/intellij/groovy/grails/maven/GrailsMavenWorkspaceConfigurator.kt
 
b/maven/src/com/intellij/groovy/grails/maven/GrailsMavenWorkspaceConfigurator.kt
index c4f8223..3258e86 100644
--- 
a/maven/src/com/intellij/groovy/grails/maven/GrailsMavenWorkspaceConfigurator.kt
+++ 
b/maven/src/com/intellij/groovy/grails/maven/GrailsMavenWorkspaceConfigurator.kt
@@ -1,17 +1,20 @@
 /*
- * Copyright 2000-2026 JetBrains s.r.o. and contributors.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   https://www.apache.org/licenses/LICENSE-2.0
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package com.intellij.groovy.grails.maven
 
@@ -19,6 +22,7 @@ import com.intellij.facet.FacetManager
 import com.intellij.facet.ModifiableFacetModel
 import com.intellij.openapi.application.ApplicationManager
 import com.intellij.util.Consumer
+import org.jetbrains.idea.maven.importing.MavenStaticSyncAware
 import org.jetbrains.idea.maven.importing.MavenWorkspaceConfigurator
 import org.jetbrains.idea.maven.project.MavenProject
 import org.jetbrains.plugins.grails.config.GrailsFramework
@@ -31,7 +35,7 @@ import java.util.stream.Stream
  * (2026.2): registers the Grails source/test/resource roots and the Grails 
facets for
  * projects built with org.grails:grails-maven-plugin.
  */
-internal class GrailsMavenWorkspaceConfigurator : MavenWorkspaceConfigurator {
+internal class GrailsMavenWorkspaceConfigurator : MavenWorkspaceConfigurator, 
MavenStaticSyncAware {
 
   private fun isApplicable(mavenProject: MavenProject): Boolean =
     mavenProject.findPlugin("org.grails", "grails-maven-plugin") != null
@@ -48,6 +52,14 @@ internal class GrailsMavenWorkspaceConfigurator : 
MavenWorkspaceConfigurator {
       GrailsFramework.GRAILS_SOURCE_FOLDERS.get(rootType)
         .mapTo(folders) { MavenWorkspaceConfigurator.AdditionalFolder(it, 
folderType) }
     }
+    // the static preimport repairs default source dirs but not resources
+    // (MavenProjectStaticImporter.resolveDirectories), so restore the Maven 
defaults here
+    if (context.mavenProject.resources.isEmpty()) {
+      
folders.add(MavenWorkspaceConfigurator.AdditionalFolder("src/main/resources", 
MavenWorkspaceConfigurator.FolderType.RESOURCE))
+    }
+    if (context.mavenProject.testResources.isEmpty()) {
+      
folders.add(MavenWorkspaceConfigurator.AdditionalFolder("src/test/resources", 
MavenWorkspaceConfigurator.FolderType.TEST_RESOURCE))
+    }
     return folders.stream()
   }
 

Reply via email to