Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
[fix] ijars are included in libraries
Browse files Browse the repository at this point in the history
even better

now it works!

does it work?


Merge-request: BAZEL-MR-941
Merged-by: Marcin Abramowicz <marcin.abramowicz@jetbrains.com>
  • Loading branch information
abrams27 authored and qodana-bot committed Mar 20, 2024
1 parent b9598d9 commit c66358e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
14 changes: 9 additions & 5 deletions aspects/rules/jvm/jvm_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ def map_with_resolve_files(f, xs):
return results, resolve_files

def get_interface_jars(output):
if hasattr(output, "compile_jar") and output.compile_jar:
return [output.compile_jar]
elif hasattr(output, "ijar") and output.ijar:
if hasattr(output, "ijar") and output.ijar:
return [output.ijar]
else:
return []

def get_binary_jars(output):
if output.class_jar:
return [output.class_jar]
else:
return []

def get_source_jars(output):
if hasattr(output, "source_jars"):
source_jars = output.source_jars
Expand Down Expand Up @@ -74,10 +78,10 @@ def get_generated_jars(provider):
return [], []

def to_jvm_outputs(output):
if output == None or output.class_jar == None:
if output == None:
return None

binary_jars = [output.class_jar]
binary_jars = get_binary_jars(output)
interface_jars = get_interface_jars(output)
source_jars = get_source_jars(output)
output = struct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ch.epfl.scala.bsp4j.BuildTargetIdentifier
public data class LibraryItem(
val id: BuildTargetIdentifier,
val dependencies: List<BuildTargetIdentifier>,
val ijars: List<String>,
val jars: List<String>,
val sourceJars: List<String>,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import org.jetbrains.bsp.bazel.workspacecontext.WorkspaceContextProvider
import java.net.URI
import java.nio.file.Path
import java.nio.file.Paths
import kotlin.io.path.exists
import kotlin.io.path.name
import kotlin.io.path.relativeToOrNull
import kotlin.io.path.toPath
Expand Down Expand Up @@ -122,8 +123,9 @@ class BspProjectMapper(
LibraryItem(
id = BuildTargetIdentifier(it.label),
dependencies = it.dependencies.map { dep -> BuildTargetIdentifier(dep) },
jars = it.outputs.map { uri -> uri.toString() },
sourceJars = it.sources.map { uri -> uri.toString() },
ijars = it.interfaceJars.filter { o -> o.toPath().exists() }.map { o -> o.toString() },
jars = it.outputs.filter { o -> o.toPath().exists() }.map { uri -> uri.toString() },
sourceJars = it.sources.filter { o -> o.toPath().exists() }.map { uri -> uri.toString() },
)
}
return WorkspaceLibrariesResult(libraries)
Expand Down

0 comments on commit c66358e

Please sign in to comment.