Search in sources :

Example 1 with GeneratorContext

use of io.automatiko.engine.codegen.GeneratorContext 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 GeneratorContext

use of io.automatiko.engine.codegen.GeneratorContext in project automatiko-engine by automatiko-io.

the class AutomatikoQuarkusProcessor method buildContext.

private GeneratorContext buildContext(AutomatikoBuildTimeConfig config, AppPaths appPaths, IndexView index) {
    GeneratorContext generationContext = QuarkusGeneratorContext.ofResourcePath(appPaths.getResourceFiles()[0], appPaths.getFirstClassesPath().toFile());
    generationContext.withBuildContext(new QuarkusApplicationBuildContext(config, className -> {
        DotName classDotName = createDotName(className);
        return !index.getAnnotations(classDotName).isEmpty() || index.getClassByName(classDotName) != null;
    }, className -> {
        return index.getAllKnownImplementors(createDotName(className)).stream().map(c -> c.name().toString()).collect(Collectors.toList());
    }));
    return AutomatikoBuildData.create(config, generationContext).getGenerationContext();
}
Also used : BiFunction(java.util.function.BiFunction) LoggerFactory(org.slf4j.LoggerFactory) GeneratorContext(io.automatiko.engine.codegen.GeneratorContext) ClassInfo(org.jboss.jandex.ClassInfo) TestRunListener(io.quarkus.deployment.dev.testing.TestRunListener) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) CodeGenConstants(io.automatiko.engine.codegen.CodeGenConstants) GeneratedBeanBuildItem(io.quarkus.arc.deployment.GeneratedBeanBuildItem) MethodInfo(org.jboss.jandex.MethodInfo) ArchiveRootBuildItem(io.quarkus.deployment.builditem.ArchiveRootBuildItem) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) CompilationTask(javax.tools.JavaCompiler.CompilationTask) CompositeIndex(org.jboss.jandex.CompositeIndex) Diagnostic(javax.tools.Diagnostic) Map(java.util.Map) CDIDependencyInjectionAnnotator(io.automatiko.engine.codegen.di.CDIDependencyInjectionAnnotator) URI(java.net.URI) Path(java.nio.file.Path) DiagnosticCollector(javax.tools.DiagnosticCollector) TestListener(io.quarkus.deployment.dev.testing.TestListener) TestListenerBuildItem(io.quarkus.deployment.dev.testing.TestListenerBuildItem) SimpleJavaFileObject(javax.tools.SimpleJavaFileObject) IoUtils(io.automatiko.engine.services.utils.IoUtils) StandardLocation(javax.tools.StandardLocation) Model(io.automatiko.engine.api.Model) JavaCompiler(javax.tools.JavaCompiler) AutomatikoMessages(io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages) Collection(java.util.Collection) Set(java.util.Set) NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) QuarkusClassLoader(io.quarkus.bootstrap.classloading.QuarkusClassLoader) Collectors(java.util.stream.Collectors) PackageConfig(io.quarkus.deployment.pkg.PackageConfig) JavaFileObject(javax.tools.JavaFileObject) List(java.util.List) ApplicationModel(io.quarkus.bootstrap.model.ApplicationModel) ConfigProvider(org.eclipse.microprofile.config.ConfigProvider) ResolvedDependency(io.quarkus.maven.dependency.ResolvedDependency) ServiceProviderBuildItem(io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem) QuarkusApplicationBuildContext(io.automatiko.engine.codegen.context.QuarkusApplicationBuildContext) ReflectiveHierarchyIgnoreWarningBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem) ToolProvider(javax.tools.ToolProvider) IndexingUtil(io.quarkus.deployment.index.IndexingUtil) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) ProcessCodegen(io.automatiko.engine.codegen.process.ProcessCodegen) DotName(org.jboss.jandex.DotName) PersistenceGenerator(io.automatiko.engine.codegen.process.persistence.PersistenceGenerator) LaunchMode(io.quarkus.runtime.LaunchMode) CurateOutcomeBuildItem(io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) PathsCollection(io.quarkus.bootstrap.model.PathsCollection) Indexer(org.jboss.jandex.Indexer) BuildStep(io.quarkus.deployment.annotations.BuildStep) BaseWorkItem(io.automatiko.engine.workflow.BaseWorkItem) Index(org.jboss.jandex.Index) LinkedHashSet(java.util.LinkedHashSet) IndexView(org.jboss.jandex.IndexView) GeneratedResourceBuildItem(io.quarkus.deployment.builditem.GeneratedResourceBuildItem) GeneratedFile(io.automatiko.engine.codegen.GeneratedFile) RuntimeInitializedClassBuildItem(io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem) Logger(org.slf4j.Logger) MemoryClassPathElement(io.quarkus.bootstrap.classloading.MemoryClassPathElement) ClassPathElement(io.quarkus.bootstrap.classloading.ClassPathElement) ApplicationArchivesBuildItem(io.quarkus.deployment.builditem.ApplicationArchivesBuildItem) Files(java.nio.file.Files) ApplicationGenerator(io.automatiko.engine.codegen.ApplicationGenerator) IOException(java.io.IOException) Field(java.lang.reflect.Field) File(java.io.File) Consumer(java.util.function.Consumer) DecisionCodegen(io.automatiko.engine.codegen.decision.DecisionCodegen) ApplicationArchive(io.quarkus.deployment.ApplicationArchive) StandardJavaFileManager(javax.tools.StandardJavaFileManager) BootstrapDependencyProcessingException(io.quarkus.bootstrap.BootstrapDependencyProcessingException) AdditionalIndexedClassesBuildItem(io.quarkus.deployment.builditem.AdditionalIndexedClassesBuildItem) Paths(java.nio.file.Paths) LaunchModeBuildItem(io.quarkus.deployment.builditem.LaunchModeBuildItem) AutomatikoBuildTimeConfig(io.automatiko.engine.quarkus.AutomatikoBuildTimeConfig) Collections(java.util.Collections) AutomatikoConfigProperties(io.automatiko.engine.api.codegen.AutomatikoConfigProperties) LiveReloadBuildItem(io.quarkus.deployment.builditem.LiveReloadBuildItem) QuarkusApplicationBuildContext(io.automatiko.engine.codegen.context.QuarkusApplicationBuildContext) GeneratorContext(io.automatiko.engine.codegen.GeneratorContext) DotName(org.jboss.jandex.DotName)

Aggregations

ApplicationGenerator (io.automatiko.engine.codegen.ApplicationGenerator)2 GeneratedFile (io.automatiko.engine.codegen.GeneratedFile)2 GeneratorContext (io.automatiko.engine.codegen.GeneratorContext)2 CDIDependencyInjectionAnnotator (io.automatiko.engine.codegen.di.CDIDependencyInjectionAnnotator)2 Model (io.automatiko.engine.api.Model)1 AutomatikoConfigProperties (io.automatiko.engine.api.codegen.AutomatikoConfigProperties)1 CodeGenConstants (io.automatiko.engine.codegen.CodeGenConstants)1 QuarkusApplicationBuildContext (io.automatiko.engine.codegen.context.QuarkusApplicationBuildContext)1 DecisionCodegen (io.automatiko.engine.codegen.decision.DecisionCodegen)1 ProcessCodegen (io.automatiko.engine.codegen.process.ProcessCodegen)1 PersistenceGenerator (io.automatiko.engine.codegen.process.persistence.PersistenceGenerator)1 AutomatikoBuildTimeConfig (io.automatiko.engine.quarkus.AutomatikoBuildTimeConfig)1 IoUtils (io.automatiko.engine.services.utils.IoUtils)1 BaseWorkItem (io.automatiko.engine.workflow.BaseWorkItem)1 AutomatikoMessages (io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages)1 GeneratedBeanBuildItem (io.quarkus.arc.deployment.GeneratedBeanBuildItem)1 BootstrapDependencyProcessingException (io.quarkus.bootstrap.BootstrapDependencyProcessingException)1 ClassPathElement (io.quarkus.bootstrap.classloading.ClassPathElement)1 MemoryClassPathElement (io.quarkus.bootstrap.classloading.MemoryClassPathElement)1 QuarkusClassLoader (io.quarkus.bootstrap.classloading.QuarkusClassLoader)1