essobedo commented on code in PR #4403:
URL: https://github.com/apache/camel-quarkus/pull/4403#discussion_r1071004448


##########
extensions/kotlin-dsl/deployment/src/main/java/org/apache/camel/quarkus/dsl/kotlin/deployment/KotlinDslProcessor.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      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.apache.camel.quarkus.dsl.kotlin.deployment;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.GeneratedClassBuildItem;
+import io.quarkus.deployment.builditem.GeneratedResourceBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.dev.CompilationProvider;
+import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
+import io.quarkus.deployment.pkg.steps.NativeBuild;
+import io.quarkus.kotlin.deployment.KotlinCompilationProvider;
+import io.quarkus.maven.dependency.ResolvedDependency;
+import io.quarkus.paths.PathCollection;
+import io.quarkus.runtime.RuntimeValue;
+import org.apache.camel.CamelContext;
+import org.apache.camel.dsl.kotlin.KotlinConstantsKt;
+import org.apache.camel.quarkus.core.deployment.main.CamelMainHelper;
+import org.apache.camel.quarkus.core.deployment.spi.CamelContextBuildItem;
+import org.apache.camel.quarkus.dsl.kotlin.runtime.Configurer;
+import org.apache.camel.quarkus.dsl.kotlin.runtime.KotlinDslRecorder;
+import org.apache.camel.spi.Resource;
+import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.IOHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class KotlinDslProcessor {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(KotlinDslProcessor.class);
+    private static final String PACKAGE_NAME = 
"org.apache.camel.quarkus.dsl.kotlin.generated";
+    private static final Pattern IMPORT_PATTERN = Pattern.compile("import .*");
+    private static final String FILE_FORMAT = "package %s\n" +
+            "%s\n" +
+            "class %s(builder: 
org.apache.camel.builder.endpoint.EndpointRouteBuilder) :\n" +
+            "  %s(builder) { \n" +
+            "  override fun configure() { \n" +
+            "    %s\n" +
+            "  }\n" +
+            "}";
+    private static final String FEATURE = "camel-kotlin-dsl";
+    public static final String CLASS_EXT = ".class";
+
+    @BuildStep
+    FeatureBuildItem feature() {
+        return new FeatureBuildItem(FEATURE);
+    }
+
+    @BuildStep(onlyIf = NativeBuild.class)
+    void compileScriptsAOT(BuildProducer<GeneratedClassBuildItem> 
generatedClass,
+            BuildProducer<GeneratedResourceBuildItem> generatedResource,
+            BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
+            BuildProducer<KotlinGeneratedClassBuildItem> generatedKotlinClass,
+            CurateOutcomeBuildItem curateOutcomeBuildItem) throws Exception {
+        LOG.debug("Loading .kts resources");
+        final Path projectDir = Paths.get(".").toAbsolutePath().normalize();
+        final Path generatedSourceDir = 
projectDir.resolve("target/kotlin-dsl/generated-sources");

Review Comment:
   Nice one, thx for sharing



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

Reply via email to