Skip to content

Import Java Tutorial #159

@snjeza

Description

@snjeza

@guw @lonhutt I haven't be able to create an issue on https://github.com/eclipseguru/bazel-eclipse/. Because of that I have created it here.

I have tried to import java-tutorial into Eclipse and VS Code.
jjava-tutorial has been created based on https://bazel.build/start/java.
I have found the following issues:

  1. Bazel Eclipse creates several error markers as

a) Folder '/home/snjeza/bazel-examples/java-tutorial/src/main/java/com/example' contains more Java files then configured in Bazel. This is a scenario which is challenging to support in IDEs! Consider re-structuring your source code into separate folder hierarchies and Bazel packages.

  • src/main/java/com/example/ProjectRunner.java

The related issue - #116

  1. Bazel Eclipse creates projects named :greeter, :ProjectRunner, src.main.java.com.example.cmdline:runner
    Eclipse/JDT can't execute a main method on Linuxu and Mac if the classpath contains : (colon)

  2. Bazel Eclipse creates duplicate links for all of the three source files in linked-srcs and linked-test-srcs
    The related issue - .java is not on the class path of project A, only syntax errors are reported #143

  3. Bazel Eclipse copies BUILD*, MODEL*, WORKSPACE* to output folder.
    When importing java-tutorial, Bazel Eclipse copies /src/main/java/com/example/cmdline/BUILD to./.eclipse/projects/src.main.java.com.example.cmdline_runner/eclipse-bin/com/example/cmdline/
    If the "View>Command Palette>Java: Clean Java Language Server workspace" command is called in VS Code, java-tutorial won't be imported correctly.
    BazelProjectImporter creates the .eclipse/projects/.eclipse.projects.src.main.java.com.example.cmdline_runner.eclipse-bin.com.example.cmdline_runner project based on the /.eclipse/projects/src.main.java.com.example.cmdline_runner/eclipse-bin/com/example/cmdline/BUILD file

I have created a PR that fixes these issues in the following way:

  1. replaces error markers with warning markers
  2. if a project name contains : (colon), the PR replaces it with _ (underscore)
  3. fixes BaseProvisioningStrategy.java
  4. adds excluding="**/BUILD*|**/MODULE*|**/WORKSPACE*" to source classpath containers

After applying eclipseguru/bazel-eclipse#1, java-tutorial will be able to be imported; Runner and ProjectRunner will be able to be executed in Eclipse as well as in VS Code.

Test VSIX: https://drive.google.com/file/d/1xgOnnSZxmK6c4rzZYSdVS2O9uC5FnHar/view?usp=sharing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions