yesamer commented on code in PR #3881:
URL:
https://github.com/apache/incubator-kie-kogito-runtimes/pull/3881#discussion_r2031240509
##########
kogito-maven-plugin/src/main/java/org/kie/kogito/maven/plugin/AbstractKieMojo.java:
##########
@@ -153,127 +86,29 @@ protected ClassLoader projectClassLoader() throws
MojoExecutionException {
null);
}
- protected String appPackageName() {
- return DroolsModelBuildContext.DEFAULT_PACKAGE_NAME;
- }
-
- private void additionalProperties(KogitoBuildContext context) {
-
- classToCheckForREST().ifPresent(restClass -> {
- if (!context.hasClassAvailable(restClass)) {
- getLog().info("Disabling REST generation because class '" +
restClass + "' is not available");
-
context.setApplicationProperty(DroolsModelBuildContext.KOGITO_GENERATE_REST,
"false");
- }
- });
- classToCheckForDI().ifPresent(diClass -> {
- if (!context.hasClassAvailable(diClass)) {
- getLog().info("Disabling dependency injection generation
because class '" + diClass + "' is not available");
-
context.setApplicationProperty(DroolsModelBuildContext.KOGITO_GENERATE_DI,
"false");
- }
- });
-
- overwritePropertiesIfNeeded(context);
- }
-
- void overwritePropertiesIfNeeded(KogitoBuildContext context) {
- overwritePropertyIfNeeded(context, RuleCodegen.GENERATOR_NAME,
generateRules);
- overwritePropertyIfNeeded(context, ProcessCodegen.GENERATOR_NAME,
generateProcesses);
- overwritePropertyIfNeeded(context, PredictionCodegen.GENERATOR_NAME,
generatePredictions);
- overwritePropertyIfNeeded(context, DecisionCodegen.GENERATOR_NAME,
generateDecisions);
- overwritePropertyIfNeeded(context,
PersistenceGenerator.GENERATOR_NAME, Boolean.toString(persistence));
- }
-
- static void overwritePropertyIfNeeded(KogitoBuildContext context, String
generatorName, String propertyValue) {
- if (propertyValue != null && !propertyValue.isEmpty()) {
- context.setApplicationProperty(Generator.CONFIG_PREFIX +
generatorName, propertyValue);
- }
- }
-
- private KogitoBuildContext.Builder contextBuilder() {
- switch (discoverFramework()) {
- case QUARKUS:
- return QuarkusKogitoBuildContext.builder();
- case SPRING:
- return SpringBootKogitoBuildContext.builder();
- default:
- return JavaKogitoBuildContext.builder();
- }
- }
-
- private Optional<String> classToCheckForREST() {
- switch (discoverFramework()) {
- case QUARKUS:
- return Optional.of(QuarkusKogitoBuildContext.QUARKUS_REST);
- case SPRING:
- return Optional.of(SpringBootKogitoBuildContext.SPRING_REST);
- default:
- return Optional.empty();
- }
- }
-
- private Optional<String> classToCheckForDI() {
- switch (discoverFramework()) {
- case QUARKUS:
- return Optional.of(QuarkusKogitoBuildContext.QUARKUS_DI);
- case SPRING:
- return Optional.of(SpringBootKogitoBuildContext.SPRING_DI);
- default:
- return Optional.empty();
- }
- }
-
- private enum Framework {
- QUARKUS,
- SPRING,
- NONE
- }
-
- private Framework discoverFramework() {
+ protected CodeGenManagerUtil.Framework discoverFramework() {
if (hasDependency("quarkus")) {
- return Framework.QUARKUS;
+ return CodeGenManagerUtil.Framework.QUARKUS;
}
if (hasDependency("spring")) {
- return Framework.SPRING;
+ return CodeGenManagerUtil.Framework.SPRING;
}
- return Framework.NONE;
+ return CodeGenManagerUtil.Framework.NONE;
}
private boolean hasDependency(String dependency) {
return project.getDependencies().stream().anyMatch(d ->
d.getArtifactId().contains(dependency));
}
- private boolean hasClassOnClasspath(String className) {
- try {
- Set<Artifact> elements = project.getArtifacts();
- URL[] urls = new URL[elements.size()];
-
- int i = 0;
- Iterator<Artifact> it = elements.iterator();
- while (it.hasNext()) {
- Artifact artifact = it.next();
-
- urls[i] = artifact.getFile().toURI().toURL();
- i++;
- }
- try (URLClassLoader cl = new URLClassLoader(urls)) {
- cl.loadClass(className);
- }
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
protected File getSourcesPath() {
// using runtime BT instead of static AppPaths.MAVEN to allow
// invocation from GRADLE
return Path.of(baseDir.getAbsolutePath(),
AppPaths.BT.GENERATED_SOURCES_PATH.toString()).toFile();
Review Comment:
@gitgabrio I removed it. I'll restore the ScaffoldMojo and the related
changes we agreed on in the subsequent PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]