Search in sources :

Example 1 with JavaModuleBuildTargetType

use of org.jetbrains.jps.builders.java.JavaModuleBuildTargetType 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 2 with JavaModuleBuildTargetType

use of org.jetbrains.jps.builders.java.JavaModuleBuildTargetType in project intellij-community by JetBrains.

the class CompileScopeUtil method addScopesForModules.

public static void addScopesForModules(Collection<Module> modules, List<TargetTypeBuildScope> scopes, boolean forceBuild) {
    if (!modules.isEmpty()) {
        for (JavaModuleBuildTargetType type : JavaModuleBuildTargetType.ALL_TYPES) {
            TargetTypeBuildScope.Builder builder = TargetTypeBuildScope.newBuilder().setTypeId(type.getTypeId()).setForceBuild(forceBuild);
            for (Module module : modules) {
                builder.addTargetId(module.getName());
            }
            scopes.add(builder.build());
        }
    }
}
Also used : JavaModuleBuildTargetType(org.jetbrains.jps.builders.java.JavaModuleBuildTargetType) Module(com.intellij.openapi.module.Module) TargetTypeBuildScope(org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope)

Example 3 with JavaModuleBuildTargetType

use of org.jetbrains.jps.builders.java.JavaModuleBuildTargetType in project intellij-community by JetBrains.

the class BuildRunner method createCompilationScope.

private static CompileScope createCompilationScope(ProjectDescriptor pd, List<TargetTypeBuildScope> scopes, Collection<String> paths, final boolean forceClean, final boolean includeDependenciesToScope) throws Exception {
    Set<BuildTargetType<?>> targetTypes = new HashSet<>();
    Set<BuildTargetType<?>> targetTypesToForceBuild = new HashSet<>();
    Set<BuildTarget<?>> targets = new HashSet<>();
    Map<BuildTarget<?>, Set<File>> files;
    final TargetTypeRegistry typeRegistry = TargetTypeRegistry.getInstance();
    for (TargetTypeBuildScope scope : scopes) {
        final BuildTargetType<?> targetType = typeRegistry.getTargetType(scope.getTypeId());
        if (targetType == null) {
            LOG.info("Unknown target type: " + scope.getTypeId());
            continue;
        }
        if (scope.getForceBuild() || forceClean) {
            targetTypesToForceBuild.add(targetType);
        }
        if (scope.getAllTargets()) {
            targetTypes.add(targetType);
        } else {
            BuildTargetLoader<?> loader = targetType.createLoader(pd.getModel());
            for (String targetId : scope.getTargetIdList()) {
                BuildTarget<?> target = loader.createTarget(targetId);
                if (target != null) {
                    targets.add(target);
                } else {
                    LOG.info("Unknown " + targetType + " target id: " + targetId);
                }
            }
        }
    }
    if (includeDependenciesToScope) {
        includeDependenciesToScope(targetTypes, targets, targetTypesToForceBuild, pd);
    }
    final Timestamps timestamps = pd.timestamps.getStorage();
    if (!paths.isEmpty()) {
        boolean forceBuildAllModuleBasedTargets = false;
        for (BuildTargetType<?> type : targetTypesToForceBuild) {
            if (type instanceof JavaModuleBuildTargetType) {
                forceBuildAllModuleBasedTargets = true;
                break;
            }
        }
        files = new HashMap<>();
        for (String path : paths) {
            final File file = new File(path);
            final Collection<BuildRootDescriptor> descriptors = pd.getBuildRootIndex().findAllParentDescriptors(file, null);
            for (BuildRootDescriptor descriptor : descriptors) {
                Set<File> fileSet = files.get(descriptor.getTarget());
                if (fileSet == null) {
                    fileSet = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
                    files.put(descriptor.getTarget(), fileSet);
                }
                final boolean added = fileSet.add(file);
                if (added) {
                    final BuildTargetType<?> targetType = descriptor.getTarget().getTargetType();
                    if (targetTypesToForceBuild.contains(targetType) || (forceBuildAllModuleBasedTargets && targetType instanceof ModuleBasedBuildTargetType)) {
                        pd.fsState.markDirty(null, file, descriptor, timestamps, false);
                    }
                }
            }
        }
    } else {
        files = Collections.emptyMap();
    }
    return new CompileScopeImpl(targetTypes, targetTypesToForceBuild, targets, files);
}
Also used : THashSet(gnu.trove.THashSet) ProjectTimestamps(org.jetbrains.jps.incremental.storage.ProjectTimestamps) Timestamps(org.jetbrains.jps.incremental.storage.Timestamps) JavaModuleBuildTargetType(org.jetbrains.jps.builders.java.JavaModuleBuildTargetType) File(java.io.File) TargetTypeBuildScope(org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope) THashSet(gnu.trove.THashSet) JavaModuleBuildTargetType(org.jetbrains.jps.builders.java.JavaModuleBuildTargetType)

Example 4 with JavaModuleBuildTargetType

use of org.jetbrains.jps.builders.java.JavaModuleBuildTargetType in project intellij-community by JetBrains.

the class CompileScopeImpl method isAffectedByAssociatedModule.

private boolean isAffectedByAssociatedModule(BuildTarget<?> target) {
    if (target instanceof ModuleBasedTarget) {
        final JpsModule module = ((ModuleBasedTarget) target).getModule();
        // this target is associated with module
        JavaModuleBuildTargetType targetType = JavaModuleBuildTargetType.getInstance(((ModuleBasedTarget) target).isTests());
        if (myTypes.contains(targetType) || myTargets.contains(new ModuleBuildTarget(module, targetType))) {
            return true;
        }
    }
    return false;
}
Also used : JavaModuleBuildTargetType(org.jetbrains.jps.builders.java.JavaModuleBuildTargetType) JpsModule(org.jetbrains.jps.model.module.JpsModule) ModuleBasedTarget(org.jetbrains.jps.builders.ModuleBasedTarget)

Example 5 with JavaModuleBuildTargetType

use of org.jetbrains.jps.builders.java.JavaModuleBuildTargetType in project intellij-community by JetBrains.

the class Standalone method runBuild.

public static void runBuild(JpsModelLoader loader, final File dataStorageRoot, boolean forceBuild, Set<String> modulesSet, final boolean allModules, List<String> artifactsList, boolean allArtifacts, final boolean includeTests, final MessageHandler messageHandler) throws Exception {
    List<TargetTypeBuildScope> scopes = new ArrayList<>();
    for (JavaModuleBuildTargetType type : JavaModuleBuildTargetType.ALL_TYPES) {
        if (includeTests || !type.isTests()) {
            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());
            }
        }
    }
    TargetTypeBuildScope.Builder builder = TargetTypeBuildScope.newBuilder().setTypeId(ArtifactBuildTargetType.INSTANCE.getTypeId()).setForceBuild(forceBuild);
    if (allArtifacts) {
        scopes.add(builder.setAllTargets(true).build());
    } else if (!artifactsList.isEmpty()) {
        scopes.add(builder.addAllTargetId(artifactsList).build());
    }
    runBuild(loader, dataStorageRoot, messageHandler, scopes, true);
}
Also used : JavaModuleBuildTargetType(org.jetbrains.jps.builders.java.JavaModuleBuildTargetType) TargetTypeBuildScope(org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope)

Aggregations

JavaModuleBuildTargetType (org.jetbrains.jps.builders.java.JavaModuleBuildTargetType)5 TargetTypeBuildScope (org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope)4 Module (com.intellij.openapi.module.Module)1 THashSet (gnu.trove.THashSet)1 File (java.io.File)1 ModuleBasedTarget (org.jetbrains.jps.builders.ModuleBasedTarget)1 ProjectTimestamps (org.jetbrains.jps.incremental.storage.ProjectTimestamps)1 Timestamps (org.jetbrains.jps.incremental.storage.Timestamps)1 JpsModule (org.jetbrains.jps.model.module.JpsModule)1