-
Notifications
You must be signed in to change notification settings - Fork 288
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
ClassFileImporter.importClasspath() ignores .withImportOption #296
Comments
Yes, you're right, that behavior is counter intuitive |
Before this commit, all custom import options were ignored and replaced with DO_NOT_INCLUDE_ARCHIVES. From this commit on DO_NOT_INCLUDE_ARCHIVES will be added to the already supplied import options. Fixes TNG#296
Before this commit, all custom import options were ignored and replaced with DO_NOT_INCLUDE_ARCHIVES. From this commit on DO_NOT_INCLUDE_ARCHIVES will be added to the already supplied import options. Fixes TNG#296 Signed-off-by: Roland Weisleder <[email protected]>
When implementing #328 I was curious if we could rework First, it's the only method that takes I implemented something on rweisleder/ArchUnit@cae6840. public JavaClasses importEntireClasspath() {
return importLocations(Locations.inClassPath());
} To replace public JavaClasses importAllClasses() {
return withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_ARCHIVES).importEntireClasspath();
} And I deprecated both WDYT? |
Sounds all good to me 👍 AFAIR I looked at Degraph back then and copied the default which was to ignore JARs (but I might remember wrong, it's a long time ago 😉), that's where the different behavior comes from. I agree that this was not a good idea, I should have favored consistency. I see two ways forward, a) introduce the new method like you did, deprecated |
Before this commit, all custom import options were ignored and replaced with DO_NOT_INCLUDE_ARCHIVES. From this commit on DO_NOT_INCLUDE_ARCHIVES will be added to the already supplied import options. Fixes TNG#296 Signed-off-by: Roland Weisleder <[email protected]>
Option c) would be to add I'm still not sure if |
Hmm, honestly I like
How do I not include tests and yet import the "entire" classpath? 😉 If I would redesign from scratch there would be one method |
I also think that only one method This reminds of |
Yeah, I agree. Also you will likely notice, because either the test will suddenly take a lot longer and you'll wonder (or it doesn't matter 😉) or fail with new errors about classes that were formerly not imported. It would be different if we would import less, then a test could silently not test the right thing anymore. But with this change the test would just test more and possibly fail with useless violations, and at that point I would guess everyone going through the release notes for some breaking changes 😉 |
…328 Until now any `ImportOption` supplied via `classFileImporter.withImportOptions(importOptions)` was disregarded, if `importClasspath()` was used (that method just used new `ImportOptions` with some default). Now any previously added `ImportOptions` will be merged with the defaults resulting in a more consistent and less surprising development experience. Fixes #296
Before this commit, all custom import options were ignored and replaced with DO_NOT_INCLUDE_ARCHIVES. From this commit on DO_NOT_INCLUDE_ARCHIVES will be added to the already supplied import options. Fixes #296 Signed-off-by: Roland Weisleder <[email protected]>
…328 Until now any `ImportOption` supplied via `classFileImporter.withImportOptions(importOptions)` was disregarded, if `importClasspath()` was used (that method just used new `ImportOptions` with some default). Now any previously added `ImportOptions` will be merged with the defaults resulting in a more consistent and less surprising development experience. Fixes #296
The user guide contains the following snippet:
Unfortunately
ClassFileImporter.importClasspath()
seems to override the import options and includes test classes:The following code works as expected:
The text was updated successfully, but these errors were encountered: