Skip to content

add haveDependenciesThat condition to ArchConditions#1580

Open
wakingrufus wants to merge 1 commit intoTNG:mainfrom
wakingrufus:haveDependenciesThat
Open

add haveDependenciesThat condition to ArchConditions#1580
wakingrufus wants to merge 1 commit intoTNG:mainfrom
wakingrufus:haveDependenciesThat

Conversation

@wakingrufus
Copy link
Copy Markdown

@wakingrufus wakingrufus commented Jan 19, 2026

there is not a good way to craft such a condition with current Public APIs

the use case I want this for is:

noClasses()
.should(
  haveAnyDependenciesThat(
    not(resideInSamePackage())
      .and(dependencyTarget(annotatedWith(Deprecated.class)))
    )
  )

where resideInSamePackage() is a DescribedPredicate which requires comparing the target and the owner in the same condition

Copy link
Copy Markdown
Contributor

@StefanGraeber StefanGraeber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :)

@wakingrufus wakingrufus force-pushed the haveDependenciesThat branch from 1593ed1 to 75d0251 Compare April 27, 2026 15:30
@wakingrufus
Copy link
Copy Markdown
Author

Thanks! I rebased. Just need approval for workflows

Copy link
Copy Markdown
Contributor

@StefanGraeber StefanGraeber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you still need the signed-off line in the commit message.
otherwise this change is ready to submit

@hankem
Copy link
Copy Markdown
Member

hankem commented May 7, 2026

Ah yes, and please squash the two commits. Thank you!

Signed-off-by: John Burns <wakingrufus@gmail.com>

Update archunit/src/test/java/com/tngtech/archunit/lang/conditions/ArchConditionsTest.java

Co-authored-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
@wakingrufus wakingrufus force-pushed the haveDependenciesThat branch from 2f1a9e9 to da88571 Compare May 7, 2026 17:54
@wakingrufus wakingrufus requested a review from hankem May 7, 2026 17:54
@wakingrufus
Copy link
Copy Markdown
Author

Ah yes, and please squash the two commits. Thank you!

rebased and squashed. Thanks again!

Copy link
Copy Markdown
Member

@hankem hankem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!
Just one last thought from my side, as naming things is hard...

}

@PublicAPI(usage = ACCESS)
public static ArchCondition<JavaClass> haveAnyDependenciesThat(DescribedPredicate<? super Dependency> predicate) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether there can be any confusion about the name. Will it be clear that haveAnyDependenciesThat(…) means "have any direct dependencies that …" as opposed to "have any transitive dependencies that …"?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants