xmolecules / jmolecules-integrations

Technology integration for jMolecules
Apache License 2.0
85 stars 23 forks source link

Package based annotation not working #196

Closed stefanzilske closed 1 year ago

stefanzilske commented 1 year ago

I am using jmolecules together with Kotlin and so far, I could place ring annotations (e.g. @DomainModelRing) inside package-info.java files (package-info.kt never worked), which where then considered properly by an ArchUnit test using JMoleculesArchitectureRules#ensureOnionClassical.

Now with upgrading to jmoleclues 2023.1.1 and archunit 1.1 it seems that this is not working anymore, I have to annotate all classes directly, in order to make the test work properly. Otherwise the test will always be green, even if there are obvious violations.

Is this a known issue (couldn't find one), am I using it wrong? Any workarounds?

Thanks and keep up the great work! Stefan

Edit: If needed I can setup a small example, but maybe someone can answer this without.

stefanzilske commented 1 year ago

I created a small example: https://github.com/stefanzilske/kotlin-jmolecules-archunit/tree/develop

If you build the project, you will see that the archunit test passes, even though there is a dependency from the domain model ring to the infrastructure ring. If you go to the two classes and add (uncomment) the @DomainModelRing and @InfrastructureRing directly, the test will fail.

stefanzilske commented 1 year ago

Hey, could somebody take a look at this? @odrotbohm maybe?

odrotbohm commented 1 year ago

I tried ./gradlew test on your project, and it looks like the package-info.java files are not compiled. So I guess it's an issue with Gradle / Kotlin?

stefanzilske commented 1 year ago

Uh, it seems you are right. I added a Maven pom.xml file and when I build the project with Maven, it seems that it works and the test is failing.

That sucks, because I have running examples, that are built with Maven und still the tests do not work. So I have to take a look again.

stefanzilske commented 1 year ago

@odrotbohm thank you for pointing me into the right direction. I figured out that for my Maven based Kotlin projects java-compile was enabled, but sourceDirectory not set to src/main/kotlin.

Now it's working again as expected.