How to access Gradle module resource output directory in JPS plugin?

Answered

For Gradle project module there are several output paths per module, pointed by sourceSets, e.g. main sourceSet has default "build/classes/main" and "build/resources/main". On UI side those can be accessed with

OrderEnumerator.orderEntries(module)...classes().getRoots();

However on JPS plugin side at builder extending ModuleLevelBuilder that has BuilderCategory.CLASS_POST_PROCESSOR there is missing "build/resources/main" path, when accessed with

JpsJavaExtensionService.dependencies(module)...classes().getRoots();

In Gradle plugin tasks may access resource ouput directory after accessing convention with

sourceSet.getOutput().getResourcesDir()

I understand that class post processor may be called before resource post porcessor in JPS and at ModuleLevelBuilder there may be no way to figure out those resource paths yet. How to access main sourceSet resources output directory at JPS plugin side, without excessive combinations?

0
2 comments

You can try the JpsGradleExtensionService:

GradleProjectConfiguration projectConfig = JpsGradleExtensionService.getInstance().getGradleProjectConfiguration(dataPaths);
GradleModuleResourceConfiguration moduleConfig = projectConfig.moduleConfigurations.get(myModule.getName());
List<ResourceRootConfiguration> resources = moduleConfig.resources;
List<ResourceRootConfiguration> testResources = moduleConfig.testResources;
1
Avatar
Permanently deleted user

It works in may case - thanks for help.

0

Please sign in to leave a comment.