-
Notifications
You must be signed in to change notification settings - Fork 25
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
Preconfigured rules scan all classes on classpath, not only the ones from the project #13
Comments
Could it be, that this is not a bug, but simply configuration of ArchUnit to resolve missing dependencies from the classpath? (i.e. if the classes you are importing have dependencies that you are not importing?) |
@codecholeric , yes, it looks like this could be the "issue". But I have a problem : when running ArchUnit through the Maven plugin, the property file in the project using it is not picked up . that's why I created TNG/ArchUnit#197 : I tried to make several tests in one of my other project, using latest version of ArchUnit and building locally :
As you can see, the file is there in 2nd position (I placed it at the root of src/test/resources) , but it's picked up by getClass().getResourceAsStream(propertiesResourceName) Any idea of how to fix this, either in ArchUnit or in the maven plugin ? |
I face a similar issue when trying to ignore violations. Did you manage to do that? I guess not, because if I place the
In So regarding to the behavior and the Maven guide I guess it would be necessary to enhance TNG/ArchUnit to inject the violation ignoring patterns programmatically. Then one could enhance the plugin's configuration to inject values to ArchUnit instead of reading the properties file. Maybe the best would be to allow injecting the class loader directly? Or at least read the configuration files from the What do you think @codecholeric and @vincent-fuchs ? |
In my opinion the problem might be, that ArchUnit should use the |
My opinion: Sounds good - if the configuration and the ignore file (or its entries) could be set programmatically then the Arch Unit Maven Plugin could make use of it and fill it with its own configuration entries. The only thing for users that would be important to document is the difference in configuring Arch Unit (via files) and the Arch Unit Maven Plugin (via plugin configuration in the POM) - but I think that's consistent to the context. I don't think that Maven Plugin users would expect configuration files to work - only users migrating from using Arch Unit (alone) to Arch Unit Maven Plugin would be affected. |
OK for me if we can set the configuration file programmatically, so that we define it with the plugin (archunit-maven-plugin.properties ?). So we need to wait for a change in ArchUnit to be able to try again, right @codecholeric ? I guess it's not as easy as simply replacing |
@vincent-fuchs Actually I think it is as easy. At least for now it looks to me like it should solve your problems and not have any negative consequences for the default case.
|
… ContextClassLoader, not just classes. Otherwise tools like the ArchUnit Maven Plugin that reconfigure the ContextClassLoader to import classes cannot load these files in a consistent way. See: societe-generale/arch-unit-maven-plugin#13 Signed-off-by: Peter Gafert <[email protected]>
quick update : file seems to be found - I see the log statement saying :
I'll give a more exhaustive status tomorrow |
I confirm it's working !
Now I'll wait for the next ArchUnit release to make a release of the plugin. Thanks !! |
fixed by @codecholeric in TNG/ArchUnit@81c31f6 . archunit.properties file will be found by the plugin once we upgrade to 0.11.0 or greater |
So is it fixed? 😉 |
yes it is, with an archunit.properties file in the maven module ! thanks a lot for your help. Now it's more difficult to realize though, because the "Analyzing class" log statement is at debug level, so it won't get displayed by default. If I had started using ArchUnit with 0.11.0, I would probably never have realized the "issue" ;-) |
v 2.2.0 has ArchUnit 0.11.0 , so closing this issue. |
Can't have it all 😉 |
… ContextClassLoader, not just classes. Otherwise tools like the ArchUnit Maven Plugin that reconfigure the ContextClassLoader to import classes cannot load these files in a consistent way. See: societe-generale/arch-unit-maven-plugin#13 Signed-off-by: Peter Gafert <[email protected]>
Summary
When the plugin runs, we see that even the standard java classes are scanned
Type of Issue
It is a :
Motivation
Execution would be faster if we were scanning only the classes from the project. Furthermore, it may happen that one standard java class has a violation for some rules.
Current Behavior
When I run the build I have this :
(..my classes are also scanned)
Expected Behavior
Only "my" classes should be scanned.
Steps to Reproduce (for bugs)
I guess this happens in all projects..
Your Environment
The text was updated successfully, but these errors were encountered: