Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(catalog): Build Red Hat build of CEQ #1238

Merged
merged 3 commits into from
Jul 10, 2024
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
1 change: 1 addition & 0 deletions packages/catalog-generator/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode/settings.json
target/
.idea/
dependency-reduced-pom.xml
4 changes: 0 additions & 4 deletions packages/catalog-generator/.vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/catalog-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Install the project dependencies:
Run the project with the following command:

```bash
./mvnw package; java -jar ./target/catalog-generator-0.0.1-SNAPSHOT.jar -o ./dist/camel-catalog -k 4.6.0 -m 4.6.0 -m 4.4.0 -m 4.4.0.redhat-00025 -q 3.8.0 -s 4.6.0 -n "Default Catalog"
./mvnw package; java -jar ./target/catalog-generator-0.0.1-SNAPSHOT.jar -o ./dist/camel-catalog -k 4.6.0 -m 4.6.0 -m 4.4.0 -m 4.4.0.redhat-00025 -q 3.12.0 -q 3.8.0.redhat-00006 -s 4.6.0 -s 4.4.0.redhat-00014 -n "Default Catalog"
```
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import io.kaoto.camelcatalog.model.CatalogRuntime;

/**
* Customize Camel Catalog for Kaoto.
*/
Expand All @@ -46,13 +48,15 @@ public class CamelCatalogProcessor {
private final ObjectMapper jsonMapper;
private final CamelCatalog camelCatalog;
private final CamelYamlDslSchemaProcessor schemaProcessor;
private final CatalogRuntime runtime;
private boolean verbose;

public CamelCatalogProcessor(CamelCatalog camelCatalog, ObjectMapper jsonMapper,
CamelYamlDslSchemaProcessor schemaProcessor, boolean verbose) {
CamelYamlDslSchemaProcessor schemaProcessor, CatalogRuntime runtime, boolean verbose) {
this.jsonMapper = jsonMapper;
this.camelCatalog = camelCatalog;
this.schemaProcessor = schemaProcessor;
this.runtime = runtime;
this.verbose = verbose;
}

Expand Down Expand Up @@ -95,6 +99,25 @@ public String getComponentCatalog() throws Exception {
var json = JsonMapper.asJsonObject(model).toJson();
var catalogNode = (ObjectNode) jsonMapper.readTree(json);
generatePropertiesSchema(catalogNode);

ObjectNode componentDefinition = catalogNode.withObject("/component");
String componentVersion = model.getVersion();

/**
* Quarkus has a different versioning scheme, therefore we need to get the Camel
* version from the debug model and combine it with the component version
*/
if (runtime == CatalogRuntime.Quarkus) {
String camelVersion = camelCatalog.model(Kind.other, "debug").getMetadata()
.get("camelVersion").toString();
componentVersion = String.format("%s (CEQ %s)", camelVersion, model.getVersion());
}

componentDefinition.put("version", componentVersion);
if (componentVersion.contains("redhat")) {
componentDefinition.put("provider", "Red Hat");
}

answer.set(name, catalogNode);
} catch (Exception e) {
if (verbose) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private CamelYamlDslSchemaProcessor processCamelSchema(CatalogDefinition index)

private void processCatalog(CamelYamlDslSchemaProcessor schemaProcessor, CatalogDefinition index) {
var catalogProcessor = new CamelCatalogProcessor(camelCatalogVersionLoader.getCamelCatalog(), jsonMapper,
schemaProcessor, verbose);
schemaProcessor, runtime, verbose);
try {
var catalogMap = catalogProcessor.processCatalog();
catalogMap.forEach((name, catalog) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public class CamelCatalogVersionLoader {
private static final Logger LOGGER = Logger.getLogger(CamelCatalogVersionLoader.class.getName());
private final KaotoMavenVersionManager kaotoVersionManager = new KaotoMavenVersionManager();
private final CamelCatalog camelCatalog = new DefaultCamelCatalog(false);
private final CamelCatalog camelCatalog = new DefaultCamelCatalog(true);
private final Map<String, String> kameletBoundaries = new HashMap<>();
private final Map<String, String> kamelets = new HashMap<>();
private final List<String> camelKCRDs = new ArrayList<>();
Expand Down Expand Up @@ -288,10 +288,9 @@ private MavenCoordinates getCatalogMavenCoordinates(CatalogRuntime runtime, Stri
private MavenCoordinates getYamlDslMavenCoordinates(CatalogRuntime runtime, OtherModel yamlDSLModel) {
switch (runtime) {
case Quarkus:
String version = yamlDSLModel.getMetadata().get("camelVersion").toString();
return new MavenCoordinates(Constants.APACHE_CAMEL_ORG, Constants.CAMEL_YAML_DSL_PACKAGE, version);
return new MavenCoordinates(Constants.APACHE_CAMEL_ORG + ".quarkus", "camel-quarkus-yaml-dsl", yamlDSLModel.getVersion());
case SpringBoot:
return new MavenCoordinates(Constants.APACHE_CAMEL_ORG, Constants.CAMEL_YAML_DSL_PACKAGE,
return new MavenCoordinates(Constants.APACHE_CAMEL_ORG + ".springboot", "camel-yaml-dsl-starter",
yamlDSLModel.getVersion());
default:
return new MavenCoordinates(Constants.APACHE_CAMEL_ORG,
Expand All @@ -303,7 +302,7 @@ private MavenCoordinates getYamlDslMavenCoordinates(CatalogRuntime runtime, Othe
/*
* This method is used to load a dependency in the classpath. This is a
* workaround
* to load dependencies that are not in the classpath, while the Kamel Catalog
* to load dependencies that are not in the classpath, while the Camel Catalog
* exposes a method to load dependencies in the classpath.
*/
private boolean loadDependencyInClasspath(MavenCoordinates mavenCoordinates) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ public boolean loadRuntimeProviderVersion(String groupId, String artifactId, Str
try {
MavenDownloader mavenDownloader = downloader;
String gav = String.format("%s:%s:%s", groupId, artifactId, version);
boolean shouldFetchTransitive = artifactId.contains("yaml");
boolean shouldUseSnapshots = version.endsWith("SNAPSHOT");

boolean useSnapshots = version.endsWith("SNAPSHOT");
resolve(mavenDownloader, gav, useSnapshots, false);
resolve(mavenDownloader, gav, shouldUseSnapshots, shouldFetchTransitive);

if (artifactId.contains("catalog")) {
this.version = version;
Expand Down Expand Up @@ -156,11 +157,12 @@ private InputStream doGetResourceAsStream(String name, String version) {
return url.openStream();
}
}

} catch (IOException e) {
if (getLog()) {
LOGGER.log(Level.WARNING, String.format("Cannot open resource {} and version {} due {}", name, version,
e.getMessage(), e));
LOGGER.log(Level.WARNING,
String.format("Cannot open resource {} and version {} due {}", name, version,
e.getMessage(), e));

}
}
Expand Down
Loading