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");
}
}
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());
}
}
}
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);
}
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;
}
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);
}
Aggregations