Search in sources :

Example 1 with TargetTypeBuildScope

use of org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope in project intellij-community by JetBrains.

the class BuildManager method runAutoMake.

private void runAutoMake() {
    final Project project = getCurrentContextProject();
    if (project == null || !canStartAutoMake(project)) {
        return;
    }
    final List<TargetTypeBuildScope> scopes = CmdlineProtoUtil.createAllModulesScopes(false);
    final AutoMakeMessageHandler handler = new AutoMakeMessageHandler(project);
    final TaskFuture future = scheduleBuild(project, false, true, false, scopes, Collections.emptyList(), Collections.emptyMap(), handler);
    if (future != null) {
        myAutomakeFutures.put(future, project);
        try {
            future.waitFor();
        } finally {
            myAutomakeFutures.remove(future);
            if (handler.unprocessedFSChangesDetected()) {
                scheduleAutoMake();
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) TargetTypeBuildScope(org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope)

Example 2 with TargetTypeBuildScope

use of org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope in project intellij-community by JetBrains.

the class CompileScopeUtil method mergeScopes.

private static void mergeScopes(Map<String, TargetTypeBuildScope> scopeById, List<TargetTypeBuildScope> scopes) {
    for (TargetTypeBuildScope scope : scopes) {
        String id = scope.getTypeId();
        TargetTypeBuildScope old = scopeById.get(id);
        if (old == null) {
            scopeById.put(id, scope);
        } else {
            scopeById.put(id, mergeScope(old, scope));
        }
    }
}
Also used : TargetTypeBuildScope(org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope)

Example 3 with TargetTypeBuildScope

use of org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope in project intellij-community by JetBrains.

the class JpsGantProjectBuilder method runBuild.

private void runBuild(final Set<String> modulesSet, final boolean allModules, boolean includeTests) {
    if (!myDryRun) {
        System.setProperty(GlobalOptions.USE_DEFAULT_FILE_LOGGING_OPTION, "false");
        final AntMessageHandler messageHandler = new AntMessageHandler();
        //noinspection AssignmentToStaticFieldFromInstanceMethod
        AntLoggerFactory.ourMessageHandler = new AntMessageHandler();
        AntLoggerFactory.ourFileLoggerFactory = myFileLoggerFactory;
        Logger.setFactory(AntLoggerFactory.class);
        boolean forceBuild = !myBuildIncrementally;
        List<TargetTypeBuildScope> scopes = new ArrayList<>();
        for (JavaModuleBuildTargetType type : JavaModuleBuildTargetType.ALL_TYPES) {
            if (includeTests || !type.isTests()) {
                List<String> namesToCompile = new ArrayList<>(allModules ? getAllModules() : modulesSet);
                if (type.isTests()) {
                    namesToCompile.removeAll(myCompiledModuleTests);
                    myCompiledModuleTests.addAll(namesToCompile);
                } else {
                    namesToCompile.removeAll(myCompiledModules);
                    myCompiledModules.addAll(namesToCompile);
                }
                if (namesToCompile.isEmpty())
                    continue;
                TargetTypeBuildScope.Builder builder = TargetTypeBuildScope.newBuilder().setTypeId(type.getTypeId()).setForceBuild(forceBuild);
                if (allModules) {
                    scopes.add(builder.setAllTargets(true).build());
                } else if (!modulesSet.isEmpty()) {
                    scopes.add(builder.addAllTargetId(modulesSet).build());
                }
            }
        }
        info("Starting build; incremental: " + myBuildIncrementally + ", cache directory: " + myDataStorageRoot.getAbsolutePath());
        info("Build scope: " + (allModules ? "all" : modulesSet.size()) + " modules, " + (includeTests ? "including tests" : "production only"));
        long compilationStart = System.currentTimeMillis();
        try {
            myBuildInfoPrinter.printBlockOpenedMessage(this, "Compilation");
            Standalone.runBuild(myModelLoader, myDataStorageRoot, messageHandler, scopes, false);
        } catch (Throwable e) {
            error(e);
        } finally {
            myBuildInfoPrinter.printBlockClosedMessage(this, "Compilation");
        }
        if (messageHandler.myFailed) {
            error("Compilation failed");
        } else if (!myStatisticsReported) {
            myBuildInfoPrinter.printStatisticsMessage(this, "Compilation time, ms", String.valueOf(System.currentTimeMillis() - compilationStart));
            myStatisticsReported = true;
        }
    } else {
        info("Building skipped as we're running dry");
    }
}
Also used : JavaModuleBuildTargetType(org.jetbrains.jps.builders.java.JavaModuleBuildTargetType) TargetTypeBuildScope(org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope)

Example 4 with TargetTypeBuildScope

use of org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope in project intellij-community by JetBrains.

the class BuildSession method scopeContainsModulesOnlyForIncrementalMake.

private static boolean scopeContainsModulesOnlyForIncrementalMake(List<TargetTypeBuildScope> scopes) {
    TargetTypeRegistry typeRegistry = null;
    for (TargetTypeBuildScope scope : scopes) {
        if (scope.getForceBuild())
            return false;
        final String typeId = scope.getTypeId();
        if (isJavaModuleBuildType(typeId)) {
            // fast check
            continue;
        }
        if (typeRegistry == null) {
            // lazy init
            typeRegistry = TargetTypeRegistry.getInstance();
        }
        final BuildTargetType<?> targetType = typeRegistry.getTargetType(typeId);
        if (targetType != null && !(targetType instanceof ModuleInducedTargetType)) {
            return false;
        }
    }
    return true;
}
Also used : TargetTypeRegistry(org.jetbrains.jps.incremental.TargetTypeRegistry) TargetTypeBuildScope(org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope)

Example 5 with TargetTypeBuildScope

use of org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope in project android by JetBrains.

the class AndroidBuildTargetScopeProvider method getBuildTargetScopes.

@NotNull
@Override
public List<TargetTypeBuildScope> getBuildTargetScopes(@NotNull CompileScope baseScope, @NotNull CompilerFilter filter, @NotNull Project project, boolean forceBuild) {
    if (!ProjectFacetManager.getInstance(project).hasFacets(AndroidFacet.ID) || AndroidProjectInfo.getInstance(project).requiresAndroidModel()) {
        return Collections.emptyList();
    }
    final List<String> appTargetIds = new ArrayList<>();
    final List<String> libTargetIds = new ArrayList<>();
    final List<String> allTargetIds = new ArrayList<>();
    final List<String> manifestMergingTargetIds = new ArrayList<>();
    final boolean fullBuild = AndroidCompileUtil.isFullBuild(baseScope);
    for (Module module : baseScope.getAffectedModules()) {
        final AndroidFacet facet = AndroidFacet.getInstance(module);
        if (facet == null) {
            continue;
        }
        allTargetIds.add(module.getName());
        if (fullBuild) {
            if (facet.canBeDependency()) {
                libTargetIds.add(module.getName());
            } else {
                if (facet.getProperties().ENABLE_MANIFEST_MERGING) {
                    manifestMergingTargetIds.add(module.getName());
                }
                appTargetIds.add(module.getName());
            }
        }
    }
    final List<TargetTypeBuildScope> result = new ArrayList<>();
    result.add(CmdlineProtoUtil.createTargetsScope(AndroidCommonUtils.MANIFEST_MERGING_BUILD_TARGET_TYPE_ID, manifestMergingTargetIds, forceBuild));
    if (fullBuild && !isProGuardUsed(project, baseScope)) {
        result.add(CmdlineProtoUtil.createTargetsScope(AndroidCommonUtils.PRE_DEX_BUILD_TARGET_TYPE_ID, Collections.singletonList("only"), forceBuild));
    }
    result.addAll(Arrays.asList(CmdlineProtoUtil.createTargetsScope(AndroidCommonUtils.AAR_DEPS_BUILD_TARGET_TYPE_ID, appTargetIds, forceBuild), CmdlineProtoUtil.createTargetsScope(AndroidCommonUtils.DEX_BUILD_TARGET_TYPE_ID, appTargetIds, forceBuild), CmdlineProtoUtil.createTargetsScope(AndroidCommonUtils.RESOURCE_CACHING_BUILD_TARGET_ID, allTargetIds, forceBuild), CmdlineProtoUtil.createTargetsScope(AndroidCommonUtils.RESOURCE_PACKAGING_BUILD_TARGET_ID, appTargetIds, forceBuild), CmdlineProtoUtil.createTargetsScope(AndroidCommonUtils.PACKAGING_BUILD_TARGET_TYPE_ID, appTargetIds, forceBuild), CmdlineProtoUtil.createTargetsScope(AndroidCommonUtils.LIBRARY_PACKAGING_BUILD_TARGET_ID, libTargetIds, forceBuild)));
    return result;
}
Also used : Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) TargetTypeBuildScope(org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TargetTypeBuildScope (org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope)11 JavaModuleBuildTargetType (org.jetbrains.jps.builders.java.JavaModuleBuildTargetType)4 Module (com.intellij.openapi.module.Module)3 NotNull (org.jetbrains.annotations.NotNull)3 Project (com.intellij.openapi.project.Project)2 Artifact (com.intellij.packaging.artifacts.Artifact)2 THashSet (gnu.trove.THashSet)2 BuildSettings (com.android.tools.idea.gradle.project.BuildSettings)1 BuildMode (com.android.tools.idea.gradle.util.BuildMode)1 CompositeScope (com.intellij.compiler.impl.CompositeScope)1 ModuleCompileScope (com.intellij.compiler.impl.ModuleCompileScope)1 ProjectCompileScope (com.intellij.compiler.impl.ProjectCompileScope)1 BuildManager (com.intellij.compiler.server.BuildManager)1 DefaultMessageHandler (com.intellij.compiler.server.DefaultMessageHandler)1 ReadAction (com.intellij.openapi.application.ReadAction)1 Result (com.intellij.openapi.application.Result)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 MessageType (com.intellij.openapi.ui.MessageType)1 Key (com.intellij.openapi.util.Key)1 HashMap (com.intellij.util.containers.HashMap)1