Skip to content

Commit

Permalink
#728 | Register sub-modules source directories for custom modules
Browse files Browse the repository at this point in the history
  • Loading branch information
mlytvyn authored Sep 17, 2023
1 parent dd88f53 commit 68ee272
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

### Fixes
- `SAP Commerce` tool window sometimes appears without any content [#725](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/725)
- Register sub-modules source directories for custom modules [#728](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/728)

## [2023.2.8]

Expand Down
2 changes: 1 addition & 1 deletion resources/META-INF/optional-java-dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<applicationService serviceInterface="com.intellij.idea.plugin.hybris.project.configurators.CompilerOutputPathsConfigurator"
serviceImplementation="com.intellij.idea.plugin.hybris.project.configurators.impl.DefaultCompilerOutputPathsConfigurator"/>

<applicationService serviceImplementation="com.intellij.idea.plugin.hybris.project.configurators.impl.RegularContentRootConfigurator"/>
<applicationService serviceImplementation="com.intellij.idea.plugin.hybris.project.configurators.impl.DefaultContentRootConfigurator"/>

<applicationService serviceInterface="com.intellij.idea.plugin.hybris.project.configurators.GroupModuleConfigurator"
serviceImplementation="com.intellij.idea.plugin.hybris.project.configurators.impl.DefaultGroupModuleConfigurator"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package com.intellij.idea.plugin.hybris.project.configurators

import com.intellij.idea.plugin.hybris.project.configurators.impl.RegularContentRootConfigurator
import com.intellij.idea.plugin.hybris.project.configurators.impl.DefaultContentRootConfigurator
import com.intellij.idea.plugin.hybris.project.descriptors.ModuleDescriptor
import com.intellij.idea.plugin.hybris.settings.HybrisApplicationSettings
import com.intellij.openapi.application.ApplicationManager
Expand All @@ -35,6 +35,6 @@ interface ContentRootConfigurator {
)

companion object {
val instance: ContentRootConfigurator = ApplicationManager.getApplication().getService(RegularContentRootConfigurator::class.java)
val instance: ContentRootConfigurator = ApplicationManager.getApplication().getService(DefaultContentRootConfigurator::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import static com.intellij.idea.plugin.hybris.common.HybrisConstants.*;
import static com.intellij.idea.plugin.hybris.common.utils.HybrisI18NBundleUtils.message;

public class RegularContentRootConfigurator implements ContentRootConfigurator {
public class DefaultContentRootConfigurator implements ContentRootConfigurator {

// module name -> relative paths
private static final Map<String, List<String>> ROOTS_TO_IGNORE = new HashMap<>();
Expand Down Expand Up @@ -109,7 +109,7 @@ protected void configureCommonRoots(
@NotNull final HybrisApplicationSettings appSettings
) {
final var rootProjectDescriptor = moduleDescriptor.getRootProjectDescriptor();
if (moduleDescriptor instanceof YCustomRegularModuleDescriptor
if (isCustomModuleDescriptor(moduleDescriptor)
|| EXTENSION_NAME_PLATFORM_SERVICES.equals(moduleDescriptor.getName())
|| !rootProjectDescriptor.isImportOotbModulesInReadOnlyMode()) {
addSourceRoots(contentEntry, moduleDescriptor.getModuleRootDirectory(), dirsToIgnore, appSettings, SRC_DIR_NAMES, JavaSourceRootType.SOURCE);
Expand All @@ -125,7 +125,7 @@ protected void configureCommonRoots(

addSourceRoots(contentEntry, moduleDescriptor.getModuleRootDirectory(), dirsToIgnore, appSettings, TEST_SRC_DIR_NAMES, JavaSourceRootType.TEST_SOURCE);

if (!(moduleDescriptor instanceof YCustomRegularModuleDescriptor) && rootProjectDescriptor.isExcludeTestSources()) {
if (!isCustomModuleDescriptor(moduleDescriptor) && rootProjectDescriptor.isExcludeTestSources()) {
excludeDirectories(contentEntry, moduleDescriptor.getModuleRootDirectory(), TEST_SRC_DIR_NAMES);
}

Expand Down Expand Up @@ -350,6 +350,11 @@ protected void configureWebInf(
}
}

private static boolean isCustomModuleDescriptor(final @NotNull ModuleDescriptor moduleDescriptor) {
return moduleDescriptor instanceof YCustomRegularModuleDescriptor
|| (moduleDescriptor instanceof final YSubModuleDescriptor ySubModuleDescriptor && ySubModuleDescriptor.getOwner() instanceof YCustomRegularModuleDescriptor);
}

private void addResourcesDirectory(final @NotNull ContentEntry contentEntry, final File platformBootstrapDirectory) {
final var platformBootstrapResourcesDirectory = new File(platformBootstrapDirectory, RESOURCES_DIRECTORY);
contentEntry.addSourceFolder(
Expand Down

0 comments on commit 68ee272

Please sign in to comment.