Search in sources :

Example 81 with KogitoBuildContext

use of org.kie.kogito.codegen.api.context.KogitoBuildContext in project kogito-runtimes by kiegroup.

the class KogitoAssetsProcessorTest method validateAvailableCapabilitiesWithOptaPlannerNoRest.

@Test
public void validateAvailableCapabilitiesWithOptaPlannerNoRest() {
    KogitoBuildContext context = QuarkusKogitoBuildContext.builder().build();
    Capabilities capabilities = capabilities("org.optaplanner.optaplanner-quarkus");
    KogitoAssetsProcessor processor = new KogitoAssetsProcessor();
    assertThat(context.getApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST)).isEmpty();
    processor.validateAvailableCapabilities(context, capabilities);
    assertThat(context.getApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST)).contains("false");
}
Also used : Capabilities(io.quarkus.deployment.Capabilities) KogitoBuildContext(org.kie.kogito.codegen.api.context.KogitoBuildContext) QuarkusKogitoBuildContext(org.kie.kogito.codegen.api.context.impl.QuarkusKogitoBuildContext) Test(org.junit.jupiter.api.Test)

Example 82 with KogitoBuildContext

use of org.kie.kogito.codegen.api.context.KogitoBuildContext in project kogito-runtimes by kiegroup.

the class KogitoAssetsProcessorTest method validateAvailableCapabilitiesWithoutOptaPlanner.

@Test
public void validateAvailableCapabilitiesWithoutOptaPlanner() {
    KogitoBuildContext context = QuarkusKogitoBuildContext.builder().build();
    Capabilities capabilities = capabilities(Capability.RESTEASY, Capability.RESTEASY_JSON_JACKSON);
    KogitoAssetsProcessor processor = new KogitoAssetsProcessor();
    assertThat(context.getApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST)).isEmpty();
    processor.validateAvailableCapabilities(context, capabilities);
    assertThat(context.getApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST)).isEmpty();
}
Also used : Capabilities(io.quarkus.deployment.Capabilities) KogitoBuildContext(org.kie.kogito.codegen.api.context.KogitoBuildContext) QuarkusKogitoBuildContext(org.kie.kogito.codegen.api.context.impl.QuarkusKogitoBuildContext) Test(org.junit.jupiter.api.Test)

Example 83 with KogitoBuildContext

use of org.kie.kogito.codegen.api.context.KogitoBuildContext in project kogito-runtimes by kiegroup.

the class KogitoAssetsProcessor method generateModel.

@BuildStep
public List<KogitoGeneratedClassesBuildItem> generateModel(KogitoGeneratedSourcesBuildItem sources, List<KogitoAddonsGeneratedSourcesBuildItem> extraSources, KogitoBuildContextBuildItem contextBuildItem, BuildProducer<GeneratedBeanBuildItem> generatedBeans, BuildProducer<GeneratedJaxRsResourceBuildItem> jaxrsProducer, BuildProducer<AdditionalStaticResourceBuildItem> staticResProducer, BuildProducer<NativeImageResourceBuildItem> resource, BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<GeneratedResourceBuildItem> genResBI) throws IOException {
    final KogitoBuildContext context = contextBuildItem.getKogitoBuildContext();
    Collection<GeneratedFile> generatedFiles = collectGeneratedFiles(sources, extraSources);
    // dump files to disk
    dumpFilesToDisk(context.getAppPaths(), generatedFiles);
    // build Java source code and register the generated beans
    Optional<KogitoGeneratedClassesBuildItem> optionalIndex = compileAndIndexJavaSources(context, generatedFiles, generatedBeans, jaxrsProducer, liveReload.isLiveReload());
    registerDataEventsForReflection(optionalIndex.map(KogitoGeneratedClassesBuildItem::getIndexedClasses), context, reflectiveClass);
    registerKogitoIncubationAPI(reflectiveClass);
    registerResources(generatedFiles, staticResProducer, resource, genResBI);
    return optionalIndex.map(Collections::singletonList).orElse(Collections.emptyList());
}
Also used : KogitoBuildContext(org.kie.kogito.codegen.api.context.KogitoBuildContext) GeneratedFile(org.kie.kogito.codegen.api.GeneratedFile) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Aggregations

KogitoBuildContext (org.kie.kogito.codegen.api.context.KogitoBuildContext)83 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)53 MethodSource (org.junit.jupiter.params.provider.MethodSource)51 GeneratedFile (org.kie.kogito.codegen.api.GeneratedFile)41 Collection (java.util.Collection)20 Test (org.junit.jupiter.api.Test)19 List (java.util.List)17 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)17 QuarkusKogitoBuildContext (org.kie.kogito.codegen.api.context.impl.QuarkusKogitoBuildContext)17 ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)16 CompilationUnit (com.github.javaparser.ast.CompilationUnit)15 Collectors (java.util.stream.Collectors)14 Collections (java.util.Collections)11 Optional (java.util.Optional)11 Paths (java.nio.file.Paths)10 Path (java.nio.file.Path)9 GeneratedFileType (org.kie.kogito.codegen.api.GeneratedFileType)9 SpringBootKogitoBuildContext (org.kie.kogito.codegen.api.context.impl.SpringBootKogitoBuildContext)9 CollectedResource (org.kie.kogito.codegen.api.io.CollectedResource)9 ReflectionMarshallerGenerator (org.kie.kogito.codegen.process.persistence.marshaller.ReflectionMarshallerGenerator)8