Search in sources :

Example 1 with CDIDependencyInjectionAnnotator

use of io.automatiko.engine.codegen.di.CDIDependencyInjectionAnnotator in project automatiko-engine by automatiko-io.

the class AutomatikoQuarkusProcessor method createApplicationGenerator.

private ApplicationGenerator createApplicationGenerator(AutomatikoBuildTimeConfig config, AppPaths appPaths, CompositeIndex archivesIndex, ApplicationModel appModel) throws IOException {
    boolean usePersistence = archivesIndex.getClassByName(createDotName(persistenceFactoryClass)) != null;
    GeneratorContext context = buildContext(config, appPaths, archivesIndex);
    ApplicationGenerator appGen = new ApplicationGenerator(config.packageName().orElse(DEFAULT_PACKAGE_NAME), new File(appPaths.getFirstProjectPath().toFile(), "target")).withDependencyInjection(new CDIDependencyInjectionAnnotator()).withPersistence(usePersistence).withGeneratorContext(context);
    List<String> dependencies = new ArrayList<>();
    if (appModel != null) {
        for (ResolvedDependency i : appModel.getRuntimeDependencies()) {
            dependencies.add(i.getResolvedPaths().getSinglePath().toAbsolutePath().toString());
        }
    }
    addProcessGenerator(appPaths, usePersistence, appGen, dependencies);
    if (context.getBuildContext().isDmnSupported()) {
        addDecisionGenerator(appPaths, appGen, false, dependencies);
    }
    return appGen;
}
Also used : CDIDependencyInjectionAnnotator(io.automatiko.engine.codegen.di.CDIDependencyInjectionAnnotator) ApplicationGenerator(io.automatiko.engine.codegen.ApplicationGenerator) ArrayList(java.util.ArrayList) ResolvedDependency(io.quarkus.maven.dependency.ResolvedDependency) GeneratorContext(io.automatiko.engine.codegen.GeneratorContext) GeneratedFile(io.automatiko.engine.codegen.GeneratedFile) File(java.io.File)

Example 2 with CDIDependencyInjectionAnnotator

use of io.automatiko.engine.codegen.di.CDIDependencyInjectionAnnotator in project automatiko-engine by automatiko-io.

the class AutomatikoCompilationProvider method compile.

@Override
public final void compile(Set<File> filesToCompile, Context context) {
    Set<File> allFiles = AutomatikoBuildData.get().getGenerationContext().collectConnectedFiles(filterFilesToCompile(filesToCompile));
    if (allFiles.isEmpty()) {
        return;
    }
    File outputDirectory = AutomatikoBuildData.get().getGenerationContext().getClassesPath();
    try {
        ApplicationGenerator appGen = new ApplicationGenerator(AutomatikoBuildData.get().getConfig().packageName().orElse(AutomatikoQuarkusProcessor.DEFAULT_PACKAGE_NAME), outputDirectory).withDependencyInjection(new CDIDependencyInjectionAnnotator()).withGeneratorContext(AutomatikoBuildData.get().getGenerationContext());
        addGenerator(appGen, allFiles, context);
        Collection<GeneratedFile> generatedFiles = appGen.generate();
        Set<File> generatedSourceFiles = new HashSet<>();
        for (GeneratedFile file : generatedFiles) {
            Path path = pathOf(outputDirectory.getPath(), file.relativePath());
            if (file.getType() != GeneratedFile.Type.APPLICATION && file.getType() != GeneratedFile.Type.APPLICATION_CONFIG) {
                Files.write(path, file.contents());
                generatedSourceFiles.add(path.toFile());
            }
        }
        javaCompile(generatedSourceFiles, context, outputDirectory);
    } catch (IOException e) {
        throw new AutomatikoCompilerException(e);
    }
}
Also used : Path(java.nio.file.Path) CDIDependencyInjectionAnnotator(io.automatiko.engine.codegen.di.CDIDependencyInjectionAnnotator) ApplicationGenerator(io.automatiko.engine.codegen.ApplicationGenerator) IOException(java.io.IOException) GeneratedFile(io.automatiko.engine.codegen.GeneratedFile) File(java.io.File) GeneratedFile(io.automatiko.engine.codegen.GeneratedFile) HashSet(java.util.HashSet)

Aggregations

ApplicationGenerator (io.automatiko.engine.codegen.ApplicationGenerator)2 GeneratedFile (io.automatiko.engine.codegen.GeneratedFile)2 CDIDependencyInjectionAnnotator (io.automatiko.engine.codegen.di.CDIDependencyInjectionAnnotator)2 File (java.io.File)2 GeneratorContext (io.automatiko.engine.codegen.GeneratorContext)1 ResolvedDependency (io.quarkus.maven.dependency.ResolvedDependency)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1