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
9 changes: 8 additions & 1 deletion deploy/build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ GIT_REV_SHORT=$(git rev-parse --short=7 HEAD)
IMAGE=${IMAGE-"quay.io/redhat-developer/code-quarkus"}
IMAGE_TAG=${IMAGE_TAG-$GIT_REV_SHORT}

docker build --compress -f docker/Dockerfile.redhat-app.multistage --build-arg MAVEN_BUILD_EXTRA_ARGS="-Dgit.commit.id=$GIT_REV" -t "${IMAGE}:${IMAGE_TAG}" .
STAGE=false

if [[ $(git --no-pager log --oneline -1) == *[STAGE]* ]]; then
echo "This commit is flagged with [STAGE] and won't go to production"
STAGE=true
fi

docker build --compress -f docker/Dockerfile.redhat-app.multistage --build-arg MAVEN_BUILD_EXTRA_ARGS="-Dgit.commit.id=$GIT_REV -Dio.quarkus.code.build.stage=$STAGE" -t "${IMAGE}:${IMAGE_TAG}" .

if [[ -n "$QUAY_USER" && -n "$QUAY_TOKEN" ]]; then
DOCKER_CONF="$PWD/.docker"
Expand Down
12 changes: 6 additions & 6 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ export QUARKUS_REGISTRY_REGISTRY_QUARKUS_IO_RECOMMEND_STREAMS_FROM_COM_REDHAT_QU


dev-rh:
export IO_QUARKUS_CODE_OFFERING_SUPPORT_TAG="redhat-support"
export QUARKUS_REGISTRY_REGISTRY_QUARKUS_REDHAT_COM_OFFERING="redhat"
quarkus dev -Dquarkus.profile=dev,redhat

dev-ibm:
export IO_QUARKUS_CODE_OFFERING_SUPPORT_TAG="ibm-support"
export QUARKUS_REGISTRY_REGISTRY_QUARKUS_REDHAT_COM_OFFERING="ibm"
quarkus dev -Dquarkus.profile=dev,ibm

dev-camel:
export IO_QUARKUS_CODE_OFFERING_SUPPORT_TAG="camel-support"
export QUARKUS_REGISTRY_REGISTRY_QUARKUS_REDHAT_COM_OFFERING="redhat-camel"
quarkus dev -Dquarkus.profile=dev,redhat-camel
build:
quarkus build -DskipTests
start-ibm:
export IO_QUARKUS_CODE_OFFERING_SUPPORT_TAG="ibm-support"
export QUARKUS_REGISTRY_REGISTRY_QUARKUS_REDHAT_COM_OFFERING="ibm"
QUARKUS_PROFILE="prod,ibm" java -jar target/quarkus-app/quarkus-run.jar
start-rh:
export IO_QUARKUS_CODE_OFFERING_SUPPORT_TAG="redhat-support"
export QUARKUS_REGISTRY_REGISTRY_QUARKUS_REDHAT_COM_OFFERING="redhat"
QUARKUS_PROFILE="prod,redhat" java -jar target/quarkus-app/quarkus-run.jar
start-camel:
export IO_QUARKUS_CODE_OFFERING_SUPPORT_TAG="redhat-camel-support"
export QUARKUS_REGISTRY_REGISTRY_QUARKUS_REDHAT_COM_OFFERING="redhat-camel"
QUARKUS_PROFILE="prod,redhat-camel" java -jar target/quarkus-app/quarkus-run.jar

3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.quarkus.code</groupId>
<artifactId>code-quarkus-parent</artifactId>
<version>59</version>
<version>61</version>
</parent>

<artifactId>code-quarkus-redhat-app</artifactId>
Expand Down Expand Up @@ -151,6 +151,7 @@
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>

</execution>
</executions>
</plugin>
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/GlobalConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java.util.Set;

class GlobalConstants {

private GlobalConstants() {
}

static final String ICONS_ASSETS_URL = "/assets/icons";

static final Set<String> TAGS = Set.of(
"with:starter-code", "status:stable", "status:preview", "status:experimental", "status:deprecated",
"support:full-support", "support:supported-in-jvm", "support:dev-support", "support:tech-preview",
"support:deprecated");
}
69 changes: 69 additions & 0 deletions src/main/java/IBMConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import io.quarkus.code.model.Preset;

import java.util.List;

class IBMConstants {

private IBMConstants() {
}

public static final List<Preset> IBM_PRESETS = List.of(
// Some presets are duplicated to support platforms before and after the Big Reactive Renaming
new Preset("rest-service", "REST service",
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/rest-service.svg",
List.of("io.quarkus:quarkus-rest")),
new Preset("db-service", "REST service with database",
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/db-service.svg",
List.of("io.quarkus:quarkus-rest", "io.quarkus:quarkus-rest-jackson",
"io.quarkus:quarkus-hibernate-orm-panache", "io.quarkus:quarkus-jdbc-postgresql")),
new Preset("event-driven-kafka", "Event driven service with Kafka",
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/event-driven.svg",
List.of("io.quarkus:quarkus-messaging-kafka")),
new Preset("cli", "Command-line tool",
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/cli.svg",
List.of("io.quarkus:quarkus-picocli")),
new Preset("webapp-mvc", "Web app with Model-View-Controller",
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/webapp-mvc.svg",
List.of("io.quarkiverse.renarde:quarkus-renarde", "io.quarkiverse.web-bundler:quarkus-web-bundler")),
new Preset("webapp-npm", "Web app with NPM UI",
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/webapp-npm.svg",
List.of("io.quarkus:quarkus-rest", "io.quarkus:quarkus-rest-jackson",
"io.quarkiverse.quinoa:quarkus-quinoa")),
new Preset("webapp-qute", "Web app with ServerSide Rendering",
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/webapp-qute.svg",
List.of("io.quarkiverse.qute.web:quarkus-qute-web", "io.quarkiverse.web-bundler:quarkus-web-bundler")),
new Preset("ai-infused", "AI Infused service",
GlobalConstants.ICONS_ASSETS_URL + "/ibm-presets/ai-infused.svg",
List.of("io.quarkiverse.langchain4j:quarkus-langchain4j-openai",
"io.quarkiverse.langchain4j:quarkus-langchain4j-easy-rag")));

//language=xml
static final List<String> IBM_POM_REPOSITORIES = """
<repositories>
<repository>
<id>ibm-enterprise-maven-repository</id>
<url>https://maven.repository.ibm.com/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>ibm-enterprise-maven-repository</id>
<url>https://maven.repository.ibm.com/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

""".lines().toList();

}
118 changes: 45 additions & 73 deletions src/main/java/OfferingPlatformOverride.java
Original file line number Diff line number Diff line change
@@ -1,90 +1,27 @@
import io.quarkus.code.model.CodeQuarkusExtension;
import io.quarkus.code.model.Preset;
import io.quarkus.code.model.ProjectDefinition;
import io.quarkus.code.service.PlatformOverride;
import io.quarkus.code.service.PlatformService;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.OptionalInt;
import java.util.function.Function;
import java.util.stream.IntStream;

@Singleton
public class OfferingPlatformOverride implements PlatformOverride {

public static final String ICONS_ASSETS_URL = "/assets/icons";

public static final List<Preset> IBM_PRESETS = List.of(
// Some presets are duplicated to support platforms before and after the Big Reactive Renaming
new Preset("rest-service", "REST service",
ICONS_ASSETS_URL + "/ibm-presets/rest-service.svg",
List.of("io.quarkus:quarkus-rest")),
new Preset("db-service", "REST service with database",
ICONS_ASSETS_URL + "/ibm-presets/db-service.svg",
List.of("io.quarkus:quarkus-rest", "io.quarkus:quarkus-rest-jackson",
"io.quarkus:quarkus-hibernate-orm-panache", "io.quarkus:quarkus-jdbc-postgresql")),
new Preset("event-driven-kafka", "Event driven service with Kafka",
ICONS_ASSETS_URL + "/ibm-presets/event-driven.svg",
List.of("io.quarkus:quarkus-messaging-kafka")),
new Preset("cli", "Command-line tool",
ICONS_ASSETS_URL + "/ibm-presets/cli.svg",
List.of("io.quarkus:quarkus-picocli")),
new Preset("webapp-mvc", "Web app with Model-View-Controller",
ICONS_ASSETS_URL + "/ibm-presets/webapp-mvc.svg",
List.of("io.quarkiverse.renarde:quarkus-renarde", "io.quarkiverse.web-bundler:quarkus-web-bundler")),
new Preset("webapp-npm", "Web app with NPM UI",
ICONS_ASSETS_URL + "/ibm-presets/webapp-npm.svg",
List.of("io.quarkus:quarkus-rest", "io.quarkus:quarkus-rest-jackson",
"io.quarkiverse.quinoa:quarkus-quinoa")),
new Preset("webapp-qute", "Web app with ServerSide Rendering",
ICONS_ASSETS_URL + "/ibm-presets/webapp-qute.svg",
List.of("io.quarkiverse.qute.web:quarkus-qute-web", "io.quarkiverse.web-bundler:quarkus-web-bundler")),
new Preset("ai-infused", "AI Infused service",
ICONS_ASSETS_URL + "/ibm-presets/ai-infused.svg",
List.of("io.quarkiverse.langchain4j:quarkus-langchain4j-openai",
"io.quarkiverse.langchain4j:quarkus-langchain4j-easy-rag")));

public static final List<Preset> REDHAT_CAMEL_PRESETS = List.of(
// Some presets are duplicated to support platforms before and after the Big Reactive Renaming
new Preset("web-service", "Web service",
ICONS_ASSETS_URL + "/redhat-camel-presets/orange-rest_pos.svg",
List.of("org.apache.camel.quarkus:camel-quarkus-rest",
"org.apache.camel.quarkus:camel-quarkus-rest-openapi",
"org.apache.camel.quarkus:camel-quarkus-cxf-soap",
"io.quarkiverse.cxf:quarkus-cxf")),
new Preset("db-service", "REST service with database",
ICONS_ASSETS_URL + "/redhat-camel-presets/orange-db-service_pos.svg",
List.of("org.apache.camel.quarkus:camel-quarkus-rest",
"org.apache.camel.quarkus:camel-quarkus-aws2-ddb",
"org.apache.camel.quarkus:camel-quarkus-cassandraql",
"org.apache.camel.quarkus:camel-quarkus-jdbc",
"org.apache.camel.quarkus:camel-quarkus-jpa",
"org.apache.camel.quarkus:camel-quarkus-kudu",
"org.apache.camel.quarkus:camel-quarkus-ldap",
"org.apache.camel.quarkus:camel-quarkus-mongodb",
"org.apache.camel.quarkus:camel-quarkus-mybatis",
"org.apache.camel.quarkus:camel-quarkus-sql")),
new Preset("event-driven-kafka", "Event driven service with Kafka",
ICONS_ASSETS_URL + "/redhat-camel-presets/orange-event-driven-kafka_pos.svg",
List.of("org.apache.camel.quarkus:camel-quarkus-kafka",
"org.apache.camel.quarkus:camel-quarkus-jms")),
new Preset("ai-infused", "AI Infused service",
ICONS_ASSETS_URL + "/redhat-camel-presets/orange-ai-infused_pos.svg",
List.of("org.apache.camel.quarkus:camel-quarkus-langchain4j-agent",
"org.apache.camel.quarkus:camel-quarkus-langchain4j-chat",
"org.apache.camel.quarkus:camel-quarkus-langchain4j-tokenizer",
"org.apache.camel.quarkus:camel-quarkus-langchain4j-tools",
"org.apache.camel.quarkus:camel-quarkus-langchain4j-web-search")));

@Inject
OfferingConfig config;

private static final Set<String> TAGS = Set.of(
"with:starter-code", "status:stable", "status:preview", "status:experimental", "status:deprecated",
"support:full-support", "support:supported-in-jvm", "support:dev-support", "support:tech-preview",
"support:deprecated");

@Override
public Function<CodeQuarkusExtension, CodeQuarkusExtension> extensionMapper() {
return Function.identity();
Expand All @@ -94,19 +31,54 @@ public Function<CodeQuarkusExtension, CodeQuarkusExtension> extensionMapper() {
public List<Preset> presets() {
switch (config.id()) {
case "ibm":
return IBM_PRESETS;
return IBMConstants.IBM_PRESETS;
case "redhat-camel":
return REDHAT_CAMEL_PRESETS;
return RedHatCamelConstants.REDHAT_CAMEL_PRESETS;
default:
return PlatformService.DEFAULT_PRESETS.stream()
.map(p -> new Preset(p.key(), p.title(), p.icon().replace("_neg", "_pos"), p.extensions()))
.toList();
}
}

@Override
public void onNewProject(ProjectDefinition projectDefinition, Path dir) {
final List<String> repositories = getRepositories();
if (repositories == null) {
return;
}
final Path pom = dir.resolve("pom.xml");
if (Files.isRegularFile(pom)) {
try {
final List<String> pomLines = Files.readAllLines(pom);
if (pomLines.stream().anyMatch(s -> s.contains("<repositories>"))) {
return;
}
OptionalInt lineNumber = IntStream.range(0, pomLines.size())
.filter(i -> pomLines.get(i).contains("<dependencyManagement>"))
.findFirst();
if (lineNumber.isEmpty()) {
throw new RuntimeException(
"Platform generated pom.xml is not valid, please, report this error to the administrator.");
}
pomLines.addAll(lineNumber.getAsInt(), repositories);
Files.writeString(pom, String.join("\n", pomLines), StandardOpenOption.TRUNCATE_EXISTING);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

private List<String> getRepositories() {
return switch (config.id()) {
case "ibm" -> IBMConstants.IBM_POM_REPOSITORIES;
default -> null;
};
}

@Override
public List<String> extensionTagsMapper(List<String> tags) {
return tags.stream().map(this::mapTag).filter(Objects::nonNull).filter(TAGS::contains).toList();
return tags.stream().map(this::mapTag).filter(Objects::nonNull).filter(GlobalConstants.TAGS::contains).toList();
}

private String mapTag(String s) {
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/RedHatCamelConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import io.quarkus.code.model.Preset;

import java.util.List;

public class RedHatCamelConstants {

private RedHatCamelConstants() {
}

static final List<Preset> REDHAT_CAMEL_PRESETS = List.of(
// Some presets are duplicated to support platforms before and after the Big Reactive Renaming
new Preset("web-service", "Web service",
GlobalConstants.ICONS_ASSETS_URL + "/redhat-camel-presets/orange-rest_pos.svg",
List.of("org.apache.camel.quarkus:camel-quarkus-rest",
"org.apache.camel.quarkus:camel-quarkus-rest-openapi",
"org.apache.camel.quarkus:camel-quarkus-cxf-soap",
"io.quarkiverse.cxf:quarkus-cxf")),
new Preset("db-service", "REST service with database",
GlobalConstants.ICONS_ASSETS_URL + "/redhat-camel-presets/orange-db-service_pos.svg",
List.of("org.apache.camel.quarkus:camel-quarkus-rest",
"org.apache.camel.quarkus:camel-quarkus-aws2-ddb",
"org.apache.camel.quarkus:camel-quarkus-cassandraql",
"org.apache.camel.quarkus:camel-quarkus-jdbc",
"org.apache.camel.quarkus:camel-quarkus-jpa",
"org.apache.camel.quarkus:camel-quarkus-kudu",
"org.apache.camel.quarkus:camel-quarkus-ldap",
"org.apache.camel.quarkus:camel-quarkus-mongodb",
"org.apache.camel.quarkus:camel-quarkus-mybatis",
"org.apache.camel.quarkus:camel-quarkus-sql")),
new Preset("event-driven-kafka", "Event driven service with Kafka",
GlobalConstants.ICONS_ASSETS_URL + "/redhat-camel-presets/orange-event-driven-kafka_pos.svg",
List.of("org.apache.camel.quarkus:camel-quarkus-kafka",
"org.apache.camel.quarkus:camel-quarkus-jms")),
new Preset("ai-infused", "AI Infused service",
GlobalConstants.ICONS_ASSETS_URL + "/redhat-camel-presets/orange-ai-infused_pos.svg",
List.of("org.apache.camel.quarkus:camel-quarkus-langchain4j-agent",
"org.apache.camel.quarkus:camel-quarkus-langchain4j-chat",
"org.apache.camel.quarkus:camel-quarkus-langchain4j-tokenizer",
"org.apache.camel.quarkus:camel-quarkus-langchain4j-tools",
"org.apache.camel.quarkus:camel-quarkus-langchain4j-web-search")));
}
38 changes: 38 additions & 0 deletions src/main/java/RedHatConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import io.quarkus.code.model.Preset;

import java.util.List;

public class RedHatConstants {

private RedHatConstants() {
}

//language=xml
static final List<String> REDHAT_POM_REPOSITORIES = """
<repositories>
<repository>
<id>red-hat-enterprise-maven-repository</id>
<url>https://maven.repository.redhat.com/ga/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>red-hat-enterprise-maven-repository</id>
<url>https://maven.repository.redhat.com/ga/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
""".lines().toList();
}
Loading
Loading