@Override public String getId() { return myModule.getName(); }
@NotNull @Override public String getPresentableName() { return "Elixir '" + myModule.getName() + "' " + (isTests() ? "test" : "production"); }
private static void collectDependentModules(@NotNull JpsModule module, @NotNull Collection<JpsModule> addedModules, @NotNull Set<String> addedModuleNames) { String moduleName = module.getName(); if (addedModuleNames.contains(moduleName)) return; addedModuleNames.add(moduleName); addedModules.add(module); for (JpsDependencyElement dependency : module.getDependenciesList().getDependencies()) { if (!(dependency instanceof JpsModuleDependency)) continue; JpsModuleDependency moduleDependency = (JpsModuleDependency) dependency; JpsModule depModule = moduleDependency.getModule(); if (depModule != null) { collectDependentModules(depModule, addedModules, addedModuleNames); } } }
@NotNull public static JpsSdk<SdkProperties> getSdk(@NotNull CompileContext context, @NotNull JpsModule module) throws ProjectBuildException { JpsSdk<SdkProperties> sdk = module.getSdk(Elixir.INSTANCE); if (sdk == null) { String errorMessage = "No SDK for module " + module.getName(); context.processMessage(new CompilerMessage(Builder.BUILDER_NAME, BuildMessage.Kind.ERROR, errorMessage)); throw new ProjectBuildException(errorMessage); } return sdk; } }
private static void addModuleToCodePath(@NotNull GeneralCommandLine commandLine, @NotNull JpsModule module, boolean forTests, @NotNull CompileContext context) throws ProjectBuildException { File outputDirectory = getBuildOutputDirectory(module, forTests, context); commandLine.addParameters(ADD_PATH_TO_FRONT_OF_CODE_PATH, outputDirectory.getPath()); for (String rootUrl : module.getContentRootsList().getUrls()) { try { String path = new URL(rootUrl).getPath(); commandLine.addParameters(ADD_PATH_TO_FRONT_OF_CODE_PATH, path); } catch (MalformedURLException e) { context.processMessage(new CompilerMessage(ElIXIRC_NAME, BuildMessage.Kind.ERROR, "Failed to find content root for module: " + module.getName())); } } }
/*** doBuildWithElixirc releated private methods */ @NotNull private static File getBuildOutputDirectory(@NotNull JpsModule module, boolean forTests, @NotNull CompileContext context) throws ProjectBuildException { JpsJavaExtensionService instance = JpsJavaExtensionService.getInstance(); File outputDirectory = instance.getOutputDirectory(module, forTests); if (outputDirectory == null) { String errorMessage = "No output directory for module " + module.getName(); context.processMessage(new CompilerMessage(ElIXIRC_NAME, BuildMessage.Kind.ERROR, errorMessage)); throw new ProjectBuildException(errorMessage); } if (!outputDirectory.exists()) { FileUtil.createDirectory(outputDirectory); } return outputDirectory; }
@NotNull @Override public String getId() { return getModule().getName(); }
@NotNull @Override public String getPresentableName() { return "Module '" + getModule().getName() + "' " + (isTests() ? "tests" : "production"); }
@NotNull private static JpsSdk<JpsDummyElement> getSdk(@NotNull CompileContext context, @NotNull JpsModule module) throws ProjectBuildException { JpsSdk<JpsDummyElement> sdk = module.getSdk(JpsMonkeySdkType.INSTANCE); if (sdk == null) { String errorMessage = "No SDK for module " + module.getName(); context.processMessage(new CompilerMessage(NAME, BuildMessage.Kind.ERROR, errorMessage)); throw new ProjectBuildException(errorMessage); } return sdk; }
@NotNull private static File getBuildOutputDirectory(@NotNull JpsModule module, boolean forTests, @NotNull CompileContext context) throws ProjectBuildException { JpsJavaExtensionService instance = JpsJavaExtensionService.getInstance(); File outputDirectory = instance.getOutputDirectory(module, forTests); if (outputDirectory == null) { String errorMessage = "No output dir for module " + module.getName(); context.processMessage(new CompilerMessage(NAME, BuildMessage.Kind.ERROR, errorMessage)); throw new ProjectBuildException(errorMessage); } if (!outputDirectory.exists()) { FileUtil.createDirectory(outputDirectory); } return outputDirectory; }