Search in sources :

Example 1 with AppPaths

use of org.kie.kogito.codegen.api.utils.AppPaths in project kogito-runtimes by kiegroup.

the class AbstractKieMojo method discoverKogitoRuntimeContext.

protected KogitoBuildContext discoverKogitoRuntimeContext(ClassLoader classLoader) {
    AppPaths appPaths = AppPaths.fromProjectDir(projectDir.toPath(), outputDirectory.toPath());
    KogitoBuildContext context = contextBuilder().withClassAvailabilityResolver(this::hasClassOnClasspath).withApplicationProperties(appPaths.getResourceFiles()).withPackageName(appPackageName()).withAddonsConfig(AddonsConfigDiscovery.discover(this::hasClassOnClasspath)).withClassLoader(classLoader).withAppPaths(appPaths).withGAV(new KogitoGAV(project.getGroupId(), project.getArtifactId(), project.getVersion())).build();
    additionalProperties(context);
    return context;
}
Also used : AppPaths(org.kie.kogito.codegen.api.utils.AppPaths) KogitoGAV(org.kie.kogito.KogitoGAV) SpringBootKogitoBuildContext(org.kie.kogito.codegen.api.context.impl.SpringBootKogitoBuildContext) KogitoBuildContext(org.kie.kogito.codegen.api.context.KogitoBuildContext) JavaKogitoBuildContext(org.kie.kogito.codegen.api.context.impl.JavaKogitoBuildContext) QuarkusKogitoBuildContext(org.kie.kogito.codegen.api.context.impl.QuarkusKogitoBuildContext)

Example 2 with AppPaths

use of org.kie.kogito.codegen.api.utils.AppPaths in project kogito-runtimes by kiegroup.

the class KogitoQuarkusResourceUtils method kogitoBuildContext.

public static KogitoBuildContext kogitoBuildContext(Path outputTarget, Iterable<Path> paths, IndexView index, Dependency appArtifact) {
    // scan and parse paths
    AppPaths.BuildTool buildTool;
    if (System.getProperty("org.gradle.appname") == null) {
        buildTool = AppPaths.BuildTool.MAVEN;
    } else {
        buildTool = AppPaths.BuildTool.GRADLE;
    }
    AppPaths appPaths = AppPaths.fromQuarkus(outputTarget, paths, buildTool);
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    KogitoBuildContext context = QuarkusKogitoBuildContext.builder().withApplicationPropertyProvider(new KogitoQuarkusApplicationPropertiesProvider()).withClassLoader(classLoader).withClassAvailabilityResolver(className -> classAvailabilityResolver(classLoader, index, className)).withAppPaths(appPaths).withGAV(new KogitoGAV(appArtifact.getGroupId(), appArtifact.getArtifactId(), appArtifact.getVersion())).build();
    if (!context.hasClassAvailable(QuarkusKogitoBuildContext.QUARKUS_REST)) {
        LOGGER.info("Disabling REST generation because class '" + QuarkusKogitoBuildContext.QUARKUS_REST + "' is not available");
        context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST, "false");
    }
    if (!context.hasClassAvailable(QuarkusKogitoBuildContext.QUARKUS_DI)) {
        LOGGER.info("Disabling dependency injection generation because class '" + QuarkusKogitoBuildContext.QUARKUS_DI + "' is not available");
        context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_DI, "false");
    }
    return context;
}
Also used : KiePath(org.kie.memorycompiler.resources.KiePath) DotName(org.jboss.jandex.DotName) LoggerFactory(org.slf4j.LoggerFactory) AdditionalStaticResourceBuildItem(io.quarkus.vertx.http.deployment.spi.AdditionalStaticResourceBuildItem) GeneratedFileWriter(org.kie.kogito.codegen.core.utils.GeneratedFileWriter) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) ArrayList(java.util.ArrayList) GeneratedBeanBuildItem(io.quarkus.arc.deployment.GeneratedBeanBuildItem) CompositeIndex(org.jboss.jandex.CompositeIndex) AppPaths(org.kie.kogito.codegen.api.utils.AppPaths) Dependency(io.quarkus.maven.dependency.Dependency) ResourceReader(org.kie.memorycompiler.resources.ResourceReader) Path(java.nio.file.Path) IndexView(org.jboss.jandex.IndexView) GeneratedResourceBuildItem(io.quarkus.deployment.builditem.GeneratedResourceBuildItem) KogitoBuildContext(org.kie.kogito.codegen.api.context.KogitoBuildContext) Logger(org.slf4j.Logger) GeneratedFileType(org.kie.kogito.codegen.api.GeneratedFileType) Files(java.nio.file.Files) Collection(java.util.Collection) NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) IOException(java.io.IOException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) KogitoGAV(org.kie.kogito.KogitoGAV) QuarkusKogitoBuildContext(org.kie.kogito.codegen.api.context.impl.QuarkusKogitoBuildContext) Paths(java.nio.file.Paths) ResolvedDependency(io.quarkus.maven.dependency.ResolvedDependency) GeneratedFile(org.kie.kogito.codegen.api.GeneratedFile) Collections(java.util.Collections) AppPaths(org.kie.kogito.codegen.api.utils.AppPaths) KogitoGAV(org.kie.kogito.KogitoGAV) KogitoBuildContext(org.kie.kogito.codegen.api.context.KogitoBuildContext) QuarkusKogitoBuildContext(org.kie.kogito.codegen.api.context.impl.QuarkusKogitoBuildContext)

Aggregations

KogitoGAV (org.kie.kogito.KogitoGAV)2 KogitoBuildContext (org.kie.kogito.codegen.api.context.KogitoBuildContext)2 QuarkusKogitoBuildContext (org.kie.kogito.codegen.api.context.impl.QuarkusKogitoBuildContext)2 AppPaths (org.kie.kogito.codegen.api.utils.AppPaths)2 GeneratedBeanBuildItem (io.quarkus.arc.deployment.GeneratedBeanBuildItem)1 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)1 GeneratedResourceBuildItem (io.quarkus.deployment.builditem.GeneratedResourceBuildItem)1 NativeImageResourceBuildItem (io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem)1 Dependency (io.quarkus.maven.dependency.Dependency)1 ResolvedDependency (io.quarkus.maven.dependency.ResolvedDependency)1 AdditionalStaticResourceBuildItem (io.quarkus.vertx.http.deployment.spi.AdditionalStaticResourceBuildItem)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 UUID (java.util.UUID)1