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

Custom AOT plugin not building #341

Open
SemperEtAnte opened this issue Jan 10, 2025 · 0 comments
Open

Custom AOT plugin not building #341

SemperEtAnte opened this issue Jan 10, 2025 · 0 comments

Comments

@SemperEtAnte
Copy link

Expected Behavior

I created AOT Code Generator:

package ru.semperante;

import io.micronaut.aot.core.AOTContext;
import io.micronaut.aot.core.AOTModule;
import io.micronaut.aot.core.codegen.AbstractCodeGenerator;
import io.micronaut.core.annotation.NonNull;

@AOTModule(id = "ru.semperante.swagger")
public class SwaggerMicronautAotGenerator extends AbstractCodeGenerator {
   @Override
   public void generate(@NonNull AOTContext context) {
      System.out.println("I CALLEDDDDD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
   }
}

Created META-INF/services/io.micronaut.aot.core.AOTCodeGenerator:

ru.semperante.SwaggerMicronautAotGenerator

Published it to local maven repository, and added to other project
aotPlugins("ru.semperante:micronaut-swagger-aot-plugin:1.7")

and added into aot block:
configurationProperties.put("ru.semperante.swagger.enabled", "true")

Expecting to see "I CALEEEDDDDDD..." in console, but...

Actual Behaviour

But instead I've got:

> Task :prepareJitOptimizations FAILED
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at io.micronaut.aot.cli.Main.executeInIsolatedLoader(Main.java:113)
        at io.micronaut.aot.cli.Main.run(Main.java:87)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2030)
        at picocli.CommandLine.access$1500(CommandLine.java:148)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
        at picocli.CommandLine.execute(CommandLine.java:2174)
        at io.micronaut.aot.cli.Main.execute(Main.java:134)
        at io.micronaut.aot.cli.Main.main(Main.java:138)
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at io.micronaut.aot.cli.Main.executeInIsolatedLoader(Main.java:107)
        ... 11 more
Caused by: java.util.ServiceConfigurationError: io.micronaut.aot.core.AOTCodeGenerator: ru.semperante.SwaggerMicronautAotGenerator not a subtype
        at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:593)
        at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1244)
        at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273)
        at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
        at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393)
        at java.base/java.util.Iterator.forEachRemaining(Iterator.java:132)
        at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
        at io.micronaut.aot.core.config.SourceGeneratorLoader.load(SourceGeneratorLoader.java:82)
        at io.micronaut.aot.MicronautAotOptimizer$Runner.execute(MicronautAotOptimizer.java:337)
        at io.micronaut.aot.MicronautAotOptimizer.execute(MicronautAotOptimizer.java:201)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        ... 13 more

FAILURE: Build failed with an exception.

And I have no idea why...

Steps To Reproduce

No response

Environment Information

OS: Windows 11 Pro
JDK: GraalVM 21.0.5 VM 23.1.5
Gradle: 8.10.1

Example Application

https://github.com/SemperEtAnte/micronaut-swagger-additions/tree/main/aot-plugin

Version

4.7.1 (2.6.0 AOT core)

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

No branches or pull requests

1 participant