You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "Croway (via GitHub)" <gi...@apache.org> on 2023/03/06 15:48:40 UTC

[GitHub] [camel] Croway opened a new pull request, #9470: CAMEL-19120: Export configurable template

Croway opened a new pull request, #9470:
URL: https://github.com/apache/camel/pull/9470

   # Description
   
   <!--
   - Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   -->
   
   # Target
   
   - [ ] I checked that the commit is targeting the correct branch (note that Camel 3 uses `camel-3.x`, whereas Camel 4 uses the `main` branch)
   
   # Tracking
   - [ ] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).
   
   <!--
   # *Note*: trivial changes like, typos, minor documentation fixes and other small items do not require a JIRA issue. In this case your pull request should address just this issue, without pulling in other changes.
   -->
   
   # Apache Camel coding standards and style
   
   - [ ] I checked that each commit in the pull request has a meaningful subject line and body.
   
   <!--  
   If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   -->
   
   - [ ] I formatted the code using `mvn -Pformat,fastinstall install && mvn -Psourcecheck`
   
   <!-- 
   You can run the aforementioned command in your module so that the build auto-formats your code and the source check verifies that is complies with our coding style. This will also be verified as part of the checks and your PR may be rejected if the checkstyle does not pass.
   
   You can learn more about the contribution guidelines at https://github.com/apache/camel/blob/main/CONTRIBUTING.md
   -->
   
   


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] Croway merged pull request #9470: CAMEL-19120: Export configurable template

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway merged PR #9470:
URL: https://github.com/apache/camel/pull/9470


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] github-actions[bot] commented on pull request #9470: CAMEL-19120: Export configurable template

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #9470:
URL: https://github.com/apache/camel/pull/9470#issuecomment-1456860515

   :no_entry_sign: There are (likely) no components to be tested in this 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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] github-actions[bot] commented on pull request #9470: CAMEL-19120: Export configurable template

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #9470:
URL: https://github.com/apache/camel/pull/9470#issuecomment-1457804487

   ### Components tested:
   
   | Total | Tested | Failed :x: | Passed :white_check_mark: | 
   | --- | --- | --- |  --- |
   | 1 | 1 | 0 | 1 |


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] github-actions[bot] commented on pull request #9470: CAMEL-19120: Export configurable template

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #9470:
URL: https://github.com/apache/camel/pull/9470#issuecomment-1456503200

   :no_entry_sign: There are (likely) no components to be tested in this 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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] github-actions[bot] commented on pull request #9470: CAMEL-19120: Export configurable template

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #9470:
URL: https://github.com/apache/camel/pull/9470#issuecomment-1456468776

   :no_entry_sign: There are (likely) no components to be tested in this 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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] davsclaus commented on a diff in pull request #9470: CAMEL-19120: Export configurable template

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #9470:
URL: https://github.com/apache/camel/pull/9470#discussion_r1126972504


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java:
##########
@@ -137,13 +139,23 @@ private void createSettingsGradle(File file) throws Exception {
     private void createMavenPom(File settings, File profile, File pom, Set<String> deps) throws Exception {
         String[] ids = gav.split(":");
 
-        String context = readResourceTemplate("templates/spring-boot-pom.tmpl");
-
         Properties prop = new CamelCaseOrderedProperties();
         RuntimeUtil.loadProperties(prop, settings);
         String repos = getMavenRepos(settings, prop, camelSpringBootVersion);
 
         CamelCatalog catalog = CatalogLoader.loadSpringBootCatalog(repos, camelSpringBootVersion);
+
+        // First try to load a specialized template from the catalog, if the catalog does not provide it
+        // fallback to the template defined in camel-jbang-core
+        String context;
+        InputStream template = catalog.loadResource("camel-jbang", "spring-boot-pom.tmpl");
+        if (template != null) {
+            context = IOHelper.loadText(template);
+            IOHelper.close(template);

Review Comment:
   IOHelper automatic close, so no need for this



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] davsclaus commented on a diff in pull request #9470: CAMEL-19120: Export configurable template

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #9470:
URL: https://github.com/apache/camel/pull/9470#discussion_r1126654824


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java:
##########
@@ -137,6 +137,9 @@ abstract class ExportBaseCommand extends CamelCommand {
                         description = "Will be quiet, only print when error occurs")
     boolean quiet;
 
+    @CommandLine.Option(names = { "--additional-properties" }, description = "Additional maven properties, ex. --properties=prop1=foo,prop2=bar")

Review Comment:
   I think the text should be `--additional-properties` in the example



##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java:
##########
@@ -137,13 +139,20 @@ private void createSettingsGradle(File file) throws Exception {
     private void createMavenPom(File settings, File profile, File pom, Set<String> deps) throws Exception {
         String[] ids = gav.split(":");
 
-        String context = readResourceTemplate("templates/spring-boot-pom.tmpl");
-
         Properties prop = new CamelCaseOrderedProperties();
         RuntimeUtil.loadProperties(prop, settings);
         String repos = getMavenRepos(settings, prop, camelSpringBootVersion);
 
         CamelCatalog catalog = CatalogLoader.loadSpringBootCatalog(repos, camelSpringBootVersion);
+
+        String context;
+        InputStream template = catalog.loadResource("camel-jbang", "spring-boot-pom.tmpl");
+        if (template != null) {
+            context = new String(template.readAllBytes(), StandardCharsets.UTF_8);

Review Comment:
   Can you try using
   
   String text = IOHelper.loadText(fis);
   
   We do this in the other commands



##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java:
##########
@@ -137,13 +139,20 @@ private void createSettingsGradle(File file) throws Exception {
     private void createMavenPom(File settings, File profile, File pom, Set<String> deps) throws Exception {
         String[] ids = gav.split(":");
 
-        String context = readResourceTemplate("templates/spring-boot-pom.tmpl");
-
         Properties prop = new CamelCaseOrderedProperties();
         RuntimeUtil.loadProperties(prop, settings);
         String repos = getMavenRepos(settings, prop, camelSpringBootVersion);
 
         CamelCatalog catalog = CatalogLoader.loadSpringBootCatalog(repos, camelSpringBootVersion);
+
+        String context;

Review Comment:
   Can you add a code comment that we look in the catalog if there is a specialized template to use, if not we use the default template



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] Croway commented on a diff in pull request #9470: CAMEL-19120: Export configurable template

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on code in PR #9470:
URL: https://github.com/apache/camel/pull/9470#discussion_r1126681894


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java:
##########
@@ -137,13 +139,20 @@ private void createSettingsGradle(File file) throws Exception {
     private void createMavenPom(File settings, File profile, File pom, Set<String> deps) throws Exception {
         String[] ids = gav.split(":");
 
-        String context = readResourceTemplate("templates/spring-boot-pom.tmpl");
-
         Properties prop = new CamelCaseOrderedProperties();
         RuntimeUtil.loadProperties(prop, settings);
         String repos = getMavenRepos(settings, prop, camelSpringBootVersion);
 
         CamelCatalog catalog = CatalogLoader.loadSpringBootCatalog(repos, camelSpringBootVersion);
+
+        String context;
+        InputStream template = catalog.loadResource("camel-jbang", "spring-boot-pom.tmpl");
+        if (template != null) {
+            context = new String(template.readAllBytes(), StandardCharsets.UTF_8);

Review Comment:
   Sure, no problem, any particular reason? `readAllBytes()` is available since java9..  probably this is the reason



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] davsclaus commented on a diff in pull request #9470: CAMEL-19120: Export configurable template

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #9470:
URL: https://github.com/apache/camel/pull/9470#discussion_r1126706013


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java:
##########
@@ -137,13 +139,20 @@ private void createSettingsGradle(File file) throws Exception {
     private void createMavenPom(File settings, File profile, File pom, Set<String> deps) throws Exception {
         String[] ids = gav.split(":");
 
-        String context = readResourceTemplate("templates/spring-boot-pom.tmpl");
-
         Properties prop = new CamelCaseOrderedProperties();
         RuntimeUtil.loadProperties(prop, settings);
         String repos = getMavenRepos(settings, prop, camelSpringBootVersion);
 
         CamelCatalog catalog = CatalogLoader.loadSpringBootCatalog(repos, camelSpringBootVersion);
+
+        String context;
+        InputStream template = catalog.loadResource("camel-jbang", "spring-boot-pom.tmpl");
+        if (template != null) {
+            context = new String(template.readAllBytes(), StandardCharsets.UTF_8);

Review Comment:
   So we use the same util code



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org