-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat(catalog): Dynamically build Camel Catalog #1169
Conversation
7e388ad
to
2c6c1bb
Compare
packages/catalog-generator/.mvn/wrapper/maven-wrapper.properties
Outdated
Show resolved
Hide resolved
packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/commands/GenerateCommand.java
Outdated
Show resolved
Hide resolved
d41206c
to
b600156
Compare
packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/Build.java
Outdated
Show resolved
Hide resolved
...s/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java
Outdated
Show resolved
Hide resolved
...s/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java
Outdated
Show resolved
Hide resolved
...s/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java
Outdated
Show resolved
Hide resolved
...s/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java
Outdated
Show resolved
Hide resolved
...s/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java
Outdated
Show resolved
Hide resolved
...s/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java
Outdated
Show resolved
Hide resolved
...s/catalog-generator/src/main/java/io/kaoto/camelcatalog/maven/CamelCatalogVersionLoader.java
Outdated
Show resolved
Hide resolved
...s/catalog-generator/src/main/java/io/kaoto/camelcatalog/maven/CamelCatalogVersionLoader.java
Outdated
Show resolved
Hide resolved
|
||
public class CamelCatalogVersionLoader { | ||
private static final Logger LOGGER = Logger.getLogger(CamelCatalogVersionLoader.class.getName()); | ||
private final KaotoMavenVersionManager KAOTO_VERSION_MANAGER = new KaotoMavenVersionManager(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either decalre it as static or rename following the regular expression '^[a-z][a-zA-Z0-9]*$'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given that it cannot be static for the use case, the field should be renamed to follow Java guidelines on naming with the regular expression '^[a-z][a-zA-Z0-9]*$'.
...s/catalog-generator/src/main/java/io/kaoto/camelcatalog/maven/CamelCatalogVersionLoader.java
Outdated
Show resolved
Hide resolved
...log-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelYamlDslSchemaProcessor.java
Outdated
Show resolved
Hide resolved
...es/catalog-generator/src/main/java/io/kaoto/camelcatalog/maven/KaotoMavenVersionManager.java
Outdated
Show resolved
Hide resolved
...es/catalog-generator/src/main/java/io/kaoto/camelcatalog/maven/KaotoMavenVersionManager.java
Outdated
Show resolved
Hide resolved
...es/catalog-generator/src/main/java/io/kaoto/camelcatalog/maven/KaotoMavenVersionManager.java
Outdated
Show resolved
Hide resolved
addressed the mentioned problems in lordrip#30 |
it doesn't compile
the import package is missing. |
My PR should have the fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be worthy to rework commit history, there is currently several commits with same message
yep, that was caused by accepting your PR suggestions. |
cleaned up the history on the PR for this PR :D So you only need to squash rename after u merged |
5b9682b
to
24f0e92
Compare
This commit adds a Camel Catalog generator CLI to build the following structure: ``` dist/ ├─ camel-main/ │ ├─ 4.4.0/ │ ├─ 4.6.0/ ├─ camel-quarkus/ │ ├─ 3.8.0/ ├─ camel-springboot/ │ ├─ 4.4.0/ │ ├─ 4.6.0/ ├─ index.json ``` * How to run? ```bash mvn package; java -jar ./target/catalog-generator-0.0.1-SNAPSHOT.jar -o ./dist -k 4.6.0 -m 4.6.0 -m 4.4.0 -q 3.8.0 -s 4.6.0 ``` This will generate: * Camel Main 4.4.0 * Camel Main 4.6.0 * Camel Quarkus 3.8.0 * Camel SpringBoot 4.6.0 * Usage ``` usage: catalog-generator -k,--kamelets <kameletsVersion> Kamelets catalog version -m,--main <version> Camel Main version -o,--output <outputDir> Output directory. It will be cleaned before generating the catalogs -q,--quarkus <version> Camel Extensions for Quarkus version -s,--springboot <version> Camel SpringBoot version -v,--verbose Be more verbose ``` relates: KaotoIO#1109
24f0e92
to
3845547
Compare
ConfigBean configBean = new ConfigBean(); | ||
CommandLineParser parser = new DefaultParser(); | ||
|
||
CommandLine cmd = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be initialized directly in side the try
|
||
public class CamelCatalogVersionLoader { | ||
private static final Logger LOGGER = Logger.getLogger(CamelCatalogVersionLoader.class.getName()); | ||
private final KaotoMavenVersionManager KAOTO_VERSION_MANAGER = new KaotoMavenVersionManager(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given that it cannot be static for the use case, the field should be renamed to follow Java guidelines on naming with the regular expression '^[a-z][a-zA-Z0-9]*$'.
LOGGER.log(Level.WARNING, | ||
String.format("Cannot resolve artifact {} due to {}", gav, e.getMessage()), e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here it is assuming that it is an error resolving the artifact, it can be another kind of error
URL found = null; | ||
Enumeration<URL> urls = getClassLoader().getResources(name); | ||
while (urls.hasMoreElements()) { | ||
URL url = urls.nextElement(); | ||
if (url.getPath().contains(version)) { | ||
found = url; | ||
break; | ||
} | ||
} | ||
if (found != null) { | ||
return found.openStream(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can directly return found.openStream instead of using a found
and a break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you be more precise here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private InputStream doGetResourceAsStream(String name, String version) {
if (version != null) {
try {
Enumeration<URL> urls = getClassLoader().getResources(name);
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
if (url.getPath().contains(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));
}
}
}
return null;
?
"type" : "object", | ||
"additionalProperties" : false, | ||
"title": "Pipe Error Handler", | ||
"description": "Camel K Pipe ErrorHandler. See https://camel.apache.org/camel-k/latest/pipe-step.html#_error_handler for more details.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Page not found for the link
|
||
@Test | ||
public void testGenerate() throws IOException { | ||
// Main.main(new String[] {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we uncomment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lordrip ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to bring and adapt the tests from the @kaoto/camel-catalog
project, we can uncomment, but nevertheless, the entire file will be replaced.
Context
This commit adds a Camel Catalog generator CLI to build the following structure:
How to run?
Alternatively,
yarn
can be used as well:This will generate:
Usage
fix: #1109