Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
{ "name": "camel.jbang.metrics", "required": false, "description": "Metrics (Micrometer and Prometheus) at \/observe\/metrics on local HTTP server (port 8080 by default) when running standalone Camel", "type": "boolean", "javaType": "boolean", "defaultValue": false, "secret": false, "deprecated": true },
{ "name": "camel.jbang.openApi", "required": false, "description": "File name of open-api spec file (JSON or YAML) to generate routes from the swagger\/openapi API spec file.", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.packageScanJars", "required": false, "description": "Whether to automatic package scan JARs for custom Spring or Quarkus beans making them available for Camel CLI", "label": "advanced", "type": "boolean", "javaType": "boolean", "defaultValue": false, "secret": false },
{ "name": "camel.jbang.parentPom", "required": false, "description": "Parent POM coordinate (groupId:artifactId:version) to use in the exported project", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.prompt", "required": false, "description": "Allow user to type in required parameters in prompt if not present in application", "label": "advanced", "type": "boolean", "javaType": "boolean", "defaultValue": false, "secret": false },
{ "name": "camel.jbang.quarkusArtifactId", "required": false, "description": "artifactId of Quarkus Platform BOM", "label": "quarkus", "type": "string", "javaType": "String", "secret": false, "deprecated": true },
{ "name": "camel.jbang.quarkusExtensionRegistryBaseUri", "required": false, "description": "The base URI of Quarkus Extension Registry", "label": "quarkus", "type": "string", "javaType": "String", "secret": false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This page covers configuring the Camel CLI — available options, configuration

// jbang options: START
== Camel CLI configurations
The camel.jbang supports 48 options, which are listed below.
The camel.jbang supports 49 options, which are listed below.

[width="100%",cols="2,5,^1,2",options="header"]
|===
Expand Down Expand Up @@ -43,6 +43,7 @@ The camel.jbang supports 48 options, which are listed below.
| *camel.jbang.metrics* | Metrics (Micrometer and Prometheus) at /observe/metrics on local HTTP server (port 8080 by default) when running standalone Camel | false | boolean
| *camel.jbang.openApi* | File name of open-api spec file (JSON or YAML) to generate routes from the swagger/openapi API spec file. | | String
| *camel.jbang.packageScanJars* | Whether to automatic package scan JARs for custom Spring or Quarkus beans making them available for Camel CLI | false | boolean
| *camel.jbang.parentPom* | Parent POM coordinate (groupId:artifactId:version) to use in the exported project | | String
| *camel.jbang.prompt* | Allow user to type in required parameters in prompt if not present in application | false | boolean
| *camel.jbang.quarkusArtifactId* | artifactId of Quarkus Platform BOM | | String
| *camel.jbang.quarkusExtensionRegistryBaseUri* | The base URI of Quarkus Extension Registry | | String
Expand Down
34 changes: 34 additions & 0 deletions docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,40 @@ Notes:
- The `--profile` option is not supported when exporting to Quarkus.
- For Spring Boot, you can override versions with `--camel-spring-boot-version`.

=== Exporting with a parent POM

When organizations run many Camel integrations, they typically use a parent POM to standardize
plugin versions, required extensions, and common dependencies. Use `--parent-pom` to set the
parent POM in the exported project:

[source,bash]
----
camel export --runtime=quarkus --gav=com.foo:acme:1.0-SNAPSHOT --parent-pom=com.ourorg:camel-parent:1.0
----

This generates the `<parent>` block in the exported `pom.xml`:

[source,xml]
----
<parent>
<groupId>com.ourorg</groupId>
<artifactId>camel-parent</artifactId>
<version>1.0</version>
<relativePath/>
</parent>
----

For Spring Boot, specifying `--parent-pom` replaces the default `spring-boot-starter-parent`.
The Spring Boot BOM (`spring-boot-dependencies`) remains in `<dependencyManagement>`, so version
management continues to work.

You can also configure this in `application.properties`:

[source,properties]
----
camel.jbang.parentPom=com.ourorg:camel-parent:1.0
----

=== Exporting with Java Agent included

NOTE: Only `camel-main` runtime supports Java Agents.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ camel dependency copy [options]
| `--output-directory` | Directory where dependencies should be copied | lib | String
| `--package-name` | For Java source files should they have the given package name. By default the package name is computed from the Maven GAV. Use false to turn off and not include package name in the Java source files. | | String
| `--package-scan-jars` | Whether to automatic package scan JARs for custom Spring or Quarkus beans making them available for Camel CLI | false | boolean
| `--parent-pom` | The Maven parent POM group:artifact:version | | String
| `--port` | Embeds a local HTTP server on this port | | int
| `--profile` | Profile to export (dev, test, prod). | | String
| `--prop,--property` | Camel application properties, ex. --property=prop1=foo | | String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ camel dependency list [options]
| `--output` | Output format (gav, maven, jbang) | gav | String
| `--package-name` | For Java source files should they have the given package name. By default the package name is computed from the Maven GAV. Use false to turn off and not include package name in the Java source files. | | String
| `--package-scan-jars` | Whether to automatic package scan JARs for custom Spring or Quarkus beans making them available for Camel CLI | false | boolean
| `--parent-pom` | The Maven parent POM group:artifact:version | | String
| `--port` | Embeds a local HTTP server on this port | | int
| `--profile` | Profile to export (dev, test, prod). | | String
| `--prop,--property` | Camel application properties, ex. --property=prop1=foo | | String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ camel dependency update [options]
| `--output` | Output format (gav, maven, jbang) | gav | String
| `--package-name` | For Java source files should they have the given package name. By default the package name is computed from the Maven GAV. Use false to turn off and not include package name in the Java source files. | | String
| `--package-scan-jars` | Whether to automatic package scan JARs for custom Spring or Quarkus beans making them available for Camel CLI | false | boolean
| `--parent-pom` | The Maven parent POM group:artifact:version | | String
| `--port` | Embeds a local HTTP server on this port | | int
| `--profile` | Profile to export (dev, test, prod). | | String
| `--prop,--property` | Camel application properties, ex. --property=prop1=foo | | String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ camel export [options]
| `--open-api` | Adds an OpenAPI spec from the given file (json or yaml file) | | String
| `--package-name` | For Java source files should they have the given package name. By default the package name is computed from the Maven GAV. Use false to turn off and not include package name in the Java source files. | | String
| `--package-scan-jars` | Whether to automatic package scan JARs for custom Spring or Quarkus beans making them available for Camel CLI | false | boolean
| `--parent-pom` | The Maven parent POM group:artifact:version | | String
| `--port` | Embeds a local HTTP server on this port | | int
| `--profile` | Profile to export (dev, test, prod). | | String
| `--prop,--property` | Camel application properties, ex. --property=prop1=foo | | String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ camel sbom [options]
| `--output-name` | Output name of the SBOM file | sbom | String
| `--package-name` | For Java source files should they have the given package name. By default the package name is computed from the Maven GAV. Use false to turn off and not include package name in the Java source files. | | String
| `--package-scan-jars` | Whether to automatic package scan JARs for custom Spring or Quarkus beans making them available for Camel CLI | false | boolean
| `--parent-pom` | The Maven parent POM group:artifact:version | | String
| `--port` | Embeds a local HTTP server on this port | | int
| `--profile` | Profile to export (dev, test, prod). | | String
| `--prop,--property` | Camel application properties, ex. --property=prop1=foo | | String
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
{ "name": "camel.jbang.metrics", "required": false, "description": "Metrics (Micrometer and Prometheus) at \/observe\/metrics on local HTTP server (port 8080 by default) when running standalone Camel", "type": "boolean", "javaType": "boolean", "defaultValue": false, "secret": false, "deprecated": true },
{ "name": "camel.jbang.openApi", "required": false, "description": "File name of open-api spec file (JSON or YAML) to generate routes from the swagger\/openapi API spec file.", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.packageScanJars", "required": false, "description": "Whether to automatic package scan JARs for custom Spring or Quarkus beans making them available for Camel CLI", "label": "advanced", "type": "boolean", "javaType": "boolean", "defaultValue": false, "secret": false },
{ "name": "camel.jbang.parentPom", "required": false, "description": "Parent POM coordinate (groupId:artifactId:version) to use in the exported project", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.prompt", "required": false, "description": "Allow user to type in required parameters in prompt if not present in application", "label": "advanced", "type": "boolean", "javaType": "boolean", "defaultValue": false, "secret": false },
{ "name": "camel.jbang.quarkusArtifactId", "required": false, "description": "artifactId of Quarkus Platform BOM", "label": "quarkus", "type": "string", "javaType": "String", "secret": false, "deprecated": true },
{ "name": "camel.jbang.quarkusExtensionRegistryBaseUri", "required": false, "description": "The base URI of Quarkus Extension Registry", "label": "quarkus", "type": "string", "javaType": "String", "secret": false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import static org.apache.camel.dsl.jbang.core.common.CamelJBangConstants.MAVEN_SETTINGS_SECURITY;
import static org.apache.camel.dsl.jbang.core.common.CamelJBangConstants.MAVEN_WRAPPER;
import static org.apache.camel.dsl.jbang.core.common.CamelJBangConstants.OPEN_API;
import static org.apache.camel.dsl.jbang.core.common.CamelJBangConstants.PARENT_POM;
import static org.apache.camel.dsl.jbang.core.common.CamelJBangConstants.SPRING_BOOT_VERSION;

@Command(name = "export",
Expand Down Expand Up @@ -190,6 +191,7 @@ private void doLoadAndInitProfileProperties(Path path) throws Exception {
this.runtime = RuntimeType.fromValue(rt);
}
this.gav = props.getProperty(GAV, this.gav);
this.parentPom = props.getProperty(PARENT_POM, this.parentPom);
// allow configuring versions from profile
this.javaVersion = props.getProperty(JAVA_VERSION, this.javaVersion);
this.camelVersion = props.getProperty(CAMEL_VERSION, this.camelVersion);
Expand Down Expand Up @@ -234,6 +236,7 @@ protected Integer export(Path exportBaseDir, ExportBaseCommand cmd) throws Excep
cmd.managementPort = this.managementPort;
cmd.observe = this.observe;
cmd.gav = this.gav;
cmd.parentPom = this.parentPom;
cmd.mavenSettings = this.mavenSettings;
cmd.mavenSettingsSecurity = this.mavenSettingsSecurity;
cmd.mavenCentralEnabled = this.mavenCentralEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public abstract class ExportBaseCommand extends CamelCommand {
@CommandLine.Option(names = { "--gav" }, description = "The Maven group:artifact:version")
protected String gav;

@CommandLine.Option(names = { "--parent-pom" }, description = "The Maven parent POM group:artifact:version")
protected String parentPom;

@CommandLine.Option(names = { "--exclude" }, description = "Exclude files by name or pattern")
protected List<String> excludes = new ArrayList<>();

Expand Down Expand Up @@ -514,6 +517,15 @@ int rankGroupId(MavenGav o1) {
/**
* Formats build properties as XML property lines for inclusion in POM templates.
*/
protected void enrichParentPom(Map<String, Object> model) {
if (parentPom != null) {
MavenGav gav = MavenGav.parseStrictGav(parentPom);
model.put("ParentGroupId", gav.getGroupId());
model.put("ParentArtifactId", gav.getArtifactId());
model.put("ParentVersion", gav.getVersion());
}
}

protected String formatBuildProperties() {
Properties properties = mapBuildProperties();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.camel.dsl.jbang.core.common.RuntimeUtil;
import org.apache.camel.dsl.jbang.core.common.TemplateHelper;
import org.apache.camel.dsl.jbang.core.common.VersionHelper;
import org.apache.camel.tooling.maven.MavenGav;
import org.apache.camel.util.CamelCaseOrderedProperties;
import org.apache.camel.util.ObjectHelper;

Expand All @@ -51,11 +52,21 @@ public ExportCamelMain(CamelJBangMain main) {

@Override
public Integer export() throws Exception {
String[] ids = gav.split(":");
if (ids.length != 3) {
try {
MavenGav.parseStrictGav(gav);
} catch (IllegalArgumentException e) {
printer().printErr("--gav must be in syntax: groupId:artifactId:version");
return 1;
}
if (parentPom != null) {
try {
MavenGav.parseStrictGav(parentPom);
} catch (IllegalArgumentException e) {
printer().printErr("--parent-pom must be in syntax: groupId:artifactId:version");
return 1;
}
}
String[] ids = gav.split(":");

// the settings file has information what to export
Path settings = CommandLineHelper.getWorkDir().resolve(Run.RUN_SETTINGS_FILE);
Expand Down Expand Up @@ -217,6 +228,7 @@ private void createMavenPom(Path settings, Path profile, Path pom, Set<String> d
model.put("Repositories", buildRepositoryList(repos));
model.put("Dependencies", buildDependencyList(deps));
model.put("JibMavenPluginVersion", jibMavenPluginVersion(settings, prop));
enrichParentPom(model);

// kubernetes/docker properties
enrichKubernetesModel(model, settings, profile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,21 @@ public ExportQuarkus(CamelJBangMain main) {

@Override
public Integer export() throws Exception {
String[] ids = gav.split(":");
if (ids.length != 3) {
try {
MavenGav.parseStrictGav(gav);
} catch (IllegalArgumentException e) {
printer().printErr("--gav must be in syntax: groupId:artifactId:version");
return 1;
}
if (parentPom != null) {
try {
MavenGav.parseStrictGav(parentPom);
} catch (IllegalArgumentException e) {
printer().printErr("--parent-pom must be in syntax: groupId:artifactId:version");
return 1;
}
}
String[] ids = gav.split(":");

exportBaseDir = exportBaseDir != null ? exportBaseDir : Path.of(".");
Path profile = exportBaseDir.resolve("application.properties");
Expand Down Expand Up @@ -396,6 +406,7 @@ private void createMavenPom(Path settings, Path pom, Set<String> deps) throws Ex
model.put("Repositories", buildRepositoryList(repos));
model.put("Dependencies", depList);
model.put("JibMavenPluginVersion", jibMavenPluginVersion(settings, prop));
enrichParentPom(model);

String context = TemplateHelper.processTemplate(pomTemplateName, model);
Files.writeString(pom, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,21 @@ public ExportSpringBoot(CamelJBangMain main) {

@Override
public Integer export() throws Exception {
String[] ids = gav.split(":");
if (ids.length != 3) {
try {
MavenGav.parseStrictGav(gav);
} catch (IllegalArgumentException e) {
printer().printErr("--gav must be in syntax: groupId:artifactId:version");
return 1;
}
if (parentPom != null) {
try {
MavenGav.parseStrictGav(parentPom);
} catch (IllegalArgumentException e) {
printer().printErr("--parent-pom must be in syntax: groupId:artifactId:version");
return 1;
}
}
String[] ids = gav.split(":");

exportBaseDir = exportBaseDir != null ? exportBaseDir : Path.of(".");
Path profile = exportBaseDir.resolve("application.properties");
Expand Down Expand Up @@ -228,6 +238,7 @@ private void createMavenPom(Path settings, Path profile, Path pom, Set<String> d
model.put("Repositories", buildRepositoryList(repos));
model.put("Dependencies", depList);
model.put("JibMavenPluginVersion", jibMavenPluginVersion(settings, prop));
enrichParentPom(model);

String context = TemplateHelper.processTemplate(pomTemplateName, model);
IOHelper.writeText(context, Files.newOutputStream(pom));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public final class CamelJBangConstants {
javaType = "String")
public static final String GAV = "camel.jbang.gav";

@Metadata(description = "Parent POM coordinate (groupId:artifactId:version) to use in the exported project",
javaType = "String")
public static final String PARENT_POM = "camel.jbang.parentPom";

@Metadata(description = "Java version",
javaType = "String", enums = "21", defaultValue = "21")
public static final String JAVA_VERSION = "camel.jbang.javaVersion";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

[#if ParentGroupId??]
<parent>
<groupId>[=ParentGroupId]</groupId>
<artifactId>[=ParentArtifactId]</artifactId>
<version>[=ParentVersion]</version>
<relativePath/>
</parent>

[/#if]
<groupId>[=GroupId]</groupId>
<artifactId>[=ArtifactId]</artifactId>
<version>[=Version]</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

[#if ParentGroupId??]
<parent>
<groupId>[=ParentGroupId]</groupId>
<artifactId>[=ParentArtifactId]</artifactId>
<version>[=ParentVersion]</version>
<relativePath/>
</parent>

[/#if]
<groupId>[=GroupId]</groupId>
<artifactId>[=ArtifactId]</artifactId>
<version>[=Version]</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@

<modelVersion>4.0.0</modelVersion>

[#if ParentGroupId??]
<parent>
<groupId>[=ParentGroupId]</groupId>
<artifactId>[=ParentArtifactId]</artifactId>
<version>[=ParentVersion]</version>
<relativePath/>
</parent>

[/#if]
<groupId>[=GroupId]</groupId>
<artifactId>[=ArtifactId]</artifactId>
<version>[=Version]</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

[#if ParentGroupId??]
<parent>
<groupId>[=ParentGroupId]</groupId>
<artifactId>[=ParentArtifactId]</artifactId>
<version>[=ParentVersion]</version>
<relativePath/>
</parent>

[/#if]
<groupId>[=GroupId]</groupId>
<artifactId>[=ArtifactId]</artifactId>
<version>[=Version]</version>
Expand Down
Loading