-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KOGITO-3972] Make TemplateGenerator use KogitoBuildContext (#934)
* WIP * [KOGITO-3974] PredictionModels and DecisionModels are now using templates + Created AbstractPredictionModels and AbstractDecisionModels with common code * [KOGITO-3975] WIP, compile but integration broken tests * [KOGITO-3975] Fix tests * [KOGITO-3974] Revert ApplicationContainerGenerator changes and postpone ApplicationTemplate to a different PR * [KOGITO-3975] Minor * [KOGITO-3974] Fix missing conf use case * [KOGITO-3975] Fix missing conf use case * [KOGITO-3974] Fix test * [KOGITO-3974] Reviewed DecisionModels/PredictionModels templates to move all the code to abstract * [KOGITO-3974] Fix test * [KOGITO-3975] update * [KOGITO-3975] Minor * [KOGITO-3972] Updated TemplatedGenerator to use KogitoBuildContext + Now TemplatedGenerator is only used as delegator + Created AbstractConfigGenerator to simplify ConfigGenerator logic * [KOGITO-3972] Fix DMN hot reload * Fix DMN hot reload * Moved packageName, annotator and addonsConfig to AbstractGenerator + Renamed ApplicationGenerator.withGenerator as ApplicationGenerator.registerAndInitGenerator * Added comment * Fix tests * Fix after merge * Revert ApplicationGenerator.registerAndInitGenerator to ApplicationGenerator.withGenerator * WIP commit * Postponing moduleGenerator initialization when used (compilationUnit() module) + ApplicationSection.classDeclaration renamed compilationUnit to return the whole template * Minor fixes * Fix post merge * Fix AbstractConfigGenerator to handle missing templates * Minor * Created JavaKogitoBuildContext for non-DI context + Moved DependencyInjectionAnnotator reference inside KogitoBuildContext to prevent inconsistent configuration + Removed all withDependencyInjectionAnnotator (no more needed) + Created a common hasDI() method inside KogitoBuildContext and removed all custom useInjection methods * Introduced static AtomicReference in AbstractPredictionModels to make DMN+PMML integration works even if DecisionModels is loaded first + Fix native-image check * After merge fix * Minor * Fix code smell * Fix code smell * Update DMNCompilationProvider.java * Update ApplicationContainerGenerator.java * Minor changes * Minor fixes * Make TemplatedGenerator final
- Loading branch information
1 parent
2641981
commit a59a15e
Showing
78 changed files
with
760 additions
and
924 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
kogito-codegen/src/main/java/org/kie/kogito/codegen/AbstractConfigGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.kie.kogito.codegen; | ||
|
||
import com.github.javaparser.ast.CompilationUnit; | ||
import org.kie.kogito.codegen.context.KogitoBuildContext; | ||
|
||
import java.util.Optional; | ||
|
||
public class AbstractConfigGenerator { | ||
|
||
private final TemplatedGenerator templatedGenerator; | ||
|
||
public AbstractConfigGenerator(KogitoBuildContext buildContext, String packageName, String targetTypeName, String resourceCdi, String resourceSpring) { | ||
this.templatedGenerator = new TemplatedGenerator( | ||
buildContext, | ||
packageName, | ||
targetTypeName, | ||
resourceCdi, | ||
resourceSpring); | ||
} | ||
|
||
public Optional<GeneratedFile> generate() { | ||
Optional<CompilationUnit> compilationUnit = templatedGenerator.compilationUnit(); | ||
return compilationUnit.map(cu -> | ||
new GeneratedFile(GeneratedFile.Type.APPLICATION_CONFIG, | ||
templatedGenerator.generatedFilePath(), | ||
cu.toString())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.