diff --git a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelClasspathContainer.java b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelClasspathContainer.java index 9d8469d3..b983bde5 100644 --- a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelClasspathContainer.java +++ b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelClasspathContainer.java @@ -35,7 +35,10 @@ */ package com.salesforce.bazel.eclipse.core.classpath; +import static java.util.Objects.requireNonNull; + import java.io.Serializable; +import java.util.Arrays; import org.eclipse.core.runtime.IPath; import org.eclipse.jdt.core.IClasspathContainer; @@ -49,14 +52,16 @@ */ public class BazelClasspathContainer implements IClasspathContainer, Serializable { - private static final long serialVersionUID = 390898179243551621L; + private static final long serialVersionUID = 390898179243551622L; private final IPath path; private final IClasspathEntry[] classpath; + private final IClasspathEntry[] transitiveClasspath; - public BazelClasspathContainer(IPath path, IClasspathEntry[] classpath) { + public BazelClasspathContainer(IPath path, IClasspathEntry[] classpath, IClasspathEntry[] transitiveClasspath) { this.path = path; - this.classpath = classpath; + this.classpath = requireNonNull(classpath); + this.transitiveClasspath = requireNonNull(transitiveClasspath); } @Override @@ -69,6 +74,15 @@ public String getDescription() { return "Bazel Dependencies"; } + public IClasspathEntry[] getFullClasspath() { + if (transitiveClasspath.length == 0) { + return classpath; + } + var fullClasspath = Arrays.copyOf(classpath, classpath.length + transitiveClasspath.length); + System.arraycopy(transitiveClasspath, 0, fullClasspath, classpath.length, transitiveClasspath.length); + return fullClasspath; + } + @Override public int getKind() { return IClasspathContainer.K_APPLICATION; @@ -78,4 +92,13 @@ public int getKind() { public IPath getPath() { return path; } + + /** + * A array of transitive classpath entries. + * + * @return + */ + public IClasspathEntry[] getTransitiveEntries() { + return transitiveClasspath; + } } diff --git a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelClasspathContainerRuntimeResolver.java b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelClasspathContainerRuntimeResolver.java index 8395d39d..2fcce786 100644 --- a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelClasspathContainerRuntimeResolver.java +++ b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelClasspathContainerRuntimeResolver.java @@ -129,7 +129,7 @@ private void populateWithSavedContainer(IJavaProject project, Collectionnull) * @throws CoreException */ - public IClasspathContainer getSavedContainer(IProject project) throws CoreException { + public BazelClasspathContainer getSavedContainer(IProject project) throws CoreException { var containerStateFile = getContainerStateFile(project); if (!containerStateFile.exists()) { return null; @@ -239,8 +239,8 @@ TargetProvisioningStrategy getTargetProvisioningStrategy(BazelWorkspace bazelWor * @param monitor * @throws CoreException */ - public void patchClasspathContainer(BazelProject bazelProject, List classpath, - IProgressMonitor progress) throws CoreException { + public void patchClasspathContainer(BazelProject bazelProject, ClasspathHolder classpath, IProgressMonitor progress) + throws CoreException { var monitor = SubMonitor.convert(progress); try { monitor.beginTask("Patchig classpath: " + bazelProject.getName(), 2); @@ -300,8 +300,10 @@ public void persistAttachedSourcesAndJavadoc(IJavaProject project, IClasspathCon bazelProject.getBazelWorkspace(), DEFAULT_CLASSPATH, monitor.split(1, SUPPRESS_ALL_LABELS)); - entries = - configureClasspathWithSourceAttachments(classpaths.get(bazelProject), null /* no props */, monitor); + entries = configureClasspathWithSourceAttachments( + classpaths.get(bazelProject).compile(), + null /* no props */, + monitor); for (IClasspathEntry entry : entries) { if (IClasspathEntry.CPE_LIBRARY == entry.getEntryKind()) { var path = entry.getPath().toPortableString(); @@ -338,16 +340,22 @@ public void persistAttachedSourcesAndJavadoc(IJavaProject project, IClasspathCon } } - void saveAndSetContainer(IJavaProject javaProject, Collection classpath, IProgressMonitor monitor) + void saveAndSetContainer(IJavaProject javaProject, ClasspathHolder classpath, IProgressMonitor monitor) throws CoreException, JavaModelException { var containerEntry = getBazelContainerEntry(javaProject); var path = containerEntry != null ? containerEntry.getPath() : new Path(BazelCoreSharedContstants.CLASSPATH_CONTAINER_ID); var sourceAttachmentProperties = getSourceAttachmentProperties(javaProject.getProject()); + var transativeClasspath = classpath.transitive().stream().map(ClasspathEntry::build).collect(toList()); + var container = new BazelClasspathContainer( path, - configureClasspathWithSourceAttachments(classpath, sourceAttachmentProperties, monitor.slice(1))); + configureClasspathWithSourceAttachments( + classpath.compile(), + sourceAttachmentProperties, + monitor.slice(1)), + transativeClasspath.toArray(new IClasspathEntry[transativeClasspath.size()])); JavaCore.setClasspathContainer( container.getPath(), @@ -359,7 +367,7 @@ void saveAndSetContainer(IJavaProject javaProject, Collection cl saveContainerState(javaProject.getProject(), container); } - private void saveContainerState(IProject project, IClasspathContainer container) throws CoreException { + private void saveContainerState(IProject project, BazelClasspathContainer container) throws CoreException { var containerStateFile = getContainerStateFile(project); try (var is = new FileOutputStream(containerStateFile)) { new BazelClasspathContainerSaveHelper().writeContainer(container, is); diff --git a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/ClasspathHolder.java b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/ClasspathHolder.java new file mode 100644 index 00000000..61cadf94 --- /dev/null +++ b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/ClasspathHolder.java @@ -0,0 +1,71 @@ +/*- + * Copyright (c) 2024 Salesforce and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Salesforce - adapted from M2E, JDT or other Eclipse project + */ +package com.salesforce.bazel.eclipse.core.classpath; + +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.eclipse.core.runtime.IPath; + +import com.salesforce.bazel.eclipse.core.model.discovery.classpath.ClasspathEntry; + +/** + * Represents a targets classpath as two parts, compile being the classpath entries that are loaded into the project + * model, and transtative as classpaths that are part of the targets runtime, but are not to be loaded in the project + * model. + */ +public record ClasspathHolder(Collection compile, Collection transitive) { + + public static class ClasspathHolderBuilder { + // Preserve classpath order. Add leaf level dependencies first and work the way up. This + // prevents conflicts when a JAR repackages it's dependencies. In such a case we prefer to + // resolve symbols from the original JAR rather than the repackaged version. + // Using accessOrdered LinkedHashMap because jars that are present in `workspaceBuilder.jdeps` + // and in `workspaceBuilder.directDeps`, we want to treat it as a directDep + private final Map compileEntries = + new LinkedHashMap<>(/* initialCapacity= */ 32, /* loadFactor= */ 0.75f, /* accessOrder= */ true); + private final Map transitiveEntries = + new LinkedHashMap<>(/* initialCapacity= */ 32, /* loadFactor= */ 0.75f, /* accessOrder= */ true); + private boolean hasUnloadedEntries = false; + + private final boolean partialClasspathEnabled; + + public ClasspathHolderBuilder(boolean partialClasspathEnabled) { + this.partialClasspathEnabled = partialClasspathEnabled; + } + + public ClasspathHolder build() { + return new ClasspathHolder( + compileEntries.values(), + hasUnloadedEntries ? transitiveEntries.values() : Collections.emptyList()); + } + + public void put(IPath path, ClasspathEntry entry) { + compileEntries.put(path, entry); + } + + public void putIfAbsent(IPath path, ClasspathEntry entry) { + compileEntries.putIfAbsent(path, entry); + } + + public void putUnloadedIfAbsent(IPath path, ClasspathEntry entry) { + if (!compileEntries.containsKey(path)) { + transitiveEntries.putIfAbsent(path, entry); + hasUnloadedEntries = true; + } + } + } +} diff --git a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/edits/AddDependenciesJob.java b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/edits/AddDependenciesJob.java index e16a2dfa..598adc1d 100644 --- a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/edits/AddDependenciesJob.java +++ b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/edits/AddDependenciesJob.java @@ -6,6 +6,7 @@ import static java.util.stream.Collectors.toList; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.stream.Stream; @@ -21,6 +22,7 @@ import org.eclipse.core.runtime.jobs.Job; import com.google.idea.blaze.base.model.primitives.Label; +import com.salesforce.bazel.eclipse.core.classpath.ClasspathHolder; import com.salesforce.bazel.eclipse.core.classpath.InitializeOrRefreshClasspathJob; import com.salesforce.bazel.eclipse.core.model.BazelProject; import com.salesforce.bazel.eclipse.core.model.BazelTarget; @@ -147,7 +149,11 @@ public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreExcepti } if (modified) { - classpathManager.patchClasspathContainer(bazelProject, classpath, monitor); + var transitive = Arrays.stream(container.getTransitiveEntries()) + .map(ClasspathEntry::fromExisting) + .collect(toList()); + classpathManager + .patchClasspathContainer(bazelProject, new ClasspathHolder(classpath, transitive), monitor); } return Status.OK_STATUS; } diff --git a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/BaseProvisioningStrategy.java b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/BaseProvisioningStrategy.java index f72fa4e7..6bae00f8 100644 --- a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/BaseProvisioningStrategy.java +++ b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/BaseProvisioningStrategy.java @@ -25,6 +25,7 @@ import static java.util.function.Predicate.not; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; +import static java.util.stream.Collectors.toSet; import static org.eclipse.core.runtime.Platform.PI_RUNTIME; import static org.eclipse.core.runtime.Platform.PREF_LINE_SEPARATOR; import static org.eclipse.jdt.core.IClasspathAttribute.ADD_EXPORTS; @@ -39,6 +40,7 @@ import java.nio.file.Files; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; @@ -106,6 +108,7 @@ import com.salesforce.bazel.eclipse.core.model.discovery.projects.LabelEntry; import com.salesforce.bazel.eclipse.core.util.trace.TracingSubMonitor; import com.salesforce.bazel.sdk.command.BazelCQueryWithStarlarkExpressionCommand; +import com.salesforce.bazel.sdk.command.BazelQueryForLabelsCommand; import com.salesforce.bazel.sdk.model.BazelLabel; /** @@ -118,6 +121,7 @@ public abstract class BaseProvisioningStrategy implements TargetProvisioningStra private static final String JRE_SYSTEM_LIBRARY = "jre_system_library"; private static final String JRE_SYSTEM_LIBRARY_RUNTIME = "current_java_runtime"; private static final String JRE_SYSTEM_LIBRARY_EE = "execution_environment"; + private static final String CLASSPATH_DEPTH = "classpath_depth"; private static final String JAVAC_OPT_ADD_OPENS = "--add-opens"; private static final String JAVAC_OPT_ADD_EXPORTS = "--add-exports"; @@ -132,18 +136,65 @@ public abstract class BaseProvisioningStrategy implements TargetProvisioningStra private static Logger LOG = LoggerFactory.getLogger(BaseProvisioningStrategy.class); - private BazelProjectFileSystemMapper fileSystemMapper; + /** + * Creates a problem marker of type {@link BazelCoreSharedContstants#CLASSPATH_CONTAINER_PROBLEM_MARKER} for the + * given status. + * + * @param project + * the project to create the marker at (must not be null) + * @param status + * the status to create the marker for (must not be null) + * @return the created marker (never null) + * @throws CoreException + */ + static IMarker createClasspathContainerProblem(BazelProject project, IStatus status) throws CoreException { + return createMarker(project.getProject(), CLASSPATH_CONTAINER_PROBLEM_MARKER, status); + } + static IMarker createMarker(IResource resource, String type, IStatus status) throws CoreException { + var message = status.getMessage(); + if (status.isMultiStatus()) { + var children = status.getChildren(); + if ((children != null) && (children.length > 0)) { + message = children[0].getMessage(); + } + } + if ((message == null) && (status.getException() != null)) { + message = status.getException().getMessage(); + } + + if (message.length() >= 21000) { + // marker content is limited in length + message = message.substring(0, 20997).concat("..."); + } + + Map markerAttributes = new HashMap<>(); + markerAttributes.put(IMarker.MESSAGE, message); + markerAttributes.put(IMarker.SOURCE_ID, "Bazel Project Provisioning"); + + if (status.matches(IStatus.ERROR)) { + markerAttributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR)); + } else if (status.matches(IStatus.WARNING)) { + markerAttributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_WARNING)); + } else if (status.matches(IStatus.INFO)) { + markerAttributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_INFO)); + } + + return resource.createMarker(type, markerAttributes); + } + + private BazelProjectFileSystemMapper fileSystemMapper; /** * Eclipse VM representing the currecurrent_java_toolchain */ protected IVMInstall javaToolchainVm; protected String javaToolchainSourceVersion; + protected String javaToolchainTargetVersion; /** - * Eclipse VM representing current_java_runtime + * Eclipse VM representing current_jaclasspath_depthva_runtime */ protected IVMInstall javaRuntimeVm; @@ -573,6 +624,46 @@ protected void analyzeProjectInfo(BazelProject project, JavaProjectInfo javaInfo } } + /** + * Calculates the java_library and java_imports for the provided targets, limited by the depth + * + * @param workspace + * the bazel workspace + * @param targetsToBuild + * a list of targets as part of the build to query their dependencies + * @param dependencyDepth + * the depth in the dependency graph to traverse and include in the result + * @return a set of java_library and java_imports, or null, if partial classpath is disabled + * @throws CoreException + */ + protected final Set calculateWorkspaceDependencies(BazelWorkspace workspace, + List targetsToBuild) throws CoreException { + + var classpathDepth = getClasspathDepthValue(workspace); + if (classpathDepth <= 0) { + return null; + } + if (classpathDepth == 1) { + return Collections.emptySet(); + } + var targetLabels = targetsToBuild.stream().map(BazelLabel::toString).collect(joining(" + ")); + return workspace.getCommandExecutor() + .runQueryWithoutLock( + new BazelQueryForLabelsCommand( + workspace.getLocation().toPath(), + format( + "kind(java_library, deps(%s, %d)) + kind(java_import, deps(%s, %d))", + targetLabels, + classpathDepth, + targetLabels, + classpathDepth), + true, + format("Querying for depdendencies for projects: %s", targetLabels))) + .stream() + .map(BazelLabel::new) + .collect(toSet()); + } + /** * Collects base Java information for a given project and the targets it represents. *

@@ -795,21 +886,6 @@ protected IMarker createBuildPathProblem(BazelProject project, IStatus status) t return createMarker(project.getProject(), BUILDPATH_PROBLEM_MARKER, status); } - /** - * Creates a problem marker of type {@link BazelCoreSharedContstants#CLASSPATH_CONTAINER_PROBLEM_MARKER} for the - * given status. - * - * @param project - * the project to create the marker at (must not be null) - * @param status - * the status to create the marker for (must not be null) - * @return the created marker (never null) - * @throws CoreException - */ - protected IMarker createClasspathContainerProblem(BazelProject project, IStatus status) throws CoreException { - return createMarker(project.getProject(), CLASSPATH_CONTAINER_PROBLEM_MARKER, status); - } - /** * Creates a folder hierarchy and marks them as derived (because they are generated and should not go into SCM) * @@ -840,38 +916,6 @@ protected final void createFolderAndParents(final IContainer folder, IProgressMo } } - protected IMarker createMarker(IResource resource, String type, IStatus status) throws CoreException { - var message = status.getMessage(); - if (status.isMultiStatus()) { - var children = status.getChildren(); - if ((children != null) && (children.length > 0)) { - message = children[0].getMessage(); - } - } - if ((message == null) && (status.getException() != null)) { - message = status.getException().getMessage(); - } - - if (message.length() >= 21000) { - // marker content is limited in length - message = message.substring(0, 20997).concat("..."); - } - - Map markerAttributes = new HashMap<>(); - markerAttributes.put(IMarker.MESSAGE, message); - markerAttributes.put(IMarker.SOURCE_ID, "Bazel Project Provisioning"); - - if (status.matches(IStatus.ERROR)) { - markerAttributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR)); - } else if (status.matches(IStatus.WARNING)) { - markerAttributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_WARNING)); - } else if (status.matches(IStatus.INFO)) { - markerAttributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_INFO)); - } - - return resource.createMarker(type, markerAttributes); - } - /** * Creates an Eclipse project representing the specified owner. *

@@ -1204,6 +1248,22 @@ private void garbageCollectFolderContent(IFolder folder, Set membersT } } + private final int getClasspathDepthValue(BazelWorkspace workspace) throws CoreException { + var classpathDepthStr = + workspace.getBazelProjectView().targetProvisioningSettings().getOrDefault(CLASSPATH_DEPTH, "0"); + var classpathDepth = 0; + try { + classpathDepth = Integer.parseInt(classpathDepthStr); + } catch (NumberFormatException e) { + LOG.warn( + "Invalid integer for target provisioning setting {} (falling back to default 0): {}", + CLASSPATH_DEPTH, + e.getMessage(), + e); + } + return classpathDepth; + } + protected IWorkspace getEclipseWorkspace() { return ResourcesPlugin.getWorkspace(); } diff --git a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/BuildFileAndVisibilityDrivenProvisioningStrategy.java b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/BuildFileAndVisibilityDrivenProvisioningStrategy.java index bd251444..c9338e45 100644 --- a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/BuildFileAndVisibilityDrivenProvisioningStrategy.java +++ b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/BuildFileAndVisibilityDrivenProvisioningStrategy.java @@ -8,11 +8,11 @@ import static java.util.stream.Collectors.groupingBy; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toCollection; -import static java.util.stream.Collectors.toSet; import static org.eclipse.core.resources.IResource.DEPTH_ZERO; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; @@ -37,6 +37,7 @@ import com.google.idea.blaze.base.model.primitives.WildcardTargetPattern; import com.google.idea.blaze.base.model.primitives.WorkspacePath; import com.salesforce.bazel.eclipse.core.classpath.BazelClasspathScope; +import com.salesforce.bazel.eclipse.core.classpath.ClasspathHolder; import com.salesforce.bazel.eclipse.core.model.BazelPackage; import com.salesforce.bazel.eclipse.core.model.BazelProject; import com.salesforce.bazel.eclipse.core.model.BazelTarget; @@ -194,7 +195,7 @@ public boolean isAllowedDependencyPath(BazelPackage fromPackage, BazelPackage to new TargetDiscoveryAndProvisioningExtensionLookup(); @Override - public Map> computeClasspaths(Collection bazelProjects, + public Map computeClasspaths(Collection bazelProjects, BazelWorkspace workspace, BazelClasspathScope scope, IProgressMonitor progress) throws CoreException { LOG.debug("Computing classpath for projects: {}", bazelProjects); try { @@ -238,7 +239,7 @@ public Map> computeClasspaths(Collectio // use the hints to avoid circular dependencies between projects in Eclipse var circularDependenciesHelper = new CircularDependenciesHelper(workspace.getBazelProjectView().targets()); - Map> classpathsByProject = new HashMap<>(); + Map classpathsByProject = new HashMap<>(); for (BazelProject bazelProject : bazelProjects) { monitor.subTask("Analyzing: " + bazelProject); monitor.checkCanceled(); @@ -248,29 +249,17 @@ public Map> computeClasspaths(Collectio // query for rdeps to find classpath exclusions var projectTargets = activeTargetsPerProject.get(bazelProject); - var rdeps = workspace.getCommandExecutor() - .runQueryWithoutLock( - new BazelQueryForLabelsCommand( - workspaceRoot, - format( - "kind(java_library, rdeps(//..., %s))", - projectTargets.stream().map(BazelLabel::toString).collect(joining(" + "))), - true, - format( - "Querying for reverse dependencies of '%s' for classpath computation", - bazelProject.getName()))) - .stream() - .map(BazelLabel::new) - .collect(toSet()); + var targets = projectTargets.stream().map(BazelLabel::toString).collect(joining(" + ")); // get all accessible targets based on visibility Set allVisibleTargets = workspace.getCommandExecutor() .runQueryWithoutLock( new BazelQueryForLabelsCommand( workspaceRoot, format( - "kind(java_library, visible(%s, //...))", - projectTargets.stream().map(BazelLabel::toString).collect(joining(" + "))), + "kind(java_library, visible(%s, //...)) except kind(java_library, rdeps(//..., %s))", + targets, + targets), true, format( "Querying for Java targets visibile to '%s' for classpath computation", @@ -295,7 +284,6 @@ public Map> computeClasspaths(Collectio // get the remaining list of visible deps based on workspace dependency graph var visibleDeps = new ArrayList<>(allVisibleTargets); - visibleDeps.removeAll(rdeps); // exclude reverse deps visibleDeps.removeAll(projectTargets); // exclude project targets (avoid dependencies on itself) // compute the classpath @@ -379,7 +367,7 @@ public Map> computeClasspaths(Collectio } } - classpathsByProject.put(bazelProject, classpath); + classpathsByProject.put(bazelProject, new ClasspathHolder(classpath, Collections.emptyList())); monitor.worked(1); } diff --git a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/JavaAspectsClasspathInfo.java b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/JavaAspectsClasspathInfo.java index 97365658..138d265d 100644 --- a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/JavaAspectsClasspathInfo.java +++ b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/JavaAspectsClasspathInfo.java @@ -16,6 +16,7 @@ import static java.lang.String.format; import static java.nio.file.Files.exists; +import static java.nio.file.Files.isRegularFile; import static java.util.stream.Collectors.toList; import static org.eclipse.core.runtime.IPath.forPosix; import static org.eclipse.core.runtime.IPath.fromPath; @@ -27,21 +28,19 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; -import java.util.Map; import java.util.Set; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.jdt.core.IAccessRule; import org.eclipse.jdt.core.IClasspathAttribute; +import org.eclipse.jdt.core.IClasspathEntry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,6 +59,8 @@ import com.google.idea.blaze.java.JavaBlazeRules; import com.google.idea.blaze.java.sync.importer.ExecutionPathHelper; import com.google.idea.blaze.java.sync.model.BlazeJarLibrary; +import com.salesforce.bazel.eclipse.core.classpath.ClasspathHolder; +import com.salesforce.bazel.eclipse.core.classpath.ClasspathHolder.ClasspathHolderBuilder; import com.salesforce.bazel.eclipse.core.model.BazelProject; import com.salesforce.bazel.eclipse.core.model.BazelTarget; import com.salesforce.bazel.eclipse.core.model.BazelWorkspace; @@ -67,6 +68,7 @@ import com.salesforce.bazel.eclipse.core.model.discovery.classpath.ClasspathEntry; import com.salesforce.bazel.sdk.command.BazelBuildWithIntelliJAspectsCommand; import com.salesforce.bazel.sdk.command.querylight.BazelRuleAttribute; +import com.salesforce.bazel.sdk.model.BazelLabel; /** * Holds information for computing Java classpath configuration of a target or a package. @@ -134,9 +136,22 @@ static boolean isJavaProtoTarget(TargetIdeInfo target) { /** set of exports (insertion order is not relevant) */ final Set