IJI-3334 Bazel: generate bazel-targets.json for community, library part

also add assertions on library paths in bazel-targets.json

GitOrigin-RevId: 5173172c1eb5ebf8b61b4ff3f74bab5a2e583f98
This commit is contained in:
Leonid Shalupov
2025-12-08 17:36:58 +00:00
committed by intellij-monorepo-bot
parent 1883fde710
commit 15509b5df7
11 changed files with 383 additions and 142 deletions
+18
View File
@@ -0,0 +1,18 @@
:<<"::CMDLITERAL"
@ECHO OFF
GOTO :CMDSCRIPT
::CMDLITERAL
set -eu
root="$(cd "$(dirname "$0")"; pwd)"
cd "$root"
exec /bin/bash "$root/bazel.cmd" build //... @rules_jvm//... @lib//...
:CMDSCRIPT
pushd "%~dp0"
call "%~dp0\bazel.cmd" build //... @rules_jvm//... @lib//...
set _exit_code=%ERRORLEVEL%
popd
EXIT /B %_exit_code%
+1
View File
@@ -5,3 +5,4 @@
kotlin-plugin*.zip
dependencies/buildSrc/build
/jvm-rules/.claude/settings.local.json
/bazel-targets.json
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
set -eux
export RUN_WITHOUT_ULTIMATE_ROOT=true
script_dir="$(cd "$(dirname "$0")"; pwd)"
cd "$script_dir/.."
output_base=$(./bazel.cmd info output_base)
echo "Bazel output base: $output_base"
./build/jpsModelToBazelCommunityOnly.cmd
./bazel-build-all-community.cmd
cd "$script_dir/../platform/build-scripts/bazel"
exec /bin/bash "../../../bazel.cmd" run "$@" //:jps-to-bazel -- "--assert-all-outputs-exist-with-output-base=$output_base"
+58 -28
View File
@@ -5168,67 +5168,80 @@ java_library(
jvm_import(
name = "io_nlopez_compose_rules-detekt-0_4_27_http_import",
jar = "@io_nlopez_compose_rules-detekt-0_4_27_http//file"
jar = "@io_nlopez_compose_rules-detekt-0_4_27_http//file",
source_jar = "@io_nlopez_compose_rules-detekt-0_4_27-sources_http//file"
)
jvm_import(
name = "io_gitlab_arturbosch_detekt-detekt-core-1_23_8_http_import",
jar = "@io_gitlab_arturbosch_detekt-detekt-core-1_23_8_http//file"
jar = "@io_gitlab_arturbosch_detekt-detekt-core-1_23_8_http//file",
source_jar = "@io_gitlab_arturbosch_detekt-detekt-core-1_23_8-sources_http//file"
)
jvm_import(
name = "io_gitlab_arturbosch_detekt-detekt-api-1_23_8_http_import",
jar = "@io_gitlab_arturbosch_detekt-detekt-api-1_23_8_http//file"
jar = "@io_gitlab_arturbosch_detekt-detekt-api-1_23_8_http//file",
source_jar = "@io_gitlab_arturbosch_detekt-detekt-api-1_23_8-sources_http//file"
)
jvm_import(
name = "dev_drewhamilton_poko-poko-annotations-jvm-0_17_1_http_import",
jar = "@dev_drewhamilton_poko-poko-annotations-jvm-0_17_1_http//file"
jar = "@dev_drewhamilton_poko-poko-annotations-jvm-0_17_1_http//file",
source_jar = "@dev_drewhamilton_poko-poko-annotations-jvm-0_17_1-sources_http//file"
)
jvm_import(
name = "io_gitlab_arturbosch_detekt-detekt-parser-1_23_8_http_import",
jar = "@io_gitlab_arturbosch_detekt-detekt-parser-1_23_8_http//file"
jar = "@io_gitlab_arturbosch_detekt-detekt-parser-1_23_8_http//file",
source_jar = "@io_gitlab_arturbosch_detekt-detekt-parser-1_23_8-sources_http//file"
)
jvm_import(
name = "io_github_davidburstrom_contester-contester-breakpoint-0_2_0_http_import",
jar = "@io_github_davidburstrom_contester-contester-breakpoint-0_2_0_http//file"
jar = "@io_github_davidburstrom_contester-contester-breakpoint-0_2_0_http//file",
source_jar = "@io_github_davidburstrom_contester-contester-breakpoint-0_2_0-sources_http//file"
)
jvm_import(
name = "io_gitlab_arturbosch_detekt-detekt-tooling-1_23_8_http_import",
jar = "@io_gitlab_arturbosch_detekt-detekt-tooling-1_23_8_http//file"
jar = "@io_gitlab_arturbosch_detekt-detekt-tooling-1_23_8_http//file",
source_jar = "@io_gitlab_arturbosch_detekt-detekt-tooling-1_23_8-sources_http//file"
)
jvm_import(
name = "org_snakeyaml-snakeyaml-engine-2_7_http_import",
jar = "@org_snakeyaml-snakeyaml-engine-2_7_http//file"
jar = "@org_snakeyaml-snakeyaml-engine-2_7_http//file",
source_jar = "@org_snakeyaml-snakeyaml-engine-2_7-sources_http//file"
)
jvm_import(
name = "io_gitlab_arturbosch_detekt-detekt-metrics-1_23_8_http_import",
jar = "@io_gitlab_arturbosch_detekt-detekt-metrics-1_23_8_http//file"
jar = "@io_gitlab_arturbosch_detekt-detekt-metrics-1_23_8_http//file",
source_jar = "@io_gitlab_arturbosch_detekt-detekt-metrics-1_23_8-sources_http//file"
)
jvm_import(
name = "io_gitlab_arturbosch_detekt-detekt-psi-utils-1_23_8_http_import",
jar = "@io_gitlab_arturbosch_detekt-detekt-psi-utils-1_23_8_http//file"
jar = "@io_gitlab_arturbosch_detekt-detekt-psi-utils-1_23_8_http//file",
source_jar = "@io_gitlab_arturbosch_detekt-detekt-psi-utils-1_23_8-sources_http//file"
)
jvm_import(
name = "io_gitlab_arturbosch_detekt-detekt-utils-1_23_8_http_import",
jar = "@io_gitlab_arturbosch_detekt-detekt-utils-1_23_8_http//file"
jar = "@io_gitlab_arturbosch_detekt-detekt-utils-1_23_8_http//file",
source_jar = "@io_gitlab_arturbosch_detekt-detekt-utils-1_23_8-sources_http//file"
)
jvm_import(
name = "io_nlopez_compose_rules-common-detekt-0_4_27_http_import",
jar = "@io_nlopez_compose_rules-common-detekt-0_4_27_http//file"
jar = "@io_nlopez_compose_rules-common-detekt-0_4_27_http//file",
source_jar = "@io_nlopez_compose_rules-common-detekt-0_4_27-sources_http//file"
)
jvm_import(
name = "libraries-dokka-jetbrains-dokka-analysis-kotlin-descriptors",
jar = "@org_jetbrains_dokka-analysis-kotlin-descriptors-2_0_0_http//file",
source_jar = "@org_jetbrains_dokka-analysis-kotlin-descriptors-2_0_0-sources_http//file",
visibility = ["//visibility:public"]
)
@@ -5242,6 +5255,7 @@ java_library(
jvm_import(
name = "libraries-dokka-jetbrains-dokka-cli",
jar = "@org_jetbrains_dokka-dokka-cli-2_0_0_http//file",
source_jar = "@org_jetbrains_dokka-dokka-cli-2_0_0-sources_http//file",
visibility = ["//visibility:public"]
)
@@ -5267,27 +5281,32 @@ java_library(
jvm_import(
name = "org_jetbrains_dokka-javadoc-plugin-2_0_0_http_import",
jar = "@org_jetbrains_dokka-javadoc-plugin-2_0_0_http//file"
jar = "@org_jetbrains_dokka-javadoc-plugin-2_0_0_http//file",
source_jar = "@org_jetbrains_dokka-javadoc-plugin-2_0_0-sources_http//file"
)
jvm_import(
name = "org_jetbrains_dokka-dokka-base-2_0_0_http_import",
jar = "@org_jetbrains_dokka-dokka-base-2_0_0_http//file"
jar = "@org_jetbrains_dokka-dokka-base-2_0_0_http//file",
source_jar = "@org_jetbrains_dokka-dokka-base-2_0_0-sources_http//file"
)
jvm_import(
name = "org_jetbrains_dokka-kotlin-as-java-plugin-2_0_0_http_import",
jar = "@org_jetbrains_dokka-kotlin-as-java-plugin-2_0_0_http//file"
jar = "@org_jetbrains_dokka-kotlin-as-java-plugin-2_0_0_http//file",
source_jar = "@org_jetbrains_dokka-kotlin-as-java-plugin-2_0_0-sources_http//file"
)
jvm_import(
name = "com_soywiz_korlibs_korte-korte-jvm-4_0_10_http_import",
jar = "@com_soywiz_korlibs_korte-korte-jvm-4_0_10_http//file"
jar = "@com_soywiz_korlibs_korte-korte-jvm-4_0_10_http//file",
source_jar = "@com_soywiz_korlibs_korte-korte-jvm-4_0_10-sources_http//file"
)
jvm_import(
name = "org_jetbrains_kotlinx-kotlinx-html-jvm-0_9_1_http_import",
jar = "@org_jetbrains_kotlinx-kotlinx-html-jvm-0_9_1_http//file"
jar = "@org_jetbrains_kotlinx-kotlinx-html-jvm-0_9_1_http//file",
source_jar = "@org_jetbrains_kotlinx-kotlinx-html-jvm-0_9_1-sources_http//file"
)
java_library(
@@ -8234,7 +8253,8 @@ java_library(
jvm_import(
name = "io_netty-netty-tcnative-boringssl-static-2_0_73_Final_http_import",
jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final_http//file"
jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final_http//file",
source_jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-sources_http//file"
)
jvm_import(
@@ -8245,27 +8265,32 @@ jvm_import(
jvm_import(
name = "io_netty-netty-tcnative-boringssl-static-2_0_73_Final-linux-x86_64_http_import",
jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-linux-x86_64_http//file"
jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-linux-x86_64_http//file",
source_jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-sources_http//file"
)
jvm_import(
name = "io_netty-netty-tcnative-boringssl-static-2_0_73_Final-linux-aarch_64_http_import",
jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-linux-aarch_64_http//file"
jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-linux-aarch_64_http//file",
source_jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-sources_http//file"
)
jvm_import(
name = "io_netty-netty-tcnative-boringssl-static-2_0_73_Final-osx-x86_64_http_import",
jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-osx-x86_64_http//file"
jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-osx-x86_64_http//file",
source_jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-sources_http//file"
)
jvm_import(
name = "io_netty-netty-tcnative-boringssl-static-2_0_73_Final-osx-aarch_64_http_import",
jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-osx-aarch_64_http//file"
jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-osx-aarch_64_http//file",
source_jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-sources_http//file"
)
jvm_import(
name = "io_netty-netty-tcnative-boringssl-static-2_0_73_Final-windows-x86_64_http_import",
jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-windows-x86_64_http//file"
jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-windows-x86_64_http//file",
source_jar = "@io_netty-netty-tcnative-boringssl-static-2_0_73_Final-sources_http//file"
)
jvm_import(
@@ -8748,27 +8773,32 @@ jvm_import(
jvm_import(
name = "io_netty-netty-transport-native-epoll-4_2_0_RC2-linux-x86_64_http_import",
jar = "@io_netty-netty-transport-native-epoll-4_2_0_RC2-linux-x86_64_http//file"
jar = "@io_netty-netty-transport-native-epoll-4_2_0_RC2-linux-x86_64_http//file",
source_jar = "@io_netty-netty-transport-native-epoll-4_2_0_RC2-sources_http//file"
)
jvm_import(
name = "io_netty-netty-transport-native-epoll-4_2_0_RC2-linux-aarch_64_http_import",
jar = "@io_netty-netty-transport-native-epoll-4_2_0_RC2-linux-aarch_64_http//file"
jar = "@io_netty-netty-transport-native-epoll-4_2_0_RC2-linux-aarch_64_http//file",
source_jar = "@io_netty-netty-transport-native-epoll-4_2_0_RC2-sources_http//file"
)
jvm_import(
name = "io_netty-netty-transport-native-epoll-4_2_0_RC2-linux-riscv64_http_import",
jar = "@io_netty-netty-transport-native-epoll-4_2_0_RC2-linux-riscv64_http//file"
jar = "@io_netty-netty-transport-native-epoll-4_2_0_RC2-linux-riscv64_http//file",
source_jar = "@io_netty-netty-transport-native-epoll-4_2_0_RC2-sources_http//file"
)
jvm_import(
name = "io_netty-netty-transport-native-kqueue-4_2_0_RC2-osx-x86_64_http_import",
jar = "@io_netty-netty-transport-native-kqueue-4_2_0_RC2-osx-x86_64_http//file"
jar = "@io_netty-netty-transport-native-kqueue-4_2_0_RC2-osx-x86_64_http//file",
source_jar = "@io_netty-netty-transport-native-kqueue-4_2_0_RC2-sources_http//file"
)
jvm_import(
name = "io_netty-netty-transport-native-kqueue-4_2_0_RC2-osx-aarch_64_http_import",
jar = "@io_netty-netty-transport-native-kqueue-4_2_0_RC2-osx-aarch_64_http//file"
jar = "@io_netty-netty-transport-native-kqueue-4_2_0_RC2-osx-aarch_64_http//file",
source_jar = "@io_netty-netty-transport-native-kqueue-4_2_0_RC2-sources_http//file"
)
java_library(
+133 -70
View File
@@ -7818,6 +7818,90 @@ http_file(
downloaded_file_path = "common-detekt-0.4.27.jar"
)
http_file(
name = "io_nlopez_compose_rules-detekt-0_4_27-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/nlopez/compose/rules/detekt/0.4.27/detekt-0.4.27-sources.jar",
sha256 = "ca1df07e125078327350348f0193f83c74b7dcc392c332aab0022672c2e180b2",
downloaded_file_path = "detekt-0.4.27-sources.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-core-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-core/1.23.8/detekt-core-1.23.8-sources.jar",
sha256 = "c83088ef6affd4f72e28f91d1aba7d6e2a23e6a8cd235016b91049e548a271e4",
downloaded_file_path = "detekt-core-1.23.8-sources.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-api-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-api/1.23.8/detekt-api-1.23.8-sources.jar",
sha256 = "3a5da5412a1853bc5054cc43593e922fe702d33af5efa52d62e0d3907dab5430",
downloaded_file_path = "detekt-api-1.23.8-sources.jar"
)
http_file(
name = "dev_drewhamilton_poko-poko-annotations-jvm-0_17_1-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/dev/drewhamilton/poko/poko-annotations-jvm/0.17.1/poko-annotations-jvm-0.17.1-sources.jar",
sha256 = "889b62379f4b7eba51b96827828e96dc5efc8f5a4fc587e758969e0f77dd76ad",
downloaded_file_path = "poko-annotations-jvm-0.17.1-sources.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-parser-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-parser/1.23.8/detekt-parser-1.23.8-sources.jar",
sha256 = "7c5c9b5c709c3f30a5a8563a02c43c0bf0992ede53c97ad698589d5681567f32",
downloaded_file_path = "detekt-parser-1.23.8-sources.jar"
)
http_file(
name = "io_github_davidburstrom_contester-contester-breakpoint-0_2_0-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/github/davidburstrom/contester/contester-breakpoint/0.2.0/contester-breakpoint-0.2.0-sources.jar",
sha256 = "f832679d34642afe7e57e8b7b3eb8d3787352ddd3e304f5965d297c5bc7b42e3",
downloaded_file_path = "contester-breakpoint-0.2.0-sources.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-tooling-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-tooling/1.23.8/detekt-tooling-1.23.8-sources.jar",
sha256 = "ff0bcb96d446169627cae468aa8f9b837f9ce521564ad96230849d47cda99b5e",
downloaded_file_path = "detekt-tooling-1.23.8-sources.jar"
)
http_file(
name = "org_snakeyaml-snakeyaml-engine-2_7-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/snakeyaml/snakeyaml-engine/2.7/snakeyaml-engine-2.7-sources.jar",
sha256 = "02572a2ab02d8507b6b2291857d909fa901a01e5b47867897d69df5db8897169",
downloaded_file_path = "snakeyaml-engine-2.7-sources.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-metrics-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-metrics/1.23.8/detekt-metrics-1.23.8-sources.jar",
sha256 = "2623a25d346c95923e1cb384adaea369a69dad6730a89eee70462264fc26c9c0",
downloaded_file_path = "detekt-metrics-1.23.8-sources.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-psi-utils-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-psi-utils/1.23.8/detekt-psi-utils-1.23.8-sources.jar",
sha256 = "91f714164c3dd2eebaba9a29642e2582d565cbb1068ec41e1c49cd744b759a38",
downloaded_file_path = "detekt-psi-utils-1.23.8-sources.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-utils-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-utils/1.23.8/detekt-utils-1.23.8-sources.jar",
sha256 = "fe3e8218997c50997d453ecf0146baab0d2eb290de5ab8d10da911480b652246",
downloaded_file_path = "detekt-utils-1.23.8-sources.jar"
)
http_file(
name = "io_nlopez_compose_rules-common-detekt-0_4_27-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/nlopez/compose/rules/common-detekt/0.4.27/common-detekt-0.4.27-sources.jar",
sha256 = "b16957b2b81b653249a7bd52cd47dfcdfe39fb7c61aad292e504c0b51e97442e",
downloaded_file_path = "common-detekt-0.4.27-sources.jar"
)
http_file(
name = "org_jetbrains_dokka-analysis-kotlin-descriptors-2_0_0_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/jetbrains/dokka/analysis-kotlin-descriptors/2.0.0/analysis-kotlin-descriptors-2.0.0.jar",
@@ -7825,6 +7909,13 @@ http_file(
downloaded_file_path = "analysis-kotlin-descriptors-2.0.0.jar"
)
http_file(
name = "org_jetbrains_dokka-analysis-kotlin-descriptors-2_0_0-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/jetbrains/dokka/analysis-kotlin-descriptors/2.0.0/analysis-kotlin-descriptors-2.0.0-sources.jar",
sha256 = "c6deada2fac53b8ea6523dbda77597b128006674616f140f04df23264c6d1aa3",
downloaded_file_path = "analysis-kotlin-descriptors-2.0.0-sources.jar"
)
http_file(
name = "org_jetbrains_dokka-dokka-cli-2_0_0_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/jetbrains/dokka/dokka-cli/2.0.0/dokka-cli-2.0.0.jar",
@@ -7832,6 +7923,13 @@ http_file(
downloaded_file_path = "dokka-cli-2.0.0.jar"
)
http_file(
name = "org_jetbrains_dokka-dokka-cli-2_0_0-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/jetbrains/dokka/dokka-cli/2.0.0/dokka-cli-2.0.0-sources.jar",
sha256 = "2a485a3c336a8d8483c2309e8b643181e8f49c1b7ef2bfb1168a4cf2625d1160",
downloaded_file_path = "dokka-cli-2.0.0-sources.jar"
)
http_file(
name = "org_jetbrains_dokka-javadoc-plugin-2_0_0_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/jetbrains/dokka/javadoc-plugin/2.0.0/javadoc-plugin-2.0.0.jar",
@@ -7867,6 +7965,41 @@ http_file(
downloaded_file_path = "kotlinx-html-jvm-0.9.1.jar"
)
http_file(
name = "org_jetbrains_dokka-javadoc-plugin-2_0_0-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/jetbrains/dokka/javadoc-plugin/2.0.0/javadoc-plugin-2.0.0-sources.jar",
sha256 = "db6021566a05bd46ef41972e2f9b08e9cdffa3655fdb9d479ae68644d587eca7",
downloaded_file_path = "javadoc-plugin-2.0.0-sources.jar"
)
http_file(
name = "org_jetbrains_dokka-dokka-base-2_0_0-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/jetbrains/dokka/dokka-base/2.0.0/dokka-base-2.0.0-sources.jar",
sha256 = "5d325e704e57e83152f398b4159ae4a91065f738057f3220c9bf20e7a87f8eca",
downloaded_file_path = "dokka-base-2.0.0-sources.jar"
)
http_file(
name = "org_jetbrains_dokka-kotlin-as-java-plugin-2_0_0-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/jetbrains/dokka/kotlin-as-java-plugin/2.0.0/kotlin-as-java-plugin-2.0.0-sources.jar",
sha256 = "5baf3dd2b3993531e148af42b3a5db4c99174af2aa3be07db17a1fbbbff9e502",
downloaded_file_path = "kotlin-as-java-plugin-2.0.0-sources.jar"
)
http_file(
name = "com_soywiz_korlibs_korte-korte-jvm-4_0_10-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/com/soywiz/korlibs/korte/korte-jvm/4.0.10/korte-jvm-4.0.10-sources.jar",
sha256 = "475ff8f7d8c8af0c66bf9cea378c34c7ed8a34942dbdc15dab37dda7c699ddea",
downloaded_file_path = "korte-jvm-4.0.10-sources.jar"
)
http_file(
name = "org_jetbrains_kotlinx-kotlinx-html-jvm-0_9_1-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-html-jvm/0.9.1/kotlinx-html-jvm-0.9.1-sources.jar",
sha256 = "ef1195449de49153f96723e0a2e5e1a99b504d57a9b58482d03c98dbcf29cf18",
downloaded_file_path = "kotlinx-html-jvm-0.9.1-sources.jar"
)
http_file(
name = "com_github_seregamorph-hamcrest-more-matchers-0_1_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/com/github/seregamorph/hamcrest-more-matchers/0.1/hamcrest-more-matchers-0.1.jar",
@@ -13103,13 +13236,6 @@ http_file(
downloaded_file_path = "kotlinx-coroutines-core-jvm-1.6.4.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-api-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-api/1.23.8/detekt-api-1.23.8-sources.jar",
sha256 = "3a5da5412a1853bc5054cc43593e922fe702d33af5efa52d62e0d3907dab5430",
downloaded_file_path = "detekt-api-1.23.8-sources.jar"
)
http_file(
name = "org_jetbrains_kotlin-kotlin-compiler-embeddable-2_0_21-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-compiler-embeddable/2.0.21/kotlin-compiler-embeddable-2.0.21-sources.jar",
@@ -13152,27 +13278,6 @@ http_file(
downloaded_file_path = "kotlinx-coroutines-core-jvm-1.6.4-sources.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-psi-utils-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-psi-utils/1.23.8/detekt-psi-utils-1.23.8-sources.jar",
sha256 = "91f714164c3dd2eebaba9a29642e2582d565cbb1068ec41e1c49cd744b759a38",
downloaded_file_path = "detekt-psi-utils-1.23.8-sources.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-utils-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-utils/1.23.8/detekt-utils-1.23.8-sources.jar",
sha256 = "fe3e8218997c50997d453ecf0146baab0d2eb290de5ab8d10da911480b652246",
downloaded_file_path = "detekt-utils-1.23.8-sources.jar"
)
http_file(
name = "dev_drewhamilton_poko-poko-annotations-jvm-0_17_1-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/dev/drewhamilton/poko/poko-annotations-jvm/0.17.1/poko-annotations-jvm-0.17.1-sources.jar",
sha256 = "889b62379f4b7eba51b96827828e96dc5efc8f5a4fc587e758969e0f77dd76ad",
downloaded_file_path = "poko-annotations-jvm-0.17.1-sources.jar"
)
http_file(
name = "org_jetbrains_kotlin-kotlin-stdlib-2_0_21_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/2.0.21/kotlin-stdlib-2.0.21.jar",
@@ -13278,34 +13383,6 @@ http_file(
downloaded_file_path = "kotlin-stdlib-jdk7-1.7.20.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-core-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-core/1.23.8/detekt-core-1.23.8-sources.jar",
sha256 = "c83088ef6affd4f72e28f91d1aba7d6e2a23e6a8cd235016b91049e548a271e4",
downloaded_file_path = "detekt-core-1.23.8-sources.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-parser-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-parser/1.23.8/detekt-parser-1.23.8-sources.jar",
sha256 = "7c5c9b5c709c3f30a5a8563a02c43c0bf0992ede53c97ad698589d5681567f32",
downloaded_file_path = "detekt-parser-1.23.8-sources.jar"
)
http_file(
name = "io_github_davidburstrom_contester-contester-breakpoint-0_2_0-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/github/davidburstrom/contester/contester-breakpoint/0.2.0/contester-breakpoint-0.2.0-sources.jar",
sha256 = "f832679d34642afe7e57e8b7b3eb8d3787352ddd3e304f5965d297c5bc7b42e3",
downloaded_file_path = "contester-breakpoint-0.2.0-sources.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-tooling-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-tooling/1.23.8/detekt-tooling-1.23.8-sources.jar",
sha256 = "ff0bcb96d446169627cae468aa8f9b837f9ce521564ad96230849d47cda99b5e",
downloaded_file_path = "detekt-tooling-1.23.8-sources.jar"
)
http_file(
name = "org_jetbrains_kotlin-kotlin-stdlib-2_0_21-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/2.0.21/kotlin-stdlib-2.0.21-sources.jar",
@@ -13320,13 +13397,6 @@ http_file(
downloaded_file_path = "annotations-13.0-sources.jar"
)
http_file(
name = "org_snakeyaml-snakeyaml-engine-2_7-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/snakeyaml/snakeyaml-engine/2.7/snakeyaml-engine-2.7-sources.jar",
sha256 = "02572a2ab02d8507b6b2291857d909fa901a01e5b47867897d69df5db8897169",
downloaded_file_path = "snakeyaml-engine-2.7-sources.jar"
)
http_file(
name = "org_jetbrains_kotlin-kotlin-reflect-2_0_21-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-reflect/2.0.21/kotlin-reflect-2.0.21-sources.jar",
@@ -13334,13 +13404,6 @@ http_file(
downloaded_file_path = "kotlin-reflect-2.0.21-sources.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-metrics-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-metrics/1.23.8/detekt-metrics-1.23.8-sources.jar",
sha256 = "2623a25d346c95923e1cb384adaea369a69dad6730a89eee70462264fc26c9c0",
downloaded_file_path = "detekt-metrics-1.23.8-sources.jar"
)
http_file(
name = "io_gitlab_arturbosch_detekt-detekt-report-html-1_23_8-sources_http",
url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/gitlab/arturbosch/detekt/detekt-report-html/1.23.8/detekt-report-html-1.23.8-sources.jar",
@@ -87,7 +87,20 @@
<root url="jar://$MAVEN_REPOSITORY$/io/gitlab/arturbosch/detekt/detekt-utils/1.23.8/detekt-utils-1.23.8-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/nlopez/compose/rules/common-detekt/0.4.27/common-detekt-0.4.27-javadoc.jar!/" />
</JAVADOC>
<SOURCES />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/io/nlopez/compose/rules/detekt/0.4.27/detekt-0.4.27-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/gitlab/arturbosch/detekt/detekt-core/1.23.8/detekt-core-1.23.8-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/gitlab/arturbosch/detekt/detekt-api/1.23.8/detekt-api-1.23.8-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/dev/drewhamilton/poko/poko-annotations-jvm/0.17.1/poko-annotations-jvm-0.17.1-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/gitlab/arturbosch/detekt/detekt-parser/1.23.8/detekt-parser-1.23.8-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/github/davidburstrom/contester/contester-breakpoint/0.2.0/contester-breakpoint-0.2.0-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/gitlab/arturbosch/detekt/detekt-tooling/1.23.8/detekt-tooling-1.23.8-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/snakeyaml/snakeyaml-engine/2.7/snakeyaml-engine-2.7-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/gitlab/arturbosch/detekt/detekt-metrics/1.23.8/detekt-metrics-1.23.8-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/gitlab/arturbosch/detekt/detekt-psi-utils/1.23.8/detekt-psi-utils-1.23.8-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/gitlab/arturbosch/detekt/detekt-utils/1.23.8/detekt-utils-1.23.8-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/nlopez/compose/rules/common-detekt/0.4.27/common-detekt-0.4.27-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module" module-name="intellij.libraries.kotlin.reflect" />
+14 -3
View File
@@ -17,7 +17,9 @@
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/dokka/dokka-cli/2.0.0/dokka-cli-2.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/dokka/dokka-cli/2.0.0/dokka-cli-2.0.0-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="PROVIDED">
@@ -63,7 +65,14 @@
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlinx/kotlinx-html-jvm/0.9.1/kotlinx-html-jvm-0.9.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/dokka/javadoc-plugin/2.0.0/javadoc-plugin-2.0.0-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/dokka/dokka-base/2.0.0/dokka-base-2.0.0-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/freemarker/freemarker/2.3.32/freemarker-2.3.32-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/dokka/kotlin-as-java-plugin/2.0.0/kotlin-as-java-plugin-2.0.0-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/soywiz/korlibs/korte/korte-jvm/4.0.10/korte-jvm-4.0.10-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlinx/kotlinx-html-jvm/0.9.1/kotlinx-html-jvm-0.9.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="PROVIDED">
@@ -79,7 +88,9 @@
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/dokka/analysis-kotlin-descriptors/2.0.0/analysis-kotlin-descriptors-2.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/dokka/analysis-kotlin-descriptors/2.0.0/analysis-kotlin-descriptors-2.0.0-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
</component>
@@ -157,6 +157,20 @@ internal class BazelBuildFileGenerator(
val mavenLibraries: Object2ObjectOpenHashMap<LibraryKey, MavenLibrary> = Object2ObjectOpenHashMap()
val localLibraries: Object2ObjectOpenHashMap<LibraryKey, LocalLibrary> = Object2ObjectOpenHashMap()
val allLibraries: Collection<Library>
get() = mavenLibraries.values + localLibraries.values
val communityOnlyLibraries: Collection<Library>
get() {
return allLibraries.filter {
check(it.target.container == communityLibraries || it.target.container == ultimateLibraries) {
"Library container ${it.target.container} of ${it.target} is not community or ultimate"
}
it.target.container == communityLibraries
}
}
private val providedLibraries: ProvidedLibraries = ProvidedLibraries()
class ProvidedLibraries {
private val providedLibraries: MultiMap<Library, LibraryContainer> = MultiMap()
@@ -196,7 +210,7 @@ internal class BazelBuildFileGenerator(
jarRepositories: List<JarRepository>,
m2Repo: Path,
) {
val fileToLabelTracker = LinkedHashMap<Path, MutableSet<String>>()
val fileToLabelTracker = LinkedHashMap<Path, MutableMap<String, String>>()
val fileToUpdater = LinkedHashMap<Path, BazelFileUpdater>()
for ((libraryContainer, list) in mavenLibraries
.values
@@ -220,7 +234,7 @@ internal class BazelBuildFileGenerator(
val groupedByTargetName = sortedList.groupBy { it.target.targetName }
val labelTracker = fileToLabelTracker.computeIfAbsent(libraryContainer.moduleFile) { HashSet() }
val labelTracker = fileToLabelTracker.computeIfAbsent(libraryContainer.moduleFile) { mutableMapOf() }
buildFile(out = bazelFileUpdater, sectionName = libraryContainer.sectionName) {
load("@rules_jvm//:jvm.bzl", "jvm_import")
@@ -14,13 +14,14 @@ import org.jetbrains.jps.model.serialization.JpsSerializationManager
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardCopyOption
import kotlin.collections.asSequence
import java.util.TreeMap
import kotlin.io.path.createDirectories
import kotlin.io.path.deleteIfExists
import kotlin.io.path.exists
import kotlin.io.path.invariantSeparatorsPathString
import kotlin.io.path.isRegularFile
import kotlin.io.path.moveTo
import kotlin.io.path.readLines
import kotlin.io.path.readText
import kotlin.io.path.relativeTo
import kotlin.io.path.writeText
@@ -39,6 +40,7 @@ internal class JpsModuleToBazel {
?: System.getProperty("user.dir")
var runWithoutUltimateRoot = System.getenv(RUN_WITHOUT_ULTIMATE_ROOT_ENV) ?: "false"
var defaultCustomModules = "true"
var bazelOutputBase: Path? = null
var m2Repo = JpsMavenSettings.getMavenRepositoryPath()
for (arg in args) {
@@ -49,6 +51,12 @@ internal class JpsModuleToBazel {
workspaceDir = arg.substringAfter("=")
arg.startsWith("--default-custom-modules=") ->
defaultCustomModules = arg.substringAfter("=")
arg.startsWith("--assert-all-outputs-exist-with-output-base=") -> {
bazelOutputBase = Path.of(arg.substringAfter("="))
check(bazelOutputBase.isAbsolute) { "Output base $bazelOutputBase must be absolute" }
check(bazelOutputBase.normalize() == bazelOutputBase) { "Output base $bazelOutputBase must be normalized" }
check(bazelOutputBase.exists()) { "Output base $bazelOutputBase must exist" }
}
arg.startsWith("--m2-repo=") ->
m2Repo = arg.substringAfter("=")
else -> error("Unknown argument: $arg")
@@ -61,14 +69,24 @@ internal class JpsModuleToBazel {
} else {
null
}
val bazelWorkspaceRoot = bazelOutputBase?.let {
val workspaceLine = it.resolve("README").readLines().single { line -> line.startsWith("WORKSPACE: ") }
Path.of(workspaceLine.removePrefixStrict("WORKSPACE: "))
}
println("Community root: $communityRoot")
println("Ultimate root: $ultimateRoot")
println("M2 repo root: $m2Repo")
println("Bazel output base: $bazelOutputBase")
val projectDir = ultimateRoot ?: communityRoot
val project = JpsSerializationManager.getInstance().loadProject(projectDir.toString(), mapOf("MAVEN_REPOSITORY" to m2Repo), true)
val project = JpsSerializationManager.getInstance().loadProject(
/* projectPath = */ projectDir,
/* externalConfigurationDirectory = */ null,
/* pathVariables = */ mapOf("MAVEN_REPOSITORY" to m2Repo),
/* loadUnloadedModules = */ true,
)
val jarRepositories = loadJarRepositories(projectDir)
val modulesBazel = listOfNotNull(
@@ -116,9 +134,30 @@ internal class JpsModuleToBazel {
)
}
val communityTargetsFile = communityRoot.resolve("build/bazel-targets.json")
saveTargets(
file = communityTargetsFile,
targets = communityResult.moduleTargets,
moduleList = moduleList,
libs = generator.communityOnlyLibraries,
communityRoot = communityRoot,
ultimateRoot = null,
projectRoot = communityRoot,
bazelOutputBase = if (bazelWorkspaceRoot == communityRoot) bazelOutputBase else null,
)
if (ultimateRoot != null) {
val targetsFile = ultimateRoot.resolve("build/bazel-targets.json")
saveTargets(targetsFile, communityResult.moduleTargets + ultimateResult.moduleTargets, moduleList, generator.mavenLibraries.values + generator.localLibraries.values, ultimateRoot)
val ultimateTargetsFile = ultimateRoot.resolve("build/bazel-targets.json")
saveTargets(
file = ultimateTargetsFile,
targets = communityResult.moduleTargets + ultimateResult.moduleTargets,
moduleList = moduleList,
libs = generator.allLibraries,
communityRoot = communityRoot,
ultimateRoot = ultimateRoot,
projectRoot = ultimateRoot,
bazelOutputBase = if (bazelWorkspaceRoot == ultimateRoot) bazelOutputBase else null,
)
}
}
@@ -167,7 +206,16 @@ internal class JpsModuleToBazel {
}
@OptIn(ExperimentalSerializationApi::class)
fun saveTargets(file: Path, targets: List<BazelBuildFileGenerator.ModuleTargets>, moduleList: ModuleList, libs: Collection<Library>, ultimateRoot: Path) {
fun saveTargets(
file: Path,
targets: List<BazelBuildFileGenerator.ModuleTargets>,
moduleList: ModuleList,
libs: Collection<Library>,
communityRoot: Path,
ultimateRoot: Path?,
projectRoot: Path,
bazelOutputBase: Path?
) {
@Serializable
data class LibraryDescription(
val target: String,
@@ -199,11 +247,13 @@ internal class JpsModuleToBazel {
"${file.mavenCoordinates.artifactId}-${file.mavenCoordinates.version}" +
(if (file.mavenCoordinates.classifier != null) "-${file.mavenCoordinates.classifier}" else "") +
".jar"
// uncomment to assert, requires all libraries to be already downloaded (e.g. by ./bazel-build-all.cmd)
//val root = bazelOutputRoot
//check(root.resolve(path).isRegularFile()) {
// "Cannot find ${root.resolve(path)} (library ${library.target.jpsName} library module=${library.target.moduleLibraryModuleName})"
//}
if (bazelOutputBase != null) {
check(bazelOutputBase.resolve(path).isRegularFile()) {
"Cannot find ${bazelOutputBase.resolve(path)} (library ${library.target.jpsName} library module=${library.target.moduleLibraryModuleName})"
}
}
return path
}
@@ -221,27 +271,34 @@ internal class JpsModuleToBazel {
LibraryDescription(
target = target,
jars = library.files.map {
require(it.normalize().startsWith(ultimateRoot)) {
"Library file ${it.relativeTo(ultimateRoot)} is not under ultimateRoot ($it)"
val normalized = it.normalize()
require(
normalized.startsWith(communityRoot) ||
(ultimateRoot != null && normalized.startsWith(ultimateRoot))
) {
"Library file $it is not under community root ($communityRoot) or ultimate root ($ultimateRoot)"
}
val relativeToUltimateRoot = it.relativeTo(ultimateRoot).invariantSeparatorsPathString
val ultimateLibRoot = ultimateRoot?.resolve("lib")
val communityLibRoot = communityRoot.resolve("lib")
val relativeToBazelOutputRoot = when {
relativeToUltimateRoot.startsWith("lib/") ->
"external/ultimate_lib+/" + relativeToUltimateRoot.removePrefix("lib/")
relativeToUltimateRoot.startsWith("community/") ->
"external/community+/" + relativeToUltimateRoot.removePrefix("community/")
else -> "execroot/_main/$relativeToUltimateRoot"
val relativeToBazelOutputBase = when {
ultimateLibRoot != null && normalized.startsWith(ultimateLibRoot) ->
"external/ultimate_lib+/" + normalized.relativeTo(ultimateLibRoot).invariantSeparatorsPathString
normalized.startsWith(communityLibRoot) ->
"external/lib+/" + normalized.relativeTo(communityLibRoot).invariantSeparatorsPathString
projectRoot == ultimateRoot && normalized.startsWith(communityRoot) ->
"external/community+/" + normalized.relativeTo(communityRoot).invariantSeparatorsPathString
else -> "execroot/_main/${normalized.relativeTo(projectRoot).invariantSeparatorsPathString}"
}
// uncomment to assert, requires all libraries to be already downloaded (e.g. by ./bazel-build-all.cmd)
//val root = bazelOutputRoot
//check(root.resolve(relativeToBazelOutputRoot).isRegularFile()) {
// "Cannot find ${root.resolve(relativeToBazelOutputRoot)} (library ${library.target.jpsName} library module=${library.target.moduleLibraryModuleName})"
//}
if (bazelOutputBase != null) {
check(bazelOutputBase.resolve(relativeToBazelOutputBase).isRegularFile()) {
"Cannot find ${bazelOutputBase.resolve(relativeToBazelOutputBase)} (library ${library.target.jpsName} library module=${library.target.moduleLibraryModuleName})"
}
}
relativeToBazelOutputRoot
relativeToBazelOutputBase
},
sourceJars = emptyList(),
)
@@ -258,7 +315,7 @@ internal class JpsModuleToBazel {
val fileContent = jsonSerializer.encodeToString(
serializer = jsonSerializer.serializersModule.serializer(),
value = TargetsFile(
modules = targets.associate { moduleTarget ->
modules = targets.associateTo(TreeMap()) { moduleTarget ->
val moduleName = moduleTarget.moduleDescriptor.module.name
moduleName to TargetsFileModuleDescription(
productionTargets = moduleTarget.productionTargets,
@@ -267,13 +324,13 @@ internal class JpsModuleToBazel {
testJars = moduleTarget.testJars,
exports = moduleList.deps[moduleTarget.moduleDescriptor]?.exports?.map { it.label } ?: emptyList(),
moduleLibraries = module2Libraries[moduleName]
?.associate { it.target.jpsName to makeLibraryDescription(it) } ?: emptyMap(),
?.associateTo(TreeMap()) { it.target.jpsName to makeLibraryDescription(it) } ?: emptyMap(),
)
} + skippedModules.associateWith { emptyModule },
projectLibraries = libs.asSequence().mapNotNull {
if (it.target.moduleLibraryModuleName != null) return@mapNotNull null
return@mapNotNull it.target.jpsName to makeLibraryDescription(it)
}.sortedBy { it.first }.toMap()
}.toMap(TreeMap())
)
)
@@ -432,7 +432,7 @@ private fun String.removeSuffixStrict(suffix: String): String {
return result
}
private fun String.removePrefixStrict(prefix: String): String {
internal fun String.removePrefixStrict(prefix: String): String {
require(prefix.isNotEmpty()) {
"prefix must not be empty"
}
@@ -88,9 +88,24 @@ private fun getUrlAndSha256(jar: MavenFileDescription, jarRepositories: List<Jar
return entry
}
internal fun checkLibraryFileWasAlreadyRendered(targetName: String, libVisibility: String?, hasSourceJar: Boolean, labelTracker: MutableMap<String, String>): Boolean {
val trackerContent = "library_file has_source_jar:$hasSourceJar lib_visibility:$libVisibility"
val olderContent = labelTracker.put(targetName, trackerContent)
if (olderContent != null && olderContent != trackerContent) {
// was rendered earlier, but the context was different
error(
"The same library target $targetName was rendered twice with different contexts: '$olderContent' and '$trackerContent'. " +
"This is no allowed, please make sure that your library settings (e.g. having sources or visiblity) is consistent across all " +
"library usages"
)
}
return olderContent != null
}
internal fun BuildFile.generateMavenLib(
lib: MavenLibrary,
labelTracker: MutableSet<String>,
labelTracker: MutableMap<String, String>,
isLibraryProvided: (Library) -> Boolean,
libVisibility: String?,
) {
@@ -102,11 +117,12 @@ internal fun BuildFile.generateMavenLib(
if (lib.jars.size == 1) {
val jar = lib.jars.single()
if (!labelTracker.add(targetName)) {
val sourceJar = lib.sourceJars.firstOrNull { it.mavenCoordinates == jar.mavenCoordinates.copy(classifier = "sources") }
if (checkLibraryFileWasAlreadyRendered(targetName, libVisibility, sourceJar != null, labelTracker)) {
return
}
val sourceJar = lib.sourceJars.singleOrNull { it.mavenCoordinates == jar.mavenCoordinates.copy(classifier = "sources") }
target("jvm_import") {
option("name", targetName)
option("jar", "@${fileToHttpRuleFile(jar.mavenCoordinates)}")
@@ -137,11 +153,12 @@ internal fun BuildFile.generateMavenLib(
for (jar in lib.jars) {
val bazelLabel = mavenCoordinatesToHttpRuleRepoName(jar.mavenCoordinates)
val label = "${bazelLabel}_import"
if (!labelTracker.add(label)) {
val sourceJar = lib.sourceJars.firstOrNull { it.mavenCoordinates == jar.mavenCoordinates.copy(classifier = "sources") }
if (checkLibraryFileWasAlreadyRendered(label, libVisibility, sourceJar != null, labelTracker)) {
continue
}
val sourceJar = lib.sourceJars.singleOrNull { it.mavenCoordinates == jar.mavenCoordinates.copy(classifier = "sources") }
target("jvm_import") {
option("name", label)
option("jar", "@$bazelLabel//file")
@@ -210,7 +227,7 @@ internal fun generateBazelModuleSectionsForLibs(
jarRepositories: List<JarRepository>,
m2Repo: Path,
urlCache: UrlCache,
moduleFileToLabelTracker: MutableMap<Path, MutableSet<String>>,
moduleFileToLabelTracker: MutableMap<Path, MutableMap<String, String>>,
fileToUpdater: MutableMap<Path, BazelFileUpdater>,
) {
val bazelFileUpdater = fileToUpdater.computeIfAbsent(owner.moduleFile) {
@@ -220,12 +237,12 @@ internal fun generateBazelModuleSectionsForLibs(
updater
}
val labelTracker = moduleFileToLabelTracker.computeIfAbsent(owner.moduleFile) { HashSet() }
val labelTracker = moduleFileToLabelTracker.computeIfAbsent(owner.moduleFile) { mutableMapOf() }
buildFile(bazelFileUpdater, owner.sectionName) {
for (lib in list) {
for (jar in lib.jars) {
val label = mavenCoordinatesToHttpRuleRepoName(jar.mavenCoordinates)
if (!labelTracker.add(label)) {
if (labelTracker.put(label, "") != null) {
continue
}
@@ -244,7 +261,7 @@ internal fun generateBazelModuleSectionsForLibs(
for (jar in lib.sourceJars) {
val label = mavenCoordinatesToHttpRuleRepoName(jar.mavenCoordinates)
if (!labelTracker.add(label)) {
if (labelTracker.put(label, "") != null) {
continue
}