Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a switch to determine multi-module wiring order at compile time. #479

Merged
merged 17 commits into from
Apr 18, 2024

Conversation

SentryMan
Copy link
Collaborator

So the thought here is that we can directly read the requires and provides via the external provider and determine the wiring order in the generator.

Then we can generate a class like this:

public final class CompiledOrder implements ModuleOrdering {

  private final Module[] sortedModules = new Module[2];
  private static final Map<String, Integer> INDEXES =
      Map.ofEntries(
          entry("org.example.external.aspect.sub.ExampleExternalAspectModule", 0),
          entry("org.other.one.OneModule", 1));
  @Override
  public List<Module> factories() {
    return List.of(sortedModules);
  }

  @Override
  public Set<String> orderModules() {
    return INDEXES.keySet();
  }

  @Override
  public void add(Module module) {
    final var index = INDEXES.get(module.getClass().getTypeName());

    if (index != null) {
      sortedModules[index] = module;
    }
  }

  @Override
  public boolean isEmpty() {
    return sortedModules.length == 0;
  }
}

which knows ahead of time what goes where.

  • adds a new attribute to InjectModule to toggle this mode
  • generator will perform wiring checks and warn if no modules that satisfy conditions are in the class/module path
  • adds new interface for determining wiring order
  • adds new functions to the maven plugin to provide the module and their dependency information

should fix #478

@rbygrave rbygrave changed the title Add a switch to determine wiring order at compile time. Add a switch to determine module wiring order at compile time. Jan 9, 2024
for the strict wiring path there is no need to initialize
@SentryMan SentryMan requested a review from rbygrave February 29, 2024 02:08
@SentryMan SentryMan self-assigned this Feb 29, 2024
@SentryMan SentryMan added the enhancement New feature or request label Feb 29, 2024
@SentryMan SentryMan changed the title Add a switch to determine module wiring order at compile time. Add a switch to determine multi-module wiring order at compile time. Apr 7, 2024
@SentryMan SentryMan enabled auto-merge April 7, 2024 04:13
@rbygrave
Copy link
Contributor

I've broken something with my last commits there trying to resolve the merge conflict. Not sure if we want to remove/revert those ones and try again.

@SentryMan SentryMan added this to the 10.0 milestone Apr 17, 2024
@rbygrave rbygrave disabled auto-merge April 18, 2024 09:37
@rbygrave rbygrave merged commit b7d0750 into avaje:master Apr 18, 2024
4 checks passed
@SentryMan SentryMan deleted the wiring-order branch May 22, 2024 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a mechanism to determine multi-module wiring order at compile time. (for multi-module projects)
2 participants