Skip to content

modules doesn't respect value as an alias for name issues #1520

@xenoterracide

Description

@xenoterracide

jmolecules documents @Module( value = "..." ) as an alias for name

Given

modules().definedByAnnotation(Module.class).should().beFreeOfCycles().check(javaClasses);

When

@Module("Annotations")
@InfrastructureLayer
@NullMarked
package com.myorg.annotation;

import org.jmolecules.architecture.layered.InfrastructureLayer;
import org.jmolecules.ddd.annotation.Module;
import org.jspecify.annotations.NullMarked;
@NullMarked
@Module("Utilities")
@InfrastructureLayer
package com.myorg.tool;

import org.jmolecules.architecture.layered.InfrastructureLayer;
import org.jmolecules.ddd.annotation.Module;
import org.jspecify.annotations.NullMarked;

Then

this is a hard to debug issue, since it doesn't identify the package or anything

Found multiple modules with the same name: []
java.lang.IllegalArgumentException: Found multiple modules with the same name: []
at com.tngtech.archunit.library.modules.ArchModules.groupBy(ArchModules.java:105)
at com.tngtech.archunit.library.modules.ArchModules.<init>(ArchModules.java:82)
at com.tngtech.archunit.library.modules.ArchModules.<init>(ArchModules.java:76)
at com.tngtech.archunit.library.modules.ArchModules$Creator$WithGenericDescriptor.modularize(ArchModules.java:567)
at com.tngtech.archunit.library.modules.syntax.ModuleRuleDefinition$Creator.lambda$definedByAnnotation$0(ModuleRuleDefinition.java:82)
at com.tngtech.archunit.library.modules.syntax.ModulesTransformer.transform(ModulesTransformer.java:52)
at com.tngtech.archunit.lang.ArchRule$Factory$SimpleArchRule.evaluate(ArchRule.java:180)
at com.tngtech.archunit.lang.ArchRule$Assertions.check(ArchRule.java:84)

It would be useful to be able to define what field to read the name from as well as perhaps respecting "value" by default. At the very least printing out the conflicting "id's" (package names) and that the name field is null as I find that I should have been looking at the Module.name field confusing; and had to run the debugger. My other developers spent hours trying to figure this out and failed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions