3

In my root project I have two sub projects with that package structure.

Project 1: com.app
Project 2: com.app.api

In Project 1 I have a Class definied with ArchRules, anotaed like that

@AnalyzeClasses( packages = "com.app")
public class ArchTests

The Problem is that if I run that test, its analyze everything from Project 2 too. How I can exclude package com.app.api?

kapex
  • 28,903
  • 6
  • 107
  • 121
Tristate
  • 1,498
  • 2
  • 18
  • 38

1 Answers1

8

You can use custom importOptions:

@AnalyzeClasses(packages = "com.app", importOptions = ExcludeApiImportOption.class)

where the ImportOption is bascially a predicate whether a Location should be imported or not:

class ExcludeApiImportOption implements com.tngtech.archunit.core.importer.ImportOption {
    @Override
    public boolean includes(Location location) {
        return !location.contains("com/app/api");
    }
}
JRA_TLL
  • 1,186
  • 12
  • 23
Manfred
  • 2,269
  • 1
  • 5
  • 14