how to get output path and test output path of a project?


I cannot find a method in Project or ProjetRootManager that could get the output paths or test output paths of a project. These paths can be set in project structure -> project settings -> Modules.


I think maybe the question is how to get the modules from a given project.

0
Avatar
Permanently deleted user

Thanks a lot for the information. 

This call gets a list of paths:

VirtualFile[] roots = ModuleRootManager.getInstance(modules[i]).orderEntries().classes().getRoots();

But, it only contains test output paths with the name of "test-classes", but not the output path of the compiled classes of the module.

0
Avatar
Permanently deleted user

Hi, please help with the output path part? I didn't find the output path of a module.

0
Avatar
Permanently deleted user

I still can't retrieve this required information:

We need to get these paths, "Output path" and "Test output path", through some API calls.

0

Sorry for the delay. You can read these paths via CompilerModuleExtension class, I've just updated javadocs to make it more discoverable.

0
Avatar
Permanently deleted user

Thank you for the information.

We also found this API while going through the source code:

String[] outputPaths = CompilerPathsEx.getOutputPaths(ModuleManager.getInstance(this.project).getModules());

Is this the right way? Or should we use the CompilerModuleExtension class?

Also, which way will cover both "Inherit project compile output path" and "Use module compile output path" cases? Will these approach work with both Maven and Gradle projects?

 

0

请先登录再写评论。