Re: [PR] Refactor camel jbang dependency list to not depend on the export command [camel]

2024-02-15 Thread via GitHub


claudio4j commented on PR #13134:
URL: https://github.com/apache/camel/pull/13134#issuecomment-1946388293

   This proposal was mostly driven by having the dependency list we are going 
to need in `camel-k run` command, so I thought why not have this in the 
`dependency list` itself instead of camel-k, but I failed to look for the 
impact on the copy and update sub-commands. I will close this PR and will 
update only the camel-k run sub-command. Sorry for the noise.


-- 
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-unsubscr...@camel.apache.org

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



Re: [PR] Refactor camel jbang dependency list to not depend on the export command [camel]

2024-02-15 Thread via GitHub


claudio4j closed pull request #13134: Refactor camel jbang dependency list to 
not depend on the export command
URL: https://github.com/apache/camel/pull/13134


-- 
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-unsubscr...@camel.apache.org

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



Re: [PR] Refactor camel jbang dependency list to not depend on the export command [camel]

2024-02-15 Thread via GitHub


claudio4j commented on PR #13134:
URL: https://github.com/apache/camel/pull/13134#issuecomment-1946333918

   > And the dependency copy command still works after this change ?
   
   Sorry, no. I will put the PR in draft and work on the the copy and update 
subcommands.


-- 
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-unsubscr...@camel.apache.org

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



Re: [PR] Refactor camel jbang dependency list to not depend on the export command [camel]

2024-02-15 Thread via GitHub


davsclaus commented on PR #13134:
URL: https://github.com/apache/camel/pull/13134#issuecomment-1946303057

   And the dependency copy command still works after this change ?


-- 
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-unsubscr...@camel.apache.org

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



Re: [PR] Refactor camel jbang dependency list to not depend on the export command [camel]

2024-02-15 Thread via GitHub


claudio4j commented on code in PR #13134:
URL: https://github.com/apache/camel/pull/13134#discussion_r1491136542


##
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java:
##
@@ -16,146 +16,89 @@
  */
 package org.apache.camel.dsl.jbang.core.commands;
 
-import java.io.File;
+import java.nio.file.Path;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
-import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
-import org.apache.camel.dsl.jbang.core.common.RuntimeUtil;
-import org.apache.camel.dsl.jbang.core.common.XmlHelper;
+import org.apache.camel.dsl.jbang.core.common.MavenGavComparator;
+import org.apache.camel.main.KameletMain;
+import org.apache.camel.main.download.DownloadListener;
 import org.apache.camel.tooling.maven.MavenGav;
-import org.apache.camel.util.CamelCaseOrderedProperties;
-import org.apache.camel.util.FileUtil;
 import picocli.CommandLine;
 
-@CommandLine.Command(name = "list",
- description = "Displays all Camel dependencies required 
to run")
-public class DependencyList extends Export {
+@CommandLine.Command(name = "list", description = "Displays all Camel 
dependencies required to run")
+public class DependencyList extends CamelCommand {
+
+// ignored list of dependencies, can be either groupId or artifactId
+private static final String[] SKIP_DEPS = new String[] {
+"org.fusesource.jansi", "org.apache.logging.log4j", 
"camel-core-languages", "camel-endpointdsl",
+"camel-java-joor-dsl" };

Review Comment:
   I removed the `camel-*` artifacts from the ignored list.



-- 
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-unsubscr...@camel.apache.org

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



Re: [PR] Refactor camel jbang dependency list to not depend on the export command [camel]

2024-02-15 Thread via GitHub


claudio4j commented on code in PR #13134:
URL: https://github.com/apache/camel/pull/13134#discussion_r1491130646


##
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java:
##
@@ -16,146 +16,89 @@
  */
 package org.apache.camel.dsl.jbang.core.commands;
 
-import java.io.File;
+import java.nio.file.Path;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
-import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
-import org.apache.camel.dsl.jbang.core.common.RuntimeUtil;
-import org.apache.camel.dsl.jbang.core.common.XmlHelper;
+import org.apache.camel.dsl.jbang.core.common.MavenGavComparator;
+import org.apache.camel.main.KameletMain;
+import org.apache.camel.main.download.DownloadListener;
 import org.apache.camel.tooling.maven.MavenGav;
-import org.apache.camel.util.CamelCaseOrderedProperties;
-import org.apache.camel.util.FileUtil;
 import picocli.CommandLine;
 
-@CommandLine.Command(name = "list",
- description = "Displays all Camel dependencies required 
to run")
-public class DependencyList extends Export {
+@CommandLine.Command(name = "list", description = "Displays all Camel 
dependencies required to run")
+public class DependencyList extends CamelCommand {
+
+// ignored list of dependencies, can be either groupId or artifactId
+private static final String[] SKIP_DEPS = new String[] {
+"org.fusesource.jansi", "org.apache.logging.log4j", 
"camel-core-languages", "camel-endpointdsl",
+"camel-java-joor-dsl" };
 
-protected static final String EXPORT_DIR = 
CommandLineHelper.CAMEL_JBANG_WORK_DIR + "/export";
+@CommandLine.Parameters(description = "The Camel file(s) to inspect for 
dependencies.", arity = "0..9",
+paramLabel = "")
+protected Path[] filePaths;
 
 @CommandLine.Option(names = { "--output" }, description = "Output format 
(gav, maven, jbang)", defaultValue = "gav")
 protected String output;
 
+@CommandLine.Option(names = { "-v" }, description = "Print additional 
verbose output.")
+protected boolean verbose = false;
+
+private Set dependencies;
+
 public DependencyList(CamelJBangMain main) {
 super(main);
+Arrays.sort(SKIP_DEPS);
 }
 
 @Override
 public Integer doCall() throws Exception {
-this.quiet = true; // be quiet and generate from fresh data to ensure 
the output is up-to-date
-return super.doCall();
-}
-
-@Override
-protected Integer export() throws Exception {
 if (!"gav".equals(output) && !"maven".equals(output) && 
!"jbang".equals(output)) {
-System.err.println("--output must be either gav or maven, was: " + 
output);
+System.err.println("--output must be either gav, maven or jbang, 
was: " + output);
 return 1;
 }
+calculate();
+return 0;
+}
 
-Integer answer = doExport();
-if (answer == 0) {
-// read pom.xml
-File pom = new File(EXPORT_DIR, "pom.xml");
-if (pom.exists()) {
-DocumentBuilderFactory dbf = 
XmlHelper.createDocumentBuilderFactory();
-DocumentBuilder db = dbf.newDocumentBuilder();
-Document dom = db.parse(pom);
-NodeList nl = dom.getElementsByTagName("dependency");
-List gavs = new ArrayList<>();
-String camelVersion = null;
-String springBootVersion = null;
-String quarkusVersion = null;
-for (int i = 0; i < nl.getLength(); i++) {
-Element node = (Element) nl.item(i);
-String g = 
node.getElementsByTagName("groupId").item(0).getTextContent();
-String a = 
node.getElementsByTagName("artifactId").item(0).getTextContent();
-String v = null;
-NodeList vl = node.getElementsByTagName("version");
-if (vl.getLength() > 0) {
-v = vl.item(0).getTextContent();
-}
-
-// BOMs
-if ("org.apache.camel".equals(g) && "camel-bom".equals(a)) 
{
-camelVersion = v;
-continue;
-}
-if ("org.apache.camel.springboot".equals(g) && 
"camel-spring-boot-bom".equals(a)) {
-camelVersion = v;
-continue;
-}
-if ("org.springframework.boot".equals(g) && 
"spring-boot-dependencies".equals(a)) {
-

Re: [PR] Refactor camel jbang dependency list to not depend on the export command [camel]

2024-02-15 Thread via GitHub


apupier commented on code in PR #13134:
URL: https://github.com/apache/camel/pull/13134#discussion_r1491109580


##
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java:
##
@@ -16,146 +16,89 @@
  */
 package org.apache.camel.dsl.jbang.core.commands;
 
-import java.io.File;
+import java.nio.file.Path;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
-import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
-import org.apache.camel.dsl.jbang.core.common.RuntimeUtil;
-import org.apache.camel.dsl.jbang.core.common.XmlHelper;
+import org.apache.camel.dsl.jbang.core.common.MavenGavComparator;
+import org.apache.camel.main.KameletMain;
+import org.apache.camel.main.download.DownloadListener;
 import org.apache.camel.tooling.maven.MavenGav;
-import org.apache.camel.util.CamelCaseOrderedProperties;
-import org.apache.camel.util.FileUtil;
 import picocli.CommandLine;
 
-@CommandLine.Command(name = "list",
- description = "Displays all Camel dependencies required 
to run")
-public class DependencyList extends Export {
+@CommandLine.Command(name = "list", description = "Displays all Camel 
dependencies required to run")
+public class DependencyList extends CamelCommand {
+
+// ignored list of dependencies, can be either groupId or artifactId
+private static final String[] SKIP_DEPS = new String[] {
+"org.fusesource.jansi", "org.apache.logging.log4j", 
"camel-core-languages", "camel-endpointdsl",
+"camel-java-joor-dsl" };
 
-protected static final String EXPORT_DIR = 
CommandLineHelper.CAMEL_JBANG_WORK_DIR + "/export";
+@CommandLine.Parameters(description = "The Camel file(s) to inspect for 
dependencies.", arity = "0..9",
+paramLabel = "")
+protected Path[] filePaths;
 
 @CommandLine.Option(names = { "--output" }, description = "Output format 
(gav, maven, jbang)", defaultValue = "gav")
 protected String output;
 
+@CommandLine.Option(names = { "-v" }, description = "Print additional 
verbose output.")
+protected boolean verbose = false;
+
+private Set dependencies;
+
 public DependencyList(CamelJBangMain main) {
 super(main);
+Arrays.sort(SKIP_DEPS);
 }
 
 @Override
 public Integer doCall() throws Exception {
-this.quiet = true; // be quiet and generate from fresh data to ensure 
the output is up-to-date
-return super.doCall();
-}
-
-@Override
-protected Integer export() throws Exception {
 if (!"gav".equals(output) && !"maven".equals(output) && 
!"jbang".equals(output)) {
-System.err.println("--output must be either gav or maven, was: " + 
output);
+System.err.println("--output must be either gav, maven or jbang, 
was: " + output);
 return 1;
 }
+calculate();
+return 0;
+}
 
-Integer answer = doExport();
-if (answer == 0) {
-// read pom.xml
-File pom = new File(EXPORT_DIR, "pom.xml");
-if (pom.exists()) {
-DocumentBuilderFactory dbf = 
XmlHelper.createDocumentBuilderFactory();
-DocumentBuilder db = dbf.newDocumentBuilder();
-Document dom = db.parse(pom);
-NodeList nl = dom.getElementsByTagName("dependency");
-List gavs = new ArrayList<>();
-String camelVersion = null;
-String springBootVersion = null;
-String quarkusVersion = null;
-for (int i = 0; i < nl.getLength(); i++) {
-Element node = (Element) nl.item(i);
-String g = 
node.getElementsByTagName("groupId").item(0).getTextContent();
-String a = 
node.getElementsByTagName("artifactId").item(0).getTextContent();
-String v = null;
-NodeList vl = node.getElementsByTagName("version");
-if (vl.getLength() > 0) {
-v = vl.item(0).getTextContent();
-}
-
-// BOMs
-if ("org.apache.camel".equals(g) && "camel-bom".equals(a)) 
{
-camelVersion = v;
-continue;
-}
-if ("org.apache.camel.springboot".equals(g) && 
"camel-spring-boot-bom".equals(a)) {
-camelVersion = v;
-continue;
-}
-if ("org.springframework.boot".equals(g) && 
"spring-boot-dependencies".equals(a)) {
-

Re: [PR] Refactor camel jbang dependency list to not depend on the export command [camel]

2024-02-15 Thread via GitHub


apupier commented on code in PR #13134:
URL: https://github.com/apache/camel/pull/13134#discussion_r1491109580


##
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java:
##
@@ -16,146 +16,89 @@
  */
 package org.apache.camel.dsl.jbang.core.commands;
 
-import java.io.File;
+import java.nio.file.Path;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
-import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
-import org.apache.camel.dsl.jbang.core.common.RuntimeUtil;
-import org.apache.camel.dsl.jbang.core.common.XmlHelper;
+import org.apache.camel.dsl.jbang.core.common.MavenGavComparator;
+import org.apache.camel.main.KameletMain;
+import org.apache.camel.main.download.DownloadListener;
 import org.apache.camel.tooling.maven.MavenGav;
-import org.apache.camel.util.CamelCaseOrderedProperties;
-import org.apache.camel.util.FileUtil;
 import picocli.CommandLine;
 
-@CommandLine.Command(name = "list",
- description = "Displays all Camel dependencies required 
to run")
-public class DependencyList extends Export {
+@CommandLine.Command(name = "list", description = "Displays all Camel 
dependencies required to run")
+public class DependencyList extends CamelCommand {
+
+// ignored list of dependencies, can be either groupId or artifactId
+private static final String[] SKIP_DEPS = new String[] {
+"org.fusesource.jansi", "org.apache.logging.log4j", 
"camel-core-languages", "camel-endpointdsl",
+"camel-java-joor-dsl" };
 
-protected static final String EXPORT_DIR = 
CommandLineHelper.CAMEL_JBANG_WORK_DIR + "/export";
+@CommandLine.Parameters(description = "The Camel file(s) to inspect for 
dependencies.", arity = "0..9",
+paramLabel = "")
+protected Path[] filePaths;
 
 @CommandLine.Option(names = { "--output" }, description = "Output format 
(gav, maven, jbang)", defaultValue = "gav")
 protected String output;
 
+@CommandLine.Option(names = { "-v" }, description = "Print additional 
verbose output.")
+protected boolean verbose = false;
+
+private Set dependencies;
+
 public DependencyList(CamelJBangMain main) {
 super(main);
+Arrays.sort(SKIP_DEPS);
 }
 
 @Override
 public Integer doCall() throws Exception {
-this.quiet = true; // be quiet and generate from fresh data to ensure 
the output is up-to-date
-return super.doCall();
-}
-
-@Override
-protected Integer export() throws Exception {
 if (!"gav".equals(output) && !"maven".equals(output) && 
!"jbang".equals(output)) {
-System.err.println("--output must be either gav or maven, was: " + 
output);
+System.err.println("--output must be either gav, maven or jbang, 
was: " + output);
 return 1;
 }
+calculate();
+return 0;
+}
 
-Integer answer = doExport();
-if (answer == 0) {
-// read pom.xml
-File pom = new File(EXPORT_DIR, "pom.xml");
-if (pom.exists()) {
-DocumentBuilderFactory dbf = 
XmlHelper.createDocumentBuilderFactory();
-DocumentBuilder db = dbf.newDocumentBuilder();
-Document dom = db.parse(pom);
-NodeList nl = dom.getElementsByTagName("dependency");
-List gavs = new ArrayList<>();
-String camelVersion = null;
-String springBootVersion = null;
-String quarkusVersion = null;
-for (int i = 0; i < nl.getLength(); i++) {
-Element node = (Element) nl.item(i);
-String g = 
node.getElementsByTagName("groupId").item(0).getTextContent();
-String a = 
node.getElementsByTagName("artifactId").item(0).getTextContent();
-String v = null;
-NodeList vl = node.getElementsByTagName("version");
-if (vl.getLength() > 0) {
-v = vl.item(0).getTextContent();
-}
-
-// BOMs
-if ("org.apache.camel".equals(g) && "camel-bom".equals(a)) 
{
-camelVersion = v;
-continue;
-}
-if ("org.apache.camel.springboot".equals(g) && 
"camel-spring-boot-bom".equals(a)) {
-camelVersion = v;
-continue;
-}
-if ("org.springframework.boot".equals(g) && 
"spring-boot-dependencies".equals(a)) {
-

Re: [PR] Refactor camel jbang dependency list to not depend on the export command [camel]

2024-02-15 Thread via GitHub


apupier commented on code in PR #13134:
URL: https://github.com/apache/camel/pull/13134#discussion_r1491109580


##
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java:
##
@@ -16,146 +16,89 @@
  */
 package org.apache.camel.dsl.jbang.core.commands;
 
-import java.io.File;
+import java.nio.file.Path;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
-import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
-import org.apache.camel.dsl.jbang.core.common.RuntimeUtil;
-import org.apache.camel.dsl.jbang.core.common.XmlHelper;
+import org.apache.camel.dsl.jbang.core.common.MavenGavComparator;
+import org.apache.camel.main.KameletMain;
+import org.apache.camel.main.download.DownloadListener;
 import org.apache.camel.tooling.maven.MavenGav;
-import org.apache.camel.util.CamelCaseOrderedProperties;
-import org.apache.camel.util.FileUtil;
 import picocli.CommandLine;
 
-@CommandLine.Command(name = "list",
- description = "Displays all Camel dependencies required 
to run")
-public class DependencyList extends Export {
+@CommandLine.Command(name = "list", description = "Displays all Camel 
dependencies required to run")
+public class DependencyList extends CamelCommand {
+
+// ignored list of dependencies, can be either groupId or artifactId
+private static final String[] SKIP_DEPS = new String[] {
+"org.fusesource.jansi", "org.apache.logging.log4j", 
"camel-core-languages", "camel-endpointdsl",
+"camel-java-joor-dsl" };
 
-protected static final String EXPORT_DIR = 
CommandLineHelper.CAMEL_JBANG_WORK_DIR + "/export";
+@CommandLine.Parameters(description = "The Camel file(s) to inspect for 
dependencies.", arity = "0..9",
+paramLabel = "")
+protected Path[] filePaths;
 
 @CommandLine.Option(names = { "--output" }, description = "Output format 
(gav, maven, jbang)", defaultValue = "gav")
 protected String output;
 
+@CommandLine.Option(names = { "-v" }, description = "Print additional 
verbose output.")
+protected boolean verbose = false;
+
+private Set dependencies;
+
 public DependencyList(CamelJBangMain main) {
 super(main);
+Arrays.sort(SKIP_DEPS);
 }
 
 @Override
 public Integer doCall() throws Exception {
-this.quiet = true; // be quiet and generate from fresh data to ensure 
the output is up-to-date
-return super.doCall();
-}
-
-@Override
-protected Integer export() throws Exception {
 if (!"gav".equals(output) && !"maven".equals(output) && 
!"jbang".equals(output)) {
-System.err.println("--output must be either gav or maven, was: " + 
output);
+System.err.println("--output must be either gav, maven or jbang, 
was: " + output);
 return 1;
 }
+calculate();
+return 0;
+}
 
-Integer answer = doExport();
-if (answer == 0) {
-// read pom.xml
-File pom = new File(EXPORT_DIR, "pom.xml");
-if (pom.exists()) {
-DocumentBuilderFactory dbf = 
XmlHelper.createDocumentBuilderFactory();
-DocumentBuilder db = dbf.newDocumentBuilder();
-Document dom = db.parse(pom);
-NodeList nl = dom.getElementsByTagName("dependency");
-List gavs = new ArrayList<>();
-String camelVersion = null;
-String springBootVersion = null;
-String quarkusVersion = null;
-for (int i = 0; i < nl.getLength(); i++) {
-Element node = (Element) nl.item(i);
-String g = 
node.getElementsByTagName("groupId").item(0).getTextContent();
-String a = 
node.getElementsByTagName("artifactId").item(0).getTextContent();
-String v = null;
-NodeList vl = node.getElementsByTagName("version");
-if (vl.getLength() > 0) {
-v = vl.item(0).getTextContent();
-}
-
-// BOMs
-if ("org.apache.camel".equals(g) && "camel-bom".equals(a)) 
{
-camelVersion = v;
-continue;
-}
-if ("org.apache.camel.springboot".equals(g) && 
"camel-spring-boot-bom".equals(a)) {
-camelVersion = v;
-continue;
-}
-if ("org.springframework.boot".equals(g) && 
"spring-boot-dependencies".equals(a)) {
-

Re: [PR] Refactor camel jbang dependency list to not depend on the export command [camel]

2024-02-15 Thread via GitHub


claudio4j commented on code in PR #13134:
URL: https://github.com/apache/camel/pull/13134#discussion_r1491094277


##
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java:
##
@@ -16,146 +16,89 @@
  */
 package org.apache.camel.dsl.jbang.core.commands;
 
-import java.io.File;
+import java.nio.file.Path;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
-import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
-import org.apache.camel.dsl.jbang.core.common.RuntimeUtil;
-import org.apache.camel.dsl.jbang.core.common.XmlHelper;
+import org.apache.camel.dsl.jbang.core.common.MavenGavComparator;
+import org.apache.camel.main.KameletMain;
+import org.apache.camel.main.download.DownloadListener;
 import org.apache.camel.tooling.maven.MavenGav;
-import org.apache.camel.util.CamelCaseOrderedProperties;
-import org.apache.camel.util.FileUtil;
 import picocli.CommandLine;
 
-@CommandLine.Command(name = "list",
- description = "Displays all Camel dependencies required 
to run")
-public class DependencyList extends Export {
+@CommandLine.Command(name = "list", description = "Displays all Camel 
dependencies required to run")
+public class DependencyList extends CamelCommand {
+
+// ignored list of dependencies, can be either groupId or artifactId
+private static final String[] SKIP_DEPS = new String[] {
+"org.fusesource.jansi", "org.apache.logging.log4j", 
"camel-core-languages", "camel-endpointdsl",
+"camel-java-joor-dsl" };

Review Comment:
   The org.fusesource.jansi, org.apache.logging.log4j were already there before 
and I didn't want to disrupt it. The other ignored dependencies are mostly from 
camel core modules, I think these could be removed from the list.



-- 
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-unsubscr...@camel.apache.org

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



Re: [PR] Refactor camel jbang dependency list to not depend on the export command [camel]

2024-02-15 Thread via GitHub


apupier commented on code in PR #13134:
URL: https://github.com/apache/camel/pull/13134#discussion_r1491087554


##
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java:
##
@@ -16,146 +16,89 @@
  */
 package org.apache.camel.dsl.jbang.core.commands;
 
-import java.io.File;
+import java.nio.file.Path;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
-import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
-import org.apache.camel.dsl.jbang.core.common.RuntimeUtil;
-import org.apache.camel.dsl.jbang.core.common.XmlHelper;
+import org.apache.camel.dsl.jbang.core.common.MavenGavComparator;
+import org.apache.camel.main.KameletMain;
+import org.apache.camel.main.download.DownloadListener;
 import org.apache.camel.tooling.maven.MavenGav;
-import org.apache.camel.util.CamelCaseOrderedProperties;
-import org.apache.camel.util.FileUtil;
 import picocli.CommandLine;
 
-@CommandLine.Command(name = "list",
- description = "Displays all Camel dependencies required 
to run")
-public class DependencyList extends Export {
+@CommandLine.Command(name = "list", description = "Displays all Camel 
dependencies required to run")
+public class DependencyList extends CamelCommand {
+
+// ignored list of dependencies, can be either groupId or artifactId
+private static final String[] SKIP_DEPS = new String[] {
+"org.fusesource.jansi", "org.apache.logging.log4j", 
"camel-core-languages", "camel-endpointdsl",
+"camel-java-joor-dsl" };
 
-protected static final String EXPORT_DIR = 
CommandLineHelper.CAMEL_JBANG_WORK_DIR + "/export";
+@CommandLine.Parameters(description = "The Camel file(s) to inspect for 
dependencies.", arity = "0..9",
+paramLabel = "")
+protected Path[] filePaths;
 
 @CommandLine.Option(names = { "--output" }, description = "Output format 
(gav, maven, jbang)", defaultValue = "gav")
 protected String output;
 
+@CommandLine.Option(names = { "-v" }, description = "Print additional 
verbose output.")
+protected boolean verbose = false;
+
+private Set dependencies;
+
 public DependencyList(CamelJBangMain main) {
 super(main);
+Arrays.sort(SKIP_DEPS);
 }
 
 @Override
 public Integer doCall() throws Exception {
-this.quiet = true; // be quiet and generate from fresh data to ensure 
the output is up-to-date
-return super.doCall();
-}
-
-@Override
-protected Integer export() throws Exception {
 if (!"gav".equals(output) && !"maven".equals(output) && 
!"jbang".equals(output)) {
-System.err.println("--output must be either gav or maven, was: " + 
output);
+System.err.println("--output must be either gav, maven or jbang, 
was: " + output);
 return 1;
 }
+calculate();
+return 0;
+}
 
-Integer answer = doExport();
-if (answer == 0) {
-// read pom.xml
-File pom = new File(EXPORT_DIR, "pom.xml");
-if (pom.exists()) {
-DocumentBuilderFactory dbf = 
XmlHelper.createDocumentBuilderFactory();
-DocumentBuilder db = dbf.newDocumentBuilder();
-Document dom = db.parse(pom);
-NodeList nl = dom.getElementsByTagName("dependency");
-List gavs = new ArrayList<>();
-String camelVersion = null;
-String springBootVersion = null;
-String quarkusVersion = null;
-for (int i = 0; i < nl.getLength(); i++) {
-Element node = (Element) nl.item(i);
-String g = 
node.getElementsByTagName("groupId").item(0).getTextContent();
-String a = 
node.getElementsByTagName("artifactId").item(0).getTextContent();
-String v = null;
-NodeList vl = node.getElementsByTagName("version");
-if (vl.getLength() > 0) {
-v = vl.item(0).getTextContent();
-}
-
-// BOMs
-if ("org.apache.camel".equals(g) && "camel-bom".equals(a)) 
{
-camelVersion = v;
-continue;
-}
-if ("org.apache.camel.springboot".equals(g) && 
"camel-spring-boot-bom".equals(a)) {
-camelVersion = v;
-continue;
-}
-if ("org.springframework.boot".equals(g) && 
"spring-boot-dependencies".equals(a)) {
-

Re: [PR] Refactor camel jbang dependency list to not depend on the export command [camel]

2024-02-15 Thread via GitHub


apupier commented on code in PR #13134:
URL: https://github.com/apache/camel/pull/13134#discussion_r1491083778


##
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java:
##
@@ -16,146 +16,89 @@
  */
 package org.apache.camel.dsl.jbang.core.commands;
 
-import java.io.File;
+import java.nio.file.Path;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
-import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
-import org.apache.camel.dsl.jbang.core.common.RuntimeUtil;
-import org.apache.camel.dsl.jbang.core.common.XmlHelper;
+import org.apache.camel.dsl.jbang.core.common.MavenGavComparator;
+import org.apache.camel.main.KameletMain;
+import org.apache.camel.main.download.DownloadListener;
 import org.apache.camel.tooling.maven.MavenGav;
-import org.apache.camel.util.CamelCaseOrderedProperties;
-import org.apache.camel.util.FileUtil;
 import picocli.CommandLine;
 
-@CommandLine.Command(name = "list",
- description = "Displays all Camel dependencies required 
to run")
-public class DependencyList extends Export {
+@CommandLine.Command(name = "list", description = "Displays all Camel 
dependencies required to run")
+public class DependencyList extends CamelCommand {
+
+// ignored list of dependencies, can be either groupId or artifactId
+private static final String[] SKIP_DEPS = new String[] {
+"org.fusesource.jansi", "org.apache.logging.log4j", 
"camel-core-languages", "camel-endpointdsl",
+"camel-java-joor-dsl" };

Review Comment:
   Why are there ignored dependencies?



-- 
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-unsubscr...@camel.apache.org

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