Search in sources :

Example 1 with TempDirProvider

use of org.infernus.idea.checkstyle.util.TempDirProvider in project checkstyle-idea by jshiell.

the class CheckStyleConfigurable method apply.

public void apply() {
    final PluginConfiguration newConfig = PluginConfigurationBuilder.from(configPanel.getPluginConfiguration()).withScanBeforeCheckin(pluginConfigurationManager.getCurrent().isScanBeforeCheckin()).build();
    pluginConfigurationManager.setCurrent(newConfig, true);
    activateCurrentCheckstyleVersion(newConfig.getCheckstyleVersion(), newConfig.getThirdPartyClasspath());
    if (!newConfig.isCopyLibs()) {
        new TempDirProvider().deleteCopiedLibrariesDir(project);
    }
}
Also used : TempDirProvider(org.infernus.idea.checkstyle.util.TempDirProvider) PluginConfiguration(org.infernus.idea.checkstyle.config.PluginConfiguration)

Example 2 with TempDirProvider

use of org.infernus.idea.checkstyle.util.TempDirProvider in project checkstyle-idea by jshiell.

the class ScannableFile method prepareBaseTmpDirFor.

private File prepareBaseTmpDirFor(final PsiFile tempPsiFile) {
    final File baseTmpDir = new File(new TempDirProvider().forPersistedPsiFile(tempPsiFile), tempFileDirectoryName());
    baseTmpDir.deleteOnExit();
    return baseTmpDir;
}
Also used : TempDirProvider(org.infernus.idea.checkstyle.util.TempDirProvider) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) PsiJavaFile(com.intellij.psi.PsiJavaFile)

Example 3 with TempDirProvider

use of org.infernus.idea.checkstyle.util.TempDirProvider in project checkstyle-idea by jshiell.

the class ModuleClassPathBuilder method build.

public ClassLoader build(final Module baseModule) {
    if (baseModule == null) {
        return getClass().getClassLoader();
    }
    final Project baseModuleProject = baseModule.getProject();
    final List<URL> outputPaths = new ArrayList<>();
    final Set<Module> transitiveDependencies = new HashSet<>();
    ModuleUtil.getDependencies(baseModule, transitiveDependencies);
    for (Module moduleInScope : transitiveDependencies) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Adding module to classpath: " + moduleInScope.getName());
        }
        outputPaths.addAll(ModulePaths.compilerOutputPathsFor(moduleInScope));
        outputPaths.addAll(ModulePaths.libraryPathsFor(moduleInScope));
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Creating class-loader with URLs: " + outputPaths);
    }
    URL[] effectiveClasspath = outputPaths.toArray(new URL[0]);
    if (wantsCopyLibs()) {
        final Optional<File> tempDir = new TempDirProvider().forCopiedLibraries(baseModuleProject);
        if (tempDir.isPresent()) {
            final Path t = Paths.get(tempDir.get().toURI());
            effectiveClasspath = new ClasspathStabilizer(baseModuleProject, t).stabilize(outputPaths);
        }
    }
    return new URLClassLoader(effectiveClasspath, getClass().getClassLoader());
}
Also used : Path(java.nio.file.Path) URL(java.net.URL) Project(com.intellij.openapi.project.Project) TempDirProvider(org.infernus.idea.checkstyle.util.TempDirProvider) URLClassLoader(java.net.URLClassLoader) Module(com.intellij.openapi.module.Module) File(java.io.File)

Aggregations

TempDirProvider (org.infernus.idea.checkstyle.util.TempDirProvider)3 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 PsiJavaFile (com.intellij.psi.PsiJavaFile)1 File (java.io.File)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 Path (java.nio.file.Path)1 PluginConfiguration (org.infernus.idea.checkstyle.config.PluginConfiguration)1