use of com.google.idea.blaze.java.sync.BlazeJavaSyncAugmenter in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporter method addTargetAsSource.
private void addTargetAsSource(WorkspaceBuilder workspaceBuilder, TargetIdeInfo target, Collection<ArtifactLocation> javaSources) {
JavaIdeInfo javaIdeInfo = target.javaIdeInfo;
if (javaIdeInfo == null) {
return;
}
TargetKey targetKey = target.key;
Collection<String> jars = jdepsMap.getDependenciesForTarget(targetKey);
if (jars != null) {
workspaceBuilder.jdeps.addAll(jars);
}
// Add all deps if this rule is in the current working set
if (workingSet == null || workingSet.isTargetInWorkingSet(target)) {
// Add self, so we pick up our own gen jars if in working set
workspaceBuilder.directDeps.add(targetKey);
for (Dependency dep : target.dependencies) {
if (dep.dependencyType != DependencyType.COMPILE_TIME) {
continue;
}
// forward deps from java proto_library aspect targets
TargetIdeInfo depTarget = targetMap.get(dep.targetKey);
if (depTarget != null && Kind.JAVA_PROTO_LIBRARY_KINDS.contains(depTarget.kind)) {
workspaceBuilder.directDeps.addAll(depTarget.dependencies.stream().map(d -> d.targetKey).collect(Collectors.toList()));
} else {
workspaceBuilder.directDeps.add(dep.targetKey);
}
}
}
for (ArtifactLocation artifactLocation : javaSources) {
if (artifactLocation.isSource()) {
duplicateSourceDetector.add(targetKey, artifactLocation);
workspaceBuilder.sourceArtifacts.add(new SourceArtifact(targetKey, artifactLocation));
workspaceBuilder.addedSourceFiles.add(artifactLocation);
}
}
ArtifactLocation manifest = javaIdeInfo.packageManifest;
if (manifest != null) {
workspaceBuilder.javaPackageManifests.put(targetKey, manifest);
}
for (LibraryArtifact libraryArtifact : javaIdeInfo.jars) {
ArtifactLocation classJar = libraryArtifact.classJar;
if (classJar != null) {
workspaceBuilder.buildOutputJars.add(classJar);
}
}
workspaceBuilder.generatedJarsFromSourceTargets.addAll(javaIdeInfo.generatedJars.stream().map(BlazeJarLibrary::new).collect(Collectors.toList()));
if (javaIdeInfo.filteredGenJar != null) {
workspaceBuilder.generatedJarsFromSourceTargets.add(new BlazeJarLibrary(javaIdeInfo.filteredGenJar));
}
for (BlazeJavaSyncAugmenter augmenter : augmenters) {
augmenter.addJarsForSourceTarget(workspaceLanguageSettings, projectViewSet, target, workspaceBuilder.outputJarsFromSourceTargets.get(targetKey), workspaceBuilder.generatedJarsFromSourceTargets);
}
}
Aggregations