yesamer commented on code in PR #3881:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/3881#discussion_r2030876357


##########
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 Yes, the point is: that seems currently unused. I was tempted to 
remove it at all, but I guess it could be useful for Gradle. If you confirm, 
I'll move it



-- 
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]

Reply via email to