-
-
Notifications
You must be signed in to change notification settings - Fork 414
Add generator for Eclipse JDT project files #5614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@lihaoyi may I ask for a first round of review from you? This is currently in good shape. I will add integration tests and documentation in the next couple of days. I have one question, tho: Since this should only be enabled for Java Modules, I was thinking about implementing something similar to this for IntelliJ. But I'm not sure how to plug it in so that it is disabled for Scala / Kotlin, etc. I'm also not sure, but for now I would discard THIS failure. Of course this is a new API and I guess it fails therefore. |
core/api/daemon/src/mill/api/daemon/internal/JavaModuleApi.scala
Outdated
Show resolved
Hide resolved
For documentation, a section under For automated testing, an integration test in the same style as The PR description should also include screenshots of manual testing, with you using Of course, you should also test this on the project you want to use it on to make sure it satisfies your own requirements |
@lihaoyi the user facing documentation I added alongside screenshots, I will add integration tests next. For now I relied mostly on the examples when manually testing, can I copy them (in the IT build, not on disk) into the integration tests and re-use them there? |
@thahnen for integration tests, you should try and minimize a small example project to use in your test. Maybe |
This will create Eclipse projects with Java Development Tools (JDT) files. Modules will be aggregated based on a Java Module and corresponding Test Modules if possible. This differs from IntelliJ IDEA where the whole "Mill Build" will become one project, in Eclipse it will be multiple ones connected correctly but loaded into one Eclipse Workspace (that won't be generated using this generator).
Changes to the generator based on pull request feedback: Simplification on aggregating the Java modules and sorting out Kotlin and Java, more JavaDoc on the main class. Fixing an integration test. Added user facing documentation on how to generate Eclipse IDE project files.
This should cover most of the cases correctly
Due to the project getting copied, the name of the project folder of course changes to a non-deterministic name.
Modules are now correctly aggregated, even in complex scenarios (tested with swaldman/c3p0). Source folders are also created uniquely to not collide based on the build logic and to not duplicate.
I tried this out, seems to work! @thahnen one thing I noticed was that the |
Hi @lihaoyi, regarding the point of duplication: This is expected since this is due to the Eclipse UI for that view (Project Explorer). The duplication is due to the fact that that in the Project Explorer the directory is once kept as a source set (that is why there is this little icon above the folder) and once as a lame folder. I think this is a useless duplication but hey, who am I to judge ^^ Regarding the point of having the projects either link to the
|
Your approach to include the build.mill sounds reasonable |
This way the `build.mill` file will be present in the Eclipse IDE as well. This can be used for further improvements on the project resource filters and an Eclipse plug-in as well.
Hey @lihaoyi, I'm done. Feel free to validate the PR and provide one last round of feedback! Best, |
@thahnen I have merged this and tagged |
Summary
This pull requests provides an additional generator for the Mill Build Tool that is targeted towards working with the Eclipse IDE. There is currently no direct support for the Mill Build Tool inside the Eclipse IDE nor any maintained plug-in for Scala (as the language the build files are written in) or Kotlin, and therefore this generator is only targeting Java projects (for now?).
This references #3372 to enable users of the Eclipse IDE to generate projects based on the Java Development Tools (JDT). The goal is to have a working generator, aggregating the Java Mill Modules (and the corresponding Test Modules) into logical Eclipse projects as good as possible.
This does not provide support for the Mill build files itself (or support for Scala) since it relies on the Build Server Protocol (BSP) for which no supporting plug-in yet exists in the Eclipse IDE.
In-depth information
In order to generate Eclipse project files, this generator searches for all Java (Test) Modules inside the build/project structure and tries to aggregate them together. This is contrary to the existing IntelliJ IDEA Project generator that results in one big project - Eclipse has one workspace with multiple projects created based on the modules.
The aggregation follow the approach of having a module with production code and its direct corresponding test code that will become one Eclipse project. If there is no connection between production and test code found by the generate, a separate Eclipse project is created.
Dependencies between modules are correctly translated to inter-project dependencies, source folders are correctly resolved (and marked whether they have production or test code in them) and other external dependencies (e.g. libraries from Maven or local ones) added to the Eclipse project.
To make the generator more user-friendly when invoked from the command line, logs are provided showing all the steps as well as every Eclipse project created with its name and location - so it is easier later for users to locate them and import them into the workspace.
A synthetic non-Java Eclipse project is created for the root Mill build file (
build.mill
) in case no module was located in this folder. This way users can also access the build script using a project inside the Eclipse workspace if they like despite the fact that the Eclipse IDE, as mentioned above, provides no active support for the build tool, the build scripts and/or the Scala programming language. The file will be handled like a plain text file for now.As this generator is not 100% failsafe for every corner case, these generated files should be usable and if not, then they can be adjusted from inside the Eclipse IDE - they are not the holy grail and users might want to tweak them as they wish anyway.
This also relates to logic from the Mill build that is not translated, like launcher configurations for applications or tests, these need to be configured manually from inside the Eclipse IDE (these configurations rely on separate files not linked to the ones generated by this generator).
Testing
The generator was tested against complying example Java projects already present inside this repository. Additionally, integration tests were added for the generator to cover the supported (corner) cases and to point out the not supported cases (e.g. Scala / Kotlin projects). This way upcoming breaking changes to the API could be found as early as possible.
Production testing
Additionally to automatic tests running on the CI and manual tests against example projects and simple, created ones, this was also tested with a non-trivial open source project. I choose swaldman/c3p0 due to the fact that its module structure and build file are a bit more complex with the following caveats:
src-proxy-interface
)Test plan
c3p0
at the locationtest/src -> com.mchange.v2.c3p0.test.junit -> MarshallUnmarshallDataSourcesJUnitTestCase.java -> testRefDerefRoundTrip()
via the context menubuild.mill
- see this limitation above!This should conclude the testing on a non-trivial open source project relying on the Mill Build Tool successfully!
Further improvements
There might be further improvements to this generator that are out of the scope of this pull requests. These include:
JavaModuleApi#javacOptions
or something similarI'm open to contribute any of these if possible and time (and life) permits 😄