TNG / ArchUnit

A Java architecture test library, to specify and assert architecture rules in plain Java
http://archunit.org
Apache License 2.0
3.18k stars 288 forks source link

Tests fail when using non-default "target" folder #1330

Open heyarny opened 2 months ago

heyarny commented 2 months ago

It seems like all tests & validations are only working when using the default "target" maven folder. As soon you change the target to something else, you get unwanted errors, because many packages and other settings match the tests itself.

Please add an option to define the target folder via maven config or even better: use ${project.build.directory} instead.

codecholeric commented 1 month ago

Can you give an example of what you mean? Or better a small project to reproduce this? Principally ArchUnit usually just reads classes from the classpath, so it doesn't matter in which folder your classes reside, as long as the ClassLoader can find them.

If you refer to the predefined ImportOption DoNotIncludeTests (which indeed depends on a couple of default folders), then that's a known limitation. It's meant for the 99.999% of default cases where we can just assume a standard build tool layout. If you've reconfigured that, then you just need to create a custom ImportOption (you can peek into DoNotIncludeTests to copy & paste).