1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.micronaut.build.aot;
17
18 import io.micronaut.build.services.CompilerService;
19 import io.micronaut.build.services.DependencyResolutionService;
20 import io.micronaut.build.services.ExecutorService;
21 import org.apache.maven.execution.MavenSession;
22 import org.apache.maven.plugins.annotations.LifecyclePhase;
23 import org.apache.maven.plugins.annotations.Mojo;
24 import org.apache.maven.plugins.annotations.ResolutionScope;
25 import org.apache.maven.project.MavenProject;
26 import org.eclipse.aether.RepositorySystem;
27
28 import javax.inject.Inject;
29 import java.io.File;
30 import java.util.Arrays;
31 import java.util.List;
32
33
34
35
36 @Mojo(name = AotSampleMojo.NAME, defaultPhase = LifecyclePhase.PACKAGE, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
37 public class AotSampleMojo extends AbstractMicronautAotCliMojo {
38
39 public static final String SAMPLE_AOT_PROPERTIES_FILE_NAME = "aot.properties";
40 public static final String NAME = "aot-sample-config";
41
42 @Inject
43 public AotSampleMojo(CompilerService compilerService, ExecutorService executorService, MavenProject mavenProject,
44 MavenSession mavenSession, RepositorySystem repositorySystem,
45 DependencyResolutionService dependencyResolutionService) {
46 super(compilerService, executorService, mavenProject, mavenSession, repositorySystem, dependencyResolutionService);
47 }
48
49 @Override
50 protected List<String> getExtraArgs() {
51 return Arrays.asList(
52 "--config",
53 outputFile(SAMPLE_AOT_PROPERTIES_FILE_NAME).getAbsolutePath()
54 );
55 }
56
57 @Override
58 protected void onSuccess(File outputDir) {
59 File sampleFile = new File(outputDir, SAMPLE_AOT_PROPERTIES_FILE_NAME);
60 if (sampleFile.exists()) {
61 getLog().info("Sample configuration file written to " + sampleFile);
62 }
63 }
64
65 @Override
66 String getName() {
67 return NAME;
68 }
69 }