@Nullable public static String getAnnotationProcessorsGenerationPath(Module module) { final CompilerConfiguration config = CompilerConfiguration.getInstance(module.getProject()); final String sourceDirName = config.getGeneratedSourceDirName(module); if (sourceDirName != null && sourceDirName.length() > 0) { final String[] roots = ModuleRootManager.getInstance(module).getContentRootUrls(); if (roots.length == 0) { return null; } if (roots.length > 1) { Arrays.sort(roots, URLS_COMPARATOR); } return VirtualFileManager.extractPath(roots[0]) + "/" + sourceDirName; } final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(module.getProject()); if (extension == null) { return null; } final String url = extension.getCompilerOutputUrl(); if (url == null) { return null; } return VirtualFileManager.extractPath(url) + "/" + DEFAULT_GENERATED_DIR_NAME + "/" + module.getName().toLowerCase(); }
@NotNull public static String getDefaultBundlesOutputPath(Project project) { CompilerProjectExtension instance = CompilerProjectExtension.getInstance(project); if (instance != null) { final VirtualFilePointer compilerOutput = instance.getCompilerOutputPointer(); if (compilerOutput != null) { return VfsUtil.urlToPath(compilerOutput.getUrl()) + "/bundles"; } } // this actually should never happen (only in tests) return FileUtil.getTempDirectory(); }
@Nullable public static String getDefaultArtifactOutputPath( @NotNull String artifactName, final @NotNull Project project) { final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(project); if (extension == null) return null; String outputUrl = extension.getCompilerOutputUrl(); if (outputUrl == null || outputUrl.length() == 0) { final VirtualFile baseDir = project.getBaseDir(); if (baseDir == null) return null; outputUrl = baseDir.getUrl() + "/out"; } return VfsUtil.urlToPath(outputUrl) + "/artifacts/" + FileUtil.sanitizeFileName(artifactName); }
private static Iterable<String> getOutputPaths(Project project) { final Collection<String> paths = new LinkedHashSet<>(); final CompilerProjectExtension cpe = CompilerProjectExtension.getInstance(project); if (cpe != null && cpe.getCompilerOutput() != null) { paths.add(cpe.getCompilerOutput().getCanonicalPath()); } final Module[] modules = ModuleManager.getInstance(project).getModules(); for (Module module : modules) { final CompilerModuleExtension cme = CompilerModuleExtension.getInstance(module); if (cme != null && cme.getCompilerOutputPath() != null) { paths.add(cme.getCompilerOutputPath().getCanonicalPath()); } } return paths; }
private String getOutputPath(CompileContext context, Chunk<Module> moduleChunk) { if (moduleChunk.getNodes().isEmpty()) { context.addMessage( CompilerMessageCategory.WARNING, "No module defined, running application might not function properly.", null, -1, -1); return CompilerProjectExtension.getInstance(project).getCompilerOutput().getPath() + "/go-bins"; } else { // TODO This is a hack to keep GoMakefileCompiler compatible with the way Runner expects // binaries, we // use any module assuming the path is the same for all Module firstModule = moduleChunk.getNodes().iterator().next(); return context.getModuleOutputDirectory(firstModule).getPath() + "/go-bins"; } }
@Override protected void setUpProject() throws Exception { super.setUpProject(); final String baseUrl = myProject.getBaseDir().getUrl(); CompilerProjectExtension.getInstance(myProject).setCompilerOutputUrl(baseUrl + "/out"); }
@Nullable public static String findResourcesCacheDirectory( @NotNull Module module, boolean createIfNotFound, @Nullable CompileContext context) { final Project project = module.getProject(); final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(project); if (extension == null) { if (context != null) { context.addMessage( CompilerMessageCategory.ERROR, "Cannot get compiler settings for project " + project.getName(), null, -1, -1); } return null; } final String projectOutputDirUrl = extension.getCompilerOutputUrl(); if (projectOutputDirUrl == null) { if (context != null) { context.addMessage( CompilerMessageCategory.ERROR, "Cannot find output directory for project " + project.getName(), null, -1, -1); } return null; } final String pngCacheDirPath = VfsUtil.urlToPath(projectOutputDirUrl) + '/' + RESOURCES_CACHE_DIR_NAME + '/' + module.getName(); final String pngCacheDirOsPath = FileUtil.toSystemDependentName(pngCacheDirPath); final File pngCacheDir = new File(pngCacheDirOsPath); if (pngCacheDir.exists()) { if (pngCacheDir.isDirectory()) { return pngCacheDirOsPath; } else { if (context != null) { context.addMessage( CompilerMessageCategory.ERROR, "Cannot create directory " + pngCacheDirOsPath + " because file already exists", null, -1, -1); } return null; } } if (!createIfNotFound) { return null; } if (!pngCacheDir.mkdirs()) { if (context != null) { context.addMessage( CompilerMessageCategory.ERROR, "Cannot create directory " + pngCacheDirOsPath, null, -1, -1); } return null; } return pngCacheDirOsPath; }