Search in sources :

Example 6 with BuildDataManager

use of org.jetbrains.jps.incremental.storage.BuildDataManager in project intellij-community by JetBrains.

the class BuildRunner method load.

public ProjectDescriptor load(MessageHandler msgHandler, File dataStorageRoot, BuildFSState fsState) throws IOException {
    final JpsModel jpsModel = myModelLoader.loadModel();
    BuildDataPaths dataPaths = new BuildDataPathsImpl(dataStorageRoot);
    BuildTargetRegistryImpl targetRegistry = new BuildTargetRegistryImpl(jpsModel);
    ModuleExcludeIndex index = new ModuleExcludeIndexImpl(jpsModel);
    IgnoredFileIndexImpl ignoredFileIndex = new IgnoredFileIndexImpl(jpsModel);
    BuildRootIndexImpl buildRootIndex = new BuildRootIndexImpl(targetRegistry, jpsModel, index, dataPaths, ignoredFileIndex);
    BuildTargetIndexImpl targetIndex = new BuildTargetIndexImpl(targetRegistry, buildRootIndex);
    BuildTargetsState targetsState = new BuildTargetsState(dataPaths, jpsModel, buildRootIndex);
    ProjectTimestamps projectTimestamps = null;
    BuildDataManager dataManager = null;
    try {
        projectTimestamps = new ProjectTimestamps(dataStorageRoot, targetsState);
        dataManager = new BuildDataManager(dataPaths, targetsState, STORE_TEMP_CACHES_IN_MEMORY);
        if (dataManager.versionDiffers()) {
            myForceCleanCaches = true;
            msgHandler.processMessage(new CompilerMessage("build", BuildMessage.Kind.INFO, "Dependency data format has changed, project rebuild required"));
        }
    } catch (Exception e) {
        // second try
        LOG.info(e);
        if (projectTimestamps != null) {
            projectTimestamps.close();
        }
        if (dataManager != null) {
            dataManager.close();
        }
        myForceCleanCaches = true;
        FileUtil.delete(dataStorageRoot);
        targetsState = new BuildTargetsState(dataPaths, jpsModel, buildRootIndex);
        projectTimestamps = new ProjectTimestamps(dataStorageRoot, targetsState);
        dataManager = new BuildDataManager(dataPaths, targetsState, STORE_TEMP_CACHES_IN_MEMORY);
        // second attempt succeeded
        msgHandler.processMessage(new CompilerMessage("build", BuildMessage.Kind.INFO, "Project rebuild forced: " + e.getMessage()));
    }
    return new ProjectDescriptor(jpsModel, fsState, projectTimestamps, dataManager, BuildLoggingManager.DEFAULT, index, targetsState, targetIndex, buildRootIndex, ignoredFileIndex);
}
Also used : ProjectTimestamps(org.jetbrains.jps.incremental.storage.ProjectTimestamps) BuildTargetRegistryImpl(org.jetbrains.jps.builders.impl.BuildTargetRegistryImpl) JpsModel(org.jetbrains.jps.model.JpsModel) BuildRootIndexImpl(org.jetbrains.jps.builders.impl.BuildRootIndexImpl) CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) IgnoredFileIndexImpl(org.jetbrains.jps.indices.impl.IgnoredFileIndexImpl) BuildTargetIndexImpl(org.jetbrains.jps.builders.impl.BuildTargetIndexImpl) BuildTargetsState(org.jetbrains.jps.incremental.storage.BuildTargetsState) IOException(java.io.IOException) BuildDataPaths(org.jetbrains.jps.builders.storage.BuildDataPaths) ModuleExcludeIndex(org.jetbrains.jps.indices.ModuleExcludeIndex) ModuleExcludeIndexImpl(org.jetbrains.jps.indices.impl.ModuleExcludeIndexImpl) BuildDataPathsImpl(org.jetbrains.jps.builders.impl.BuildDataPathsImpl) BuildDataManager(org.jetbrains.jps.incremental.storage.BuildDataManager)

Example 7 with BuildDataManager

use of org.jetbrains.jps.incremental.storage.BuildDataManager in project intellij-community by JetBrains.

the class BackwardReferenceIndexWriter method initialize.

static void initialize(@NotNull final CompileContext context, int attempt) {
    final BuildDataManager dataManager = context.getProjectDescriptor().dataManager;
    final File buildDir = dataManager.getDataPaths().getDataStorageRoot();
    if (isEnabled()) {
        boolean isRebuild = isRebuildInAllJavaModules(context);
        if (!JavaCompilers.JAVAC_ID.equals(JavaBuilder.getUsedCompilerId(context)) || !JavaBuilder.IS_ENABLED.get(context, Boolean.TRUE)) {
            CompilerBackwardReferenceIndex.removeIndexFiles(buildDir);
            return;
        }
        if (isRebuild) {
            CompilerBackwardReferenceIndex.removeIndexFiles(buildDir);
        } else if (CompilerBackwardReferenceIndex.versionDiffers(buildDir)) {
            CompilerBackwardReferenceIndex.removeIndexFiles(buildDir);
            if ((attempt == 0 && areAllJavaModulesAffected(context))) {
                throw new BuildDataCorruptedException("backward reference index should be updated to actual version");
            } else {
            // do not request a rebuild if a project is affected incompletely and version is changed, just disable indices
            }
        }
        if (CompilerBackwardReferenceIndex.exist(buildDir) || isRebuild) {
            ourInstance = new BackwardReferenceIndexWriter(new CompilerBackwardReferenceIndex(buildDir, false));
        }
    } else {
        CompilerBackwardReferenceIndex.removeIndexFiles(buildDir);
    }
}
Also used : BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) BuildDataManager(org.jetbrains.jps.incremental.storage.BuildDataManager) File(java.io.File)

Example 8 with BuildDataManager

use of org.jetbrains.jps.incremental.storage.BuildDataManager in project intellij-elixir by KronicDeth.

the class JpsBuildTestCase method createProjectDescriptor.

protected ProjectDescriptor createProjectDescriptor(BuildLoggingManager buildLoggingManager) {
    try {
        BuildTargetRegistryImpl targetRegistry = new BuildTargetRegistryImpl(myModel);
        ModuleExcludeIndex index = new ModuleExcludeIndexImpl(myModel);
        IgnoredFileIndexImpl ignoredFileIndex = new IgnoredFileIndexImpl(myModel);
        BuildDataPaths dataPaths = new BuildDataPathsImpl(myDataStorageRoot);
        BuildRootIndexImpl buildRootIndex = new BuildRootIndexImpl(targetRegistry, myModel, index, dataPaths, ignoredFileIndex);
        BuildTargetIndexImpl targetIndex = new BuildTargetIndexImpl(targetRegistry, buildRootIndex);
        BuildTargetsState targetsState = new BuildTargetsState(dataPaths, myModel, buildRootIndex);
        PathRelativizerService relativizer = new PathRelativizerService(myModel.getProject());
        ProjectStamps timestamps = new ProjectStamps(myDataStorageRoot, targetsState, relativizer);
        BuildDataManager dataManager = new BuildDataManager(dataPaths, targetsState, relativizer);
        return new ProjectDescriptor(myModel, new BuildFSState(true), timestamps, dataManager, buildLoggingManager, index, targetsState, targetIndex, buildRootIndex, ignoredFileIndex);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : BuildTargetRegistryImpl(org.jetbrains.jps.builders.impl.BuildTargetRegistryImpl) BuildRootIndexImpl(org.jetbrains.jps.builders.impl.BuildRootIndexImpl) PathRelativizerService(org.jetbrains.jps.incremental.relativizer.PathRelativizerService) IgnoredFileIndexImpl(org.jetbrains.jps.indices.impl.IgnoredFileIndexImpl) BuildTargetIndexImpl(org.jetbrains.jps.builders.impl.BuildTargetIndexImpl) IOException(java.io.IOException) BuildTargetsState(org.jetbrains.jps.incremental.storage.BuildTargetsState) ProjectStamps(org.jetbrains.jps.incremental.storage.ProjectStamps) BuildFSState(org.jetbrains.jps.incremental.fs.BuildFSState) BuildDataPaths(org.jetbrains.jps.builders.storage.BuildDataPaths) ModuleExcludeIndex(org.jetbrains.jps.indices.ModuleExcludeIndex) ProjectDescriptor(org.jetbrains.jps.cmdline.ProjectDescriptor) ModuleExcludeIndexImpl(org.jetbrains.jps.indices.impl.ModuleExcludeIndexImpl) BuildDataPathsImpl(org.jetbrains.jps.builders.impl.BuildDataPathsImpl) BuildDataManager(org.jetbrains.jps.incremental.storage.BuildDataManager)

Aggregations

BuildDataManager (org.jetbrains.jps.incremental.storage.BuildDataManager)8 IOException (java.io.IOException)5 BuildDataPathsImpl (org.jetbrains.jps.builders.impl.BuildDataPathsImpl)3 BuildRootIndexImpl (org.jetbrains.jps.builders.impl.BuildRootIndexImpl)3 BuildTargetIndexImpl (org.jetbrains.jps.builders.impl.BuildTargetIndexImpl)3 BuildTargetRegistryImpl (org.jetbrains.jps.builders.impl.BuildTargetRegistryImpl)3 BuildDataPaths (org.jetbrains.jps.builders.storage.BuildDataPaths)3 BuildTargetsState (org.jetbrains.jps.incremental.storage.BuildTargetsState)3 ModuleExcludeIndex (org.jetbrains.jps.indices.ModuleExcludeIndex)3 IgnoredFileIndexImpl (org.jetbrains.jps.indices.impl.IgnoredFileIndexImpl)3 ModuleExcludeIndexImpl (org.jetbrains.jps.indices.impl.ModuleExcludeIndexImpl)3 HashMap (com.intellij.util.containers.HashMap)2 TObjectLongHashMap (gnu.trove.TObjectLongHashMap)2 File (java.io.File)2 SourceToOutputMapping (org.jetbrains.jps.builders.storage.SourceToOutputMapping)2 ProjectDescriptor (org.jetbrains.jps.cmdline.ProjectDescriptor)2 BuildFSState (org.jetbrains.jps.incremental.fs.BuildFSState)2 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)2 ProjectTimestamps (org.jetbrains.jps.incremental.storage.ProjectTimestamps)2 IAndroidTarget (com.android.sdklib.IAndroidTarget)1