Skip to content

Regex validation error #325

Description

@krystek-dev

I have created example project where you can find not working regex as expected.

I would like to have modules that ends with "Ui" in their name. So there should be allowed to reference/depend from non UI modules to UI but UI module cannot depends another UI module.

For example modules:

  • composeApp
  • libUi
  • testUi
  • another

The composeApp could depends another and all Uis, but libUi can depends composeApp (logically do not need that) but could also depends another.
So i found restrictions that module that ends with Ui could refers just non-ending Ui modules and modules that not ends with Ui could reference all modules.

Non ending modules regex: ^(?!.*Ui$).*$
All modules regex: .*

Ending Ui regex: .*Ui$
Modules that NOT ends with Ui: ^(?!.*Ui$).*$

Regex could be checked https://regex101.com/

There is configuration

moduleGraphAssert {
    configurations += setOf("commonMainImplementation", "commonMainApi")
    maxHeight = 3
    allowed = arrayOf(
        ".*Ui$ -> ^(?!.*Ui$).*$",
        "^(?!.*Ui$).*$  -> .*",
    )
    restricted = arrayOf(
    )
    assertOnAnyBuild = true
}

Build build ends with error:
Failed to notify build listener.

[':composeApp' -> ':shared'] not allowed by any of ['.Ui$ -> ^(?!.Ui$).$', '^(?!.Ui$).$ -> .']
[':shared:libUi' -> ':shared:testUi'] not allowed by any of [':.Ui$ -> ^(?!.Ui$).$', '^(?!.Ui$).$ -> .']

The sample project:
MyApplication.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions