{"id":18949977,"url":"https://github.com/salesforce/bazel-jdt-java-toolchain","last_synced_at":"2025-04-15T23:31:29.714Z","repository":{"id":43006296,"uuid":"416646316","full_name":"salesforce/bazel-jdt-java-toolchain","owner":"salesforce","description":"Eclipse Java Compiler (ECJ) for Bazel","archived":false,"fork":false,"pushed_at":"2024-08-02T15:26:46.000Z","size":20007,"stargazers_count":9,"open_issues_count":3,"forks_count":6,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-08-03T13:54:17.296Z","etag":null,"topics":["bazel","compile","ecj","eclipse","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/salesforce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-13T08:11:05.000Z","updated_at":"2024-08-02T15:26:48.000Z","dependencies_parsed_at":"2024-03-07T10:51:23.036Z","dependency_job_id":"3551b66d-a887-46ee-a367-d114626cc7b9","html_url":"https://github.com/salesforce/bazel-jdt-java-toolchain","commit_stats":{"total_commits":82,"total_committers":5,"mean_commits":16.4,"dds":0.4024390243902439,"last_synced_commit":"b266b03136398bdbfc8aa3ef65c067352a2dd3b9"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salesforce%2Fbazel-jdt-java-toolchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salesforce%2Fbazel-jdt-java-toolchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salesforce%2Fbazel-jdt-java-toolchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salesforce%2Fbazel-jdt-java-toolchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/salesforce","download_url":"https://codeload.github.com/salesforce/bazel-jdt-java-toolchain/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223689599,"owners_count":17186458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bazel","compile","ecj","eclipse","java"],"created_at":"2024-11-08T13:20:06.095Z","updated_at":"2024-11-08T13:20:06.843Z","avatar_url":"https://github.com/salesforce.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jdt-java-toolchain\nA Java Toolchain for Bazel that uses ECJ (Eclipse Compiler for Java) for compilation.\n\n## Why ECJ?\n\nThe Eclipse Compiler for Java is much (much, much) faster than javac.\nIt's even faster than Bazel's Java header compiler, i.e. with this toolchain you can disable Turbine header compilation and still have a faster build time.\nAdditionally, we included a few optimizations to further improve the compilation performance.\nFor example, it's possible to disable transitive dependencies and only compile with directly declared dependencies. \n\n## Usage\n\nSee [releases](https://github.com/salesforce/bazel-jdt-java-toolchain/releases/) for the release\nspecific notes and instructions what to add to your `WORKSPACE` file.\n\nOnce this is completed, add this to your `.bazelrc`:\n```\nbuild --extra_toolchains=@bazel_jdt_java_toolchain//jdt:all\n```\n\nBy default the `jdt_java_toolchain` is using `rules_java` default for compilation.\nPlease create your own `default_java_toolchain` if this doesn't work for your use case.\n\nHave a look at `jdt/BUILD` to see which JDKs are supported.\n\n\n## ECJ Notes\n\nRead [ECJ README](compiler/src/main/ecj/README.md) for details about updating JDT.\n\n\n## Current Limitations\nCurrently, there are some issues with clients that try to access use this toolchain\nby compiling the builder from source. Many of the Bazel macros depend on the current\njava toolchain, and because that toolchain has not been built yet, we run into a circular\ndependency.\n\nThe solution is for `bazel-jdt-java-toolchain` developers to build the toolchain and then\ncopy the deploy jar into the repository. Clients can then use the `override_repository` command\nand point directly at the source of this repo for development and testing.\n\nUnfortunately this means additional steps are required for developers. This script can be\nused to facilitate the steps.\n\n```\n#!/bin/bash\n\nbazel build :JdtJavaBuilder_deploy.jar\ncp -fv bazel-bin/JdtJavaBuilder_deploy.jar compiler/export/\n\nbazel build //compiler/third_party/turbine:turbine_direct_binary_deploy.jar\ncp -fv bazel-bin/compiler/third_party/turbine/turbine_direct_binary_deploy.jar compiler/tools/\n```\n\nFor your convenience, the `build-toolchain` script is provided in this repository.\n\n\n## Debugging\nFor debugging the toolchain's Java code (including ECJ compiler) here are a few notes:\n\nOverride repository in your project's `.bazelrc` (or via command line) and add debug statements as follows:\n\n```\nbuild --override_repository=jdt_java_toolchain=/Users/.../bazel-jdt-java-toolchain/\ncommon --subcommands=pretty_print\ncommon --verbose_failures\n```\n\nThis will give output during the build how Bazel is invoking JDT compiler:\n\n```\nbazel build //some-java-target:target\nINFO: Analyzed target //some-java-target:target (...).\nINFO: Found 1 target...\nSUBCOMMAND: # //ome-java-target:target [action 'Building some-java-target/libtarget-class.jar ...]\n(cd /private/var/tmp/_bazel_username/hash/execroot/core \u0026\u0026 \\\n  exec env - \\\n    LC_CTYPE=en_US.UTF-8 \\\n    LD_LIBRARY_PATH='' \\\n    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \\\n  /Users/username/tools/Darwin/jdk/bin/java \\\n    -jar \\\n    external/jdt_java_toolchain/builder/export/JdtJavaBuilder_deploy.jar \\\n    @bazel-out/darwin-fastbuild/bin/some-java-target/libtarget-class.jar-0.params \\\n    @bazel-out/darwin-fastbuild/bin/some-java-target/libtarget-class.jar-1.params)\nERROR: /Users/username/app/main/core/some-java-target/BUILD.bazel:4:13: Building some-java-target/libtarget-class.jar ... failed: (Exit 1): java failed: error executing command\n  (cd /private/var/tmp/_bazel_username/hash/execroot/core \u0026\u0026 \\\n  exec env - \\\n    LC_CTYPE=en_US.UTF-8 \\\n    LD_LIBRARY_PATH='' \\\n    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \\\n  /Users/username/tools/Darwin/jdk/bin/java -jar external/jdt_java_toolchain/builder/export/JdtJavaBuilder_deploy.jar @bazel-out/darwin-fastbuild/bin/some-java-target/libtarget-class.jar-0.params @bazel-out/darwin-fastbuild/bin/some-java-target/libtarget-class.jar-1.params)\n```\n\nEither take the *SUBCOMMAND* or *ERROR* command.\nYou can ignore the `exec env` part.\n\nThe interesting two steps are:\n\n```\ncd /private/var/tmp/_bazel_username/hash/execroot/core\n```\n\n```\n/Users/username/tools/Darwin/jdk/bin/java -jar external/jdt_java_toolchain/builder/export/JdtJavaBuilder_deploy.jar @bazel-out/darwin-fastbuild/bin/some-java-target/libtarget-class.jar-0.params @bazel-out/darwin-fastbuild/bin/some-java-target/libtarget-class.jar-1.params\n```\n\nThe first is the execution directory and the latter the command.\nYou need to `cd` into the execution directory and then run the command yourself.\nBut this time add the remote debug arguments (before `-jar`) as follows:\n\n```\n/Users/username/tools/Darwin/jdk/bin/java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 -jar external/jdt_java_toolchain/builder/export/JdtJavaBuilder_deploy.jar @bazel-out/darwin-fastbuild/bin/some-java-target/libtarget-class.jar-0.params @bazel-out/darwin-fastbuild/bin/some-java-target/libtarget-class.jar-1.params\n```\n\nThe important part is `suspend=y`.\nWithout it the compiler would be finished before you are able to connect.\n\nOnce you run the command, connect to the waiting process with your IDE's remote debugger.\n\n\n# Development Guide\n\nThis project can be loaded with the Bazel Eclipse Feature.\nThe VS Code Bazel Java extension should also work.\n\n## Releasing\n\nSee [RELEASING README](dist/README.md).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalesforce%2Fbazel-jdt-java-toolchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalesforce%2Fbazel-jdt-java-toolchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalesforce%2Fbazel-jdt-java-toolchain/lists"}