Skip to content

Commit 55c21b0

Browse files
committed
Add support for custom repositories
1 parent 47c8796 commit 55c21b0

File tree

9 files changed

+218
-85
lines changed

9 files changed

+218
-85
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.quarkus.code</groupId>
88
<artifactId>code-quarkus-parent</artifactId>
9-
<version>59</version>
9+
<version>60</version>
1010
</parent>
1111

1212
<artifactId>code-quarkus-redhat-app</artifactId>

src/main/java/GlobalConstants.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import java.util.Set;
2+
3+
class GlobalConstants {
4+
5+
private GlobalConstants() {
6+
}
7+
8+
static final String ICONS_ASSETS_URL = "/assets/icons";
9+
10+
static final Set<String> TAGS = Set.of(
11+
"with:starter-code", "status:stable", "status:preview", "status:experimental", "status:deprecated",
12+
"support:full-support", "support:supported-in-jvm", "support:dev-support", "support:tech-preview",
13+
"support:deprecated");
14+
}

src/main/java/IBMConstants.java

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import io.quarkus.code.model.Preset;
2+
3+
import java.util.List;
4+
5+
class IBMConstants {
6+
7+
private IBMConstants() {
8+
}
9+
10+
public static final List<Preset> IBM_PRESETS = List.of(
11+
// Some presets are duplicated to support platforms before and after the Big Reactive Renaming
12+
new Preset("rest-service", "REST service",
13+
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/rest-service.svg",
14+
List.of("io.quarkus:quarkus-rest")),
15+
new Preset("db-service", "REST service with database",
16+
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/db-service.svg",
17+
List.of("io.quarkus:quarkus-rest", "io.quarkus:quarkus-rest-jackson",
18+
"io.quarkus:quarkus-hibernate-orm-panache", "io.quarkus:quarkus-jdbc-postgresql")),
19+
new Preset("event-driven-kafka", "Event driven service with Kafka",
20+
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/event-driven.svg",
21+
List.of("io.quarkus:quarkus-messaging-kafka")),
22+
new Preset("cli", "Command-line tool",
23+
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/cli.svg",
24+
List.of("io.quarkus:quarkus-picocli")),
25+
new Preset("webapp-mvc", "Web app with Model-View-Controller",
26+
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/webapp-mvc.svg",
27+
List.of("io.quarkiverse.renarde:quarkus-renarde", "io.quarkiverse.web-bundler:quarkus-web-bundler")),
28+
new Preset("webapp-npm", "Web app with NPM UI",
29+
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/webapp-npm.svg",
30+
List.of("io.quarkus:quarkus-rest", "io.quarkus:quarkus-rest-jackson",
31+
"io.quarkiverse.quinoa:quarkus-quinoa")),
32+
new Preset("webapp-qute", "Web app with ServerSide Rendering",
33+
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/webapp-qute.svg",
34+
List.of("io.quarkiverse.qute.web:quarkus-qute-web", "io.quarkiverse.web-bundler:quarkus-web-bundler")),
35+
new Preset("ai-infused", "AI Infused service",
36+
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/ai-infused.svg",
37+
List.of("io.quarkiverse.langchain4j:quarkus-langchain4j-openai",
38+
"io.quarkiverse.langchain4j:quarkus-langchain4j-easy-rag")));
39+
40+
//language=xml
41+
static final List<String> IBM_POM_REPOSITORIES = """
42+
<repositories>
43+
<repository>
44+
<id>ibm-enterprise-maven-repository</id>
45+
<url>https://maven.repository.ibm.com/releases/</url>
46+
<releases>
47+
<enabled>true</enabled>
48+
</releases>
49+
<snapshots>
50+
<enabled>true</enabled>
51+
</snapshots>
52+
</repository>
53+
</repositories>
54+
<pluginRepositories>
55+
<pluginRepository>
56+
<id>ibm-enterprise-maven-repository</id>
57+
<url>https://maven.repository.ibm.com/releases/</url>
58+
<releases>
59+
<enabled>true</enabled>
60+
</releases>
61+
<snapshots>
62+
<enabled>true</enabled>
63+
</snapshots>
64+
</pluginRepository>
65+
</pluginRepositories>
66+
67+
""".lines().toList();
68+
69+
}

src/main/java/OfferingPlatformOverride.java

Lines changed: 44 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,29 @@
11
import io.quarkus.code.model.CodeQuarkusExtension;
22
import io.quarkus.code.model.Preset;
3+
import io.quarkus.code.model.ProjectDefinition;
34
import io.quarkus.code.service.PlatformOverride;
45
import io.quarkus.code.service.PlatformService;
56
import jakarta.inject.Inject;
67
import jakarta.inject.Singleton;
78

9+
import java.io.IOException;
10+
import java.nio.file.Files;
11+
import java.nio.file.Path;
12+
import java.nio.file.StandardOpenOption;
813
import java.util.List;
914
import java.util.Objects;
15+
import java.util.OptionalInt;
1016
import java.util.Set;
1117
import java.util.function.Function;
18+
import java.util.stream.Collectors;
19+
import java.util.stream.IntStream;
1220

1321
@Singleton
1422
public class OfferingPlatformOverride implements PlatformOverride {
1523

16-
public static final String ICONS_ASSETS_URL = "/assets/icons";
17-
18-
public static final List<Preset> IBM_PRESETS = List.of(
19-
// Some presets are duplicated to support platforms before and after the Big Reactive Renaming
20-
new Preset("rest-service", "REST service",
21-
ICONS_ASSETS_URL + "/ibm-presets/rest-service.svg",
22-
List.of("io.quarkus:quarkus-rest")),
23-
new Preset("db-service", "REST service with database",
24-
ICONS_ASSETS_URL + "/ibm-presets/db-service.svg",
25-
List.of("io.quarkus:quarkus-rest", "io.quarkus:quarkus-rest-jackson",
26-
"io.quarkus:quarkus-hibernate-orm-panache", "io.quarkus:quarkus-jdbc-postgresql")),
27-
new Preset("event-driven-kafka", "Event driven service with Kafka",
28-
ICONS_ASSETS_URL + "/ibm-presets/event-driven.svg",
29-
List.of("io.quarkus:quarkus-messaging-kafka")),
30-
new Preset("cli", "Command-line tool",
31-
ICONS_ASSETS_URL + "/ibm-presets/cli.svg",
32-
List.of("io.quarkus:quarkus-picocli")),
33-
new Preset("webapp-mvc", "Web app with Model-View-Controller",
34-
ICONS_ASSETS_URL + "/ibm-presets/webapp-mvc.svg",
35-
List.of("io.quarkiverse.renarde:quarkus-renarde", "io.quarkiverse.web-bundler:quarkus-web-bundler")),
36-
new Preset("webapp-npm", "Web app with NPM UI",
37-
ICONS_ASSETS_URL + "/ibm-presets/webapp-npm.svg",
38-
List.of("io.quarkus:quarkus-rest", "io.quarkus:quarkus-rest-jackson",
39-
"io.quarkiverse.quinoa:quarkus-quinoa")),
40-
new Preset("webapp-qute", "Web app with ServerSide Rendering",
41-
ICONS_ASSETS_URL + "/ibm-presets/webapp-qute.svg",
42-
List.of("io.quarkiverse.qute.web:quarkus-qute-web", "io.quarkiverse.web-bundler:quarkus-web-bundler")),
43-
new Preset("ai-infused", "AI Infused service",
44-
ICONS_ASSETS_URL + "/ibm-presets/ai-infused.svg",
45-
List.of("io.quarkiverse.langchain4j:quarkus-langchain4j-openai",
46-
"io.quarkiverse.langchain4j:quarkus-langchain4j-easy-rag")));
47-
48-
public static final List<Preset> REDHAT_CAMEL_PRESETS = List.of(
49-
// Some presets are duplicated to support platforms before and after the Big Reactive Renaming
50-
new Preset("web-service", "Web service",
51-
ICONS_ASSETS_URL + "/redhat-camel-presets/orange-rest_pos.svg",
52-
List.of("org.apache.camel.quarkus:camel-quarkus-rest",
53-
"org.apache.camel.quarkus:camel-quarkus-rest-openapi",
54-
"org.apache.camel.quarkus:camel-quarkus-cxf-soap",
55-
"io.quarkiverse.cxf:quarkus-cxf")),
56-
new Preset("db-service", "REST service with database",
57-
ICONS_ASSETS_URL + "/redhat-camel-presets/orange-db-service_pos.svg",
58-
List.of("org.apache.camel.quarkus:camel-quarkus-rest",
59-
"org.apache.camel.quarkus:camel-quarkus-aws2-ddb",
60-
"org.apache.camel.quarkus:camel-quarkus-cassandraql",
61-
"org.apache.camel.quarkus:camel-quarkus-jdbc",
62-
"org.apache.camel.quarkus:camel-quarkus-jpa",
63-
"org.apache.camel.quarkus:camel-quarkus-kudu",
64-
"org.apache.camel.quarkus:camel-quarkus-ldap",
65-
"org.apache.camel.quarkus:camel-quarkus-mongodb",
66-
"org.apache.camel.quarkus:camel-quarkus-mybatis",
67-
"org.apache.camel.quarkus:camel-quarkus-sql")),
68-
new Preset("event-driven-kafka", "Event driven service with Kafka",
69-
ICONS_ASSETS_URL + "/redhat-camel-presets/orange-event-driven-kafka_pos.svg",
70-
List.of("org.apache.camel.quarkus:camel-quarkus-kafka",
71-
"org.apache.camel.quarkus:camel-quarkus-jms")),
72-
new Preset("ai-infused", "AI Infused service",
73-
ICONS_ASSETS_URL + "/redhat-camel-presets/orange-ai-infused_pos.svg",
74-
List.of("org.apache.camel.quarkus:camel-quarkus-langchain4j-agent",
75-
"org.apache.camel.quarkus:camel-quarkus-langchain4j-chat",
76-
"org.apache.camel.quarkus:camel-quarkus-langchain4j-tokenizer",
77-
"org.apache.camel.quarkus:camel-quarkus-langchain4j-tools",
78-
"org.apache.camel.quarkus:camel-quarkus-langchain4j-web-search")));
79-
8024
@Inject
8125
OfferingConfig config;
8226

83-
private static final Set<String> TAGS = Set.of(
84-
"with:starter-code", "status:stable", "status:preview", "status:experimental", "status:deprecated",
85-
"support:full-support", "support:supported-in-jvm", "support:dev-support", "support:tech-preview",
86-
"support:deprecated");
87-
8827
@Override
8928
public Function<CodeQuarkusExtension, CodeQuarkusExtension> extensionMapper() {
9029
return Function.identity();
@@ -94,19 +33,52 @@ public Function<CodeQuarkusExtension, CodeQuarkusExtension> extensionMapper() {
9433
public List<Preset> presets() {
9534
switch (config.id()) {
9635
case "ibm":
97-
return IBM_PRESETS;
36+
return IBMConstants.IBM_PRESETS;
9837
case "redhat-camel":
99-
return REDHAT_CAMEL_PRESETS;
38+
return RedHatCamelConstants.REDHAT_CAMEL_PRESETS;
10039
default:
10140
return PlatformService.DEFAULT_PRESETS.stream()
10241
.map(p -> new Preset(p.key(), p.title(), p.icon().replace("_neg", "_pos"), p.extensions()))
10342
.toList();
10443
}
10544
}
10645

46+
@Override
47+
public void onNewProject(ProjectDefinition projectDefinition, Path dir) {
48+
final Path pom = dir.resolve("pom.xml");
49+
if (Files.isRegularFile(pom)) {
50+
try {
51+
final List<String> strings = Files.readAllLines(pom);
52+
if (strings.stream().anyMatch(s -> s.contains("<repositories>"))) {
53+
return;
54+
}
55+
OptionalInt lineNumber = IntStream.range(0, strings.size())
56+
.filter(i -> strings.get(i).contains("<dependencyManagement>"))
57+
.findFirst();
58+
if (lineNumber.isEmpty()) {
59+
throw new RuntimeException(
60+
"Platform generated pom.xml is not valid, please, report this error to the administrator.");
61+
}
62+
strings.addAll(lineNumber.getAsInt(), getRepositories());
63+
Files.writeString(pom, String.join("\n", strings), StandardOpenOption.TRUNCATE_EXISTING);
64+
} catch (IOException e) {
65+
throw new RuntimeException(e);
66+
}
67+
}
68+
}
69+
70+
private List<String> getRepositories() {
71+
switch (config.id()) {
72+
case "ibm":
73+
return IBMConstants.IBM_POM_REPOSITORIES;
74+
default:
75+
return RedHatConstants.REDHAT_POM_REPOSITORIES;
76+
}
77+
}
78+
10779
@Override
10880
public List<String> extensionTagsMapper(List<String> tags) {
109-
return tags.stream().map(this::mapTag).filter(Objects::nonNull).filter(TAGS::contains).toList();
81+
return tags.stream().map(this::mapTag).filter(Objects::nonNull).filter(GlobalConstants.TAGS::contains).toList();
11082
}
11183

11284
private String mapTag(String s) {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import io.quarkus.code.model.Preset;
2+
3+
import java.util.List;
4+
5+
public class RedHatCamelConstants {
6+
7+
private RedHatCamelConstants() {
8+
}
9+
10+
static final List<Preset> REDHAT_CAMEL_PRESETS = List.of(
11+
// Some presets are duplicated to support platforms before and after the Big Reactive Renaming
12+
new Preset("web-service", "Web service",
13+
GlobalConstants.ICONS_ASSETS_URL + "/redhat-camel-presets/orange-rest_pos.svg",
14+
List.of("org.apache.camel.quarkus:camel-quarkus-rest",
15+
"org.apache.camel.quarkus:camel-quarkus-rest-openapi",
16+
"org.apache.camel.quarkus:camel-quarkus-cxf-soap",
17+
"io.quarkiverse.cxf:quarkus-cxf")),
18+
new Preset("db-service", "REST service with database",
19+
GlobalConstants.ICONS_ASSETS_URL + "/redhat-camel-presets/orange-db-service_pos.svg",
20+
List.of("org.apache.camel.quarkus:camel-quarkus-rest",
21+
"org.apache.camel.quarkus:camel-quarkus-aws2-ddb",
22+
"org.apache.camel.quarkus:camel-quarkus-cassandraql",
23+
"org.apache.camel.quarkus:camel-quarkus-jdbc",
24+
"org.apache.camel.quarkus:camel-quarkus-jpa",
25+
"org.apache.camel.quarkus:camel-quarkus-kudu",
26+
"org.apache.camel.quarkus:camel-quarkus-ldap",
27+
"org.apache.camel.quarkus:camel-quarkus-mongodb",
28+
"org.apache.camel.quarkus:camel-quarkus-mybatis",
29+
"org.apache.camel.quarkus:camel-quarkus-sql")),
30+
new Preset("event-driven-kafka", "Event driven service with Kafka",
31+
GlobalConstants.ICONS_ASSETS_URL + "/redhat-camel-presets/orange-event-driven-kafka_pos.svg",
32+
List.of("org.apache.camel.quarkus:camel-quarkus-kafka",
33+
"org.apache.camel.quarkus:camel-quarkus-jms")),
34+
new Preset("ai-infused", "AI Infused service",
35+
GlobalConstants.ICONS_ASSETS_URL + "/redhat-camel-presets/orange-ai-infused_pos.svg",
36+
List.of("org.apache.camel.quarkus:camel-quarkus-langchain4j-agent",
37+
"org.apache.camel.quarkus:camel-quarkus-langchain4j-chat",
38+
"org.apache.camel.quarkus:camel-quarkus-langchain4j-tokenizer",
39+
"org.apache.camel.quarkus:camel-quarkus-langchain4j-tools",
40+
"org.apache.camel.quarkus:camel-quarkus-langchain4j-web-search")));
41+
}

src/main/java/RedHatConstants.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import io.quarkus.code.model.Preset;
2+
3+
import java.util.List;
4+
5+
public class RedHatConstants {
6+
7+
private RedHatConstants() {
8+
}
9+
10+
//language=xml
11+
static final List<String> REDHAT_POM_REPOSITORIES = """
12+
<repositories>
13+
<repository>
14+
<id>red-hat-enterprise-maven-repository</id>
15+
<url>https://maven.repository.redhat.com/ga/</url>
16+
<releases>
17+
<enabled>true</enabled>
18+
</releases>
19+
<snapshots>
20+
<enabled>true</enabled>
21+
</snapshots>
22+
</repository>
23+
</repositories>
24+
<pluginRepositories>
25+
<pluginRepository>
26+
<id>red-hat-enterprise-maven-repository</id>
27+
<url>https://maven.repository.redhat.com/ga/</url>
28+
<releases>
29+
<enabled>true</enabled>
30+
</releases>
31+
<snapshots>
32+
<enabled>true</enabled>
33+
</snapshots>
34+
</pluginRepository>
35+
</pluginRepositories>
36+
37+
""".lines().toList();
38+
}

src/main/resources/application.properties

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
io.quarkus.code.git-commit-id=${git.commit.id}
22

3-
quarkus.web-bundler.bundle.lib=true
43
quarkus.web-bundler.bundle.community-app=false
54

65
quarkus.web-bundler.bundle.ibm-app=true
7-
quarkus.web-bundler.bundle.ibm-app.key=ibm
86

97
quarkus.web-bundler.bundle.redhat-camel-app=true
10-
quarkus.web-bundler.bundle.redhat-camel-app.key=camel
8+
quarkus.web-bundler.bundle.redhat-camel-app.key=redhat-camel
119
quarkus.web-bundler.bundle.redhat-camel-app.dir=redhat-camel-app
1210

1311
quarkus.web-bundler.bundle.redhat-app=true
14-
quarkus.web-bundler.bundle.redhat-app.key=redhat
1512

1613
io.quarkus.code.offering=redhat
1714
io.quarkus.code.offering.support-tag=redhat-support
@@ -30,8 +27,8 @@ block-static-name=ibm
3027
%ibm.io.quarkus.code.ui.favicon=https://www.ibm.com/content/dam/adobe-cms/default-images/icon-32x32.png
3128
%ibm.block-static-name=redhat
3229

33-
io.quarkus.code.ui.id=${io.quarkus.code.offering}
34-
%redhat-camel.io.quarkus.code.ui.id=camel
30+
io.quarkus.code.ui.id=${io.quarkus.code.offering}-app
31+
%redhat-camel.io.quarkus.code.ui.id=redhat-camel
3532

3633
io.quarkus.code.quarkus-platforms.registry-id=registry.quarkus.redhat.com
3734
%test.io.quarkus.code.quarkus-platforms.registry-id=

src/main/resources/web/redhat-app/theme.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
@use "./red-hat-font.scss" as redhatFont;
2+
@include redhatFont.printRedHatFont(400, "Regular", $familyName: "RedHatText", $relative: false);
3+
@include redhatFont.printRedHatFont(700, "Medium", $familyName: "RedHatText", $relative: false);
14
@import url(https://fonts.googleapis.com/css?family=PT+Mono);
2-
@import "./red-hat-font.scss";
3-
@include printRedHatFont(400, "Regular", $familyName: "RedHatText", $relative: false);
4-
@include printRedHatFont(700, "Medium", $familyName: "RedHatText", $relative: false);
5+
56

67
:root {
78

src/main/resources/web/redhat-camel-app/theme.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
@use "./red-hat-font.scss" as redhatFont;
2+
@include redhatFont.printRedHatFont(400, "Regular", $familyName: "RedHatText", $relative: false);
3+
@include redhatFont.printRedHatFont(700, "Medium", $familyName: "RedHatText", $relative: false);
14
@import url(https://fonts.googleapis.com/css?family=PT+Mono);
2-
@import "./red-hat-font.scss";
3-
@include printRedHatFont(400, "Regular", $familyName: "RedHatText", $relative: false);
4-
@include printRedHatFont(700, "Medium", $familyName: "RedHatText", $relative: false);
5+
56

67
:root {
78

0 commit comments

Comments
 (0)