-
Notifications
You must be signed in to change notification settings - Fork 41.1k
BeanPostProcessor architecture rules do not work with external classes #45202
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
This works because |
Thanks, @nosan. I think that the "official" Gradle way of doing this would be to use |
Thanks, @wilkinsona I will take a look. |
I've been trying to use
From my understanding, rules are not serializable. Do you have any suggestions on how to handle this? |
Hmm, perhaps using the worker API isn't such a good idea after all. Apologies for the dead end. I don't recall the details of your original approach, but an alternative to manipulating the thread context class loader would be a custom Perhaps it's better to just stick with setting the TCCL. We can reconsider if it causes problems in the future. |
@philwebb |
593cba2
to
6c9b61d
Compare
6c9b61d
to
c2a401b
Compare
I've updated this PR to utilize a custom Additionally, I made updates to the I also added a test to verify external BPP. Builed failed due to:
|
I can fix |
Project project = ProjectBuilder.builder().withProjectDir(projectDir).build();
project.getTasks().register("checkArchitecture", ArchitectureCheck.class, (task) -> {
task.setClasses(project.files("classes"));
callback.accept(task);
}).get(); //This line triggers a callback but is currently being missed
But I still need |
66264d2
to
09faa83
Compare
Prior to this commit, certain rules, such as `BeanPostProcessor`, did not work with external classes. This commit ensures that `ArchRules` are executed using the `CompileClasspathClassResolver`, which resolves any missing classes. This helps build a Class Graph for external classes. Signed-off-by: Dmytro Nosan <[email protected]>
Prior to this commit, certain rules, like BeanPostProcessor, did not work with external classes. This commit ensures that ArchRules are executed within a context ClassLoader that includes all classes from the compile classpath. Signed-off-by: Dmytro Nosan <[email protected]>
09faa83
to
5baa6d9
Compare
Unfortunately, this approach has a significant limitation: it is not possible to pass a
Sticking with setting the TCCL seems better |
This PR includes two commits:
|
Prior to this commit, certain rules, like BeanPostProcessor, did not work with external classes. This commit ensures that ArchRules are executed within a context ClassLoader that includes all classes from the compile classpath. See gh-45202 Signed-off-by: Dmytro Nosan <[email protected]>
Thanks very much, @nosan. I went with the TCCL-based approach in the end. |
Thanks, @wilkinsona I came across the commit a572283, and I was wondering if this |
I don't think it needs to be as we don't have any BPPs in those branches that use infrastructure beans. We can backport the slight relaxation of the rule in the future if needed. |
See #45196