Skip to content

Commit

Permalink
remove hard spi dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
SentryMan committed Jun 23, 2024
1 parent 4ddd488 commit 13f7d50
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ private static final class Ctx {
private final String diAnnotation;
private final boolean warnHttp;
private final boolean injectPresent;
private final boolean spiPresent;
private boolean validated;

Ctx(ProcessingEnvironment env) {
var elements = env.getElementUtils();

this.injectPresent = elements.getTypeElement(Constants.COMPONENT) != null;
this.warnHttp = elements.getTypeElement("io.avaje.http.api.Controller") != null;
this.spiPresent = elements.getTypeElement("io.avaje.spi.internal.ServiceProcessor") != null;

final var jakarta = elements.getTypeElement(Constants.SINGLETON_JAKARTA) != null;

Expand All @@ -48,11 +50,13 @@ static void init(ProcessingEnvironment processingEnv) {
}

static FileObject createMetaInfWriterFor(String interfaceType) throws IOException {
return filer()
.createResource(
StandardLocation.CLASS_OUTPUT,
"",
interfaceType.replace("META-INF/services/", "META-INF/generated-services/"));

var serviceFile =
CTX.get().spiPresent
? interfaceType.replace("META-INF/services/", "META-INF/generated-services/")
: interfaceType;

return filer().createResource(StandardLocation.CLASS_OUTPUT, "", serviceFile);
}

static String diAnnotation() {
Expand Down

0 comments on commit 13f7d50

Please sign in to comment.