-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add precommit task for detecting split packages #73784
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
Modularization of the JDK has been ongoing for several years. Recently in Java 16 the JDK began enforcing module boundaries by default. While Elasticsearch does not yet use the module system directly, there are some side effects even for those projects not modularized (eg elastic#73517). Before we can even begin to think about how to modularize, we must Prepare The Way by enforcing packages only exist in a single jar file, since the module system does not allow packages to coexist in multiple modules. This commit adds a precommit check to the build which detects split packages. The expectation is that we will add the existing split packages to the ignore list so that any new classes will not exacerbate the problem, and the work to cleanup these split packages can be parallelized. relates elastic#73525
|
Pinging @elastic/es-delivery (Team:Delivery) |
|
Note that this is a WIP as far as adding any existing ignores, but the Gradle work is ready to review. |
The plugin classloader exists in its own jar file for legacy reasons, and while it should go away in the future, it currently duplicates the package name of the rest of the plugin classes. This commit moves the classloader into its own unique package. relates elastic#73784
The org.elasticsearch.bootstrap package exists in server with classes for starting up Elasticsearch. The elasticsearch-core jar has a handful of classes that were split out from there, namely java version parsing and jarhell. This commit moves those classes to a new org.elasticsearch.jdk package so as to not split the server owned bootstrap package. relates elastic#73784
build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BuildPlugin.java
Show resolved
Hide resolved
...main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditPrecommitPlugin.java
Outdated
Show resolved
Hide resolved
...main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditPrecommitPlugin.java
Outdated
Show resolved
Hide resolved
...main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditPrecommitPlugin.java
Outdated
Show resolved
Hide resolved
...ternal/src/main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditTask.java
Outdated
Show resolved
Hide resolved
...ternal/src/main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditTask.java
Outdated
Show resolved
Hide resolved
...ternal/src/main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditTask.java
Show resolved
Hide resolved
| return splitPackages; | ||
| } | ||
|
|
||
| private void filterSplitPackages(Map<String, Set<String>> splitPackages) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goning back and mutating our findings seems unnecessarily complicated. Why not just filter these out directly in splitPackages(). Since we already have the package/classname there, we can just check against the filter list before adding to the result set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the separation, since the algorithms are clearer (how to find the split packages vs reading through filters).
...ternal/src/main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditTask.java
Outdated
Show resolved
Hide resolved
The plugin classloader exists in its own jar file for legacy reasons, and while it should go away in the future, it currently duplicates the package name of the rest of the plugin classes. This commit moves the classloader into its own unique package. relates #73784
The plugin classloader exists in its own jar file for legacy reasons, and while it should go away in the future, it currently duplicates the package name of the rest of the plugin classes. This commit moves the classloader into its own unique package. relates elastic#73784
The org.elasticsearch.bootstrap package exists in server with classes for starting up Elasticsearch. The elasticsearch-core jar has a handful of classes that were split out from there, namely java version parsing and jarhell. This commit moves those classes to a new org.elasticsearch.jdk package so as to not split the server owned bootstrap package. relates #73784
The org.elasticsearch.bootstrap package exists in server with classes for starting up Elasticsearch. The elasticsearch-core jar has a handful of classes that were split out from there, namely java version parsing and jarhell. This commit moves those classes to a new org.elasticsearch.jdk package so as to not split the server owned bootstrap package. relates elastic#73784
The org.elasticsearch.bootstrap package exists in server with classes for starting up Elasticsearch. The elasticsearch-core jar has a handful of classes that were split out from there, namely java version parsing and jarhell. This commit moves those classes to a new org.elasticsearch.jdk package so as to not split the server owned bootstrap package. relates #73784
The plugin classloader exists in its own jar file for legacy reasons, and while it should go away in the future, it currently duplicates the package name of the rest of the plugin classes. This commit moves the classloader into its own unique package. relates #73784
When libs/core was created, several classes were moved from server's o.e.common package, but they were not moved to a new package. Split packages need to go away long term, so that Elasticsearch can even think about modularization. This commit moves all the classes under o.e.common in core to o.e.core. relates elastic#73784
When libs/core was created, several classes were moved from server's o.e.common package, but they were not moved to a new package. Split packages need to go away long term, so that Elasticsearch can even think about modularization. This commit moves all the classes under o.e.common in core to o.e.core. relates #73784
|
@mark-vieira I think I've addressed all your comments, and I have added ignores for existing split packages. This should be ready for another look. |
o.e.common package, but they were not moved to a new package. Split packages need to go away long term, so that Elasticsearch can even think about modularization. This commit moves all the classes under o.e.common in core to o.e.core. relates elastic#73784 backport elastic#73909
ParseField is part of the x-content lib, yet it doesn't exist under the same root package as the rest of the lib. This commit moves the class to the appropriate package. relates elastic#73784
mark-vieira
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, couple questions about comments referring to lucene but don't seem related.
plugins/analysis-icu/build.gradle
Outdated
| } | ||
|
|
||
| tasks.named('splitPackagesAudit').configure { | ||
| // Lucene packages should be owned by Lucene! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do these packages have to do with Lucene?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a copy/paste error. I'll fix the comments.
| } | ||
|
|
||
| tasks.named('splitPackagesAudit').configure { | ||
| // Lucene packages should be owned by Lucene! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, these are org.elasticsearch packages, how do they conflict with Lucene?
ParseField is part of the x-content lib, yet it doesn't exist under the same root package as the rest of the lib. This commit moves the class to the appropriate package. relates #73784
When libs/core was created, several classes were moved from server's o.e.common package, but they were not moved to a new package. Split packages need to go away long term, so that Elasticsearch can even think about modularization. This commit moves all the classes under o.e.common in core to o.e.core. relates #73784 backport #73909
ParseField is part of the x-content lib, yet it doesn't exist under the same root package as the rest of the lib. This commit moves the class to the appropriate package. relates elastic#73784
Modularization of the JDK has been ongoing for several years. Recently in Java 16 the JDK began enforcing module boundaries by default. While Elasticsearch does not yet use the module system directly, there are some side effects even for those projects not modularized (eg elastic#73517). Before we can even begin to think about how to modularize, we must Prepare The Way by enforcing packages only exist in a single jar file, since the module system does not allow packages to coexist in multiple modules. This commit adds a precommit check to the build which detects split packages. The expectation is that we will add the existing split packages to the ignore list so that any new classes will not exacerbate the problem, and the work to cleanup these split packages can be parallelized. relates elastic#73525
Modularization of the JDK has been ongoing for several years. Recently in Java 16 the JDK began enforcing module boundaries by default. While Elasticsearch does not yet use the module system directly, there are some side effects even for those projects not modularized (eg #73517). Before we can even begin to think about how to modularize, we must Prepare The Way by enforcing packages only exist in a single jar file, since the module system does not allow packages to coexist in multiple modules. This commit adds a precommit check to the build which detects split packages. The expectation is that we will add the existing split packages to the ignore list so that any new classes will not exacerbate the problem, and the work to cleanup these split packages can be parallelized. relates #73525
Modularization of the JDK has been ongoing for several years. Recently
in Java 16 the JDK began enforcing module boundaries by default. While
Elasticsearch does not yet use the module system directly, there are
some side effects even for those projects not modularized (eg #73517).
Before we can even begin to think about how to modularize, we must
Prepare The Way by enforcing packages only exist in a single jar file,
since the module system does not allow packages to coexist in multiple
modules.
This commit adds a precommit check to the build which detects split
packages. The expectation is that we will add the existing split
packages to the ignore list so that any new classes will not exacerbate
the problem, and the work to cleanup these split packages can be
parallelized.
relates #73525