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 Helidon Archetype generates broken projects #6721

Merged
merged 1 commit into from
Apr 28, 2023
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
6 changes: 4 additions & 2 deletions archetypes/helidon/filters.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2022 Oracle and/or its affiliates.
# Copyright (c) 2022, 2023 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,7 +40,9 @@ metrics=!${metrics} || (${metrics.builtin})
tracing=!${tracing} || (${tracing} && ${metrics.provider} == 'microprofile')

# group extra options
extra=${extra} == [] || ${extra} == ['cors', 'webclient', 'fault-tolerance']
extra=${extra} == [] || \
(${flavor} == 'se' && ${extra} == ['cors', 'webclient', 'fault-tolerance']) || \
(${flavor} == 'mp' && ${extra} == ['cors', 'fault-tolerance'])

# group docker, k8s and v8o
packaging=!(${docker} || ${k8s} || ${v8o}) || (${docker} && ${k8s} && ${v8o})
Expand Down
24 changes: 23 additions & 1 deletion archetypes/helidon/src/main/archetype/common/extra.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2022 Oracle and/or its affiliates.
Copyright (c) 2022, 2023 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -57,6 +57,10 @@
<value key="groupId">io.helidon.microprofile</value>
<value key="artifactId">helidon-microprofile-fault-tolerance</value>
</map>
<map>
<value key="groupId">io.helidon.webclient</value>
<value key="artifactId">helidon-webclient</value>
</map>
</list>
<list key="Main-helidon-imports">
<value>io.helidon.common.http.Http</value>
Expand Down Expand Up @@ -96,11 +100,29 @@
<value key="groupId">io.helidon.microprofile</value>
<value key="artifactId">helidon-microprofile-cors</value>
</map>
<map if="${flavor} == 'mp'">
<value key="groupId">io.helidon.webclient</value>
<value key="artifactId">helidon-webclient</value>
</map>
<map if="${flavor} == 'mp'">
<value key="groupId">io.helidon.webclient</value>
<value key="artifactId">helidon-webclient</value>
</map>
<map if="${flavor} == 'mp'">
<value key="groupId">io.helidon.microprofile.metrics</value>
<value key="artifactId">helidon-microprofile-metrics</value>
</map>
<map if="${flavor} == 'se'">
<value key="groupId">io.helidon.webserver</value>
<value key="artifactId">helidon-webserver-cors</value>
</map>
</list>
<list key="FileServiceTest-annotations" if="${media} contains 'multipart'">
<value>@AddExtension(CorsCdiExtension.class)</value>
</list>
<list key="FileServiceTest-helidon-imports" if="${media} contains 'multipart'">
<value>io.helidon.microprofile.cors.CorsCdiExtension</value>
</list>
<list key="SimpleGreetService-imports" if="${flavor} == 'mp'">
<value>io.helidon.microprofile.cors.CrossOrigin</value>
<value>jakarta.ws.rs.OPTIONS</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@ curl -s -X GET http://localhost:8080/health
<list key="readme-sections">
<value file="/common/files/README.jaeger.md"/>
</list>
<list key="test-config-properties">
<value>tracing.global=false</value>
</list>
</model>
</output>
</option>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{#test-config-properties}}
{{.}}
{{/test-config-properties}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

{{#FileServiceTest-helidon-imports}}
import {{.}};
{{/FileServiceTest-helidon-imports}}
import io.helidon.microprofile.server.JaxRsCdiExtension;
import io.helidon.microprofile.server.ServerCdiExtension;
import io.helidon.microprofile.tests.junit5.AddBean;
Expand Down Expand Up @@ -46,6 +49,9 @@ import static org.hamcrest.Matchers.notNullValue;
@AddExtension(ServerCdiExtension.class)
@AddExtension(JaxRsCdiExtension.class)
@AddExtension(CdiComponentProvider.class)
{{#FileServiceTest-annotations}}
{{.}}
{{/FileServiceTest-annotations}}
@AddBean(FileService.class)
@AddBean(FileStorage.class)
@AddBean(MultiPartFeatureProvider.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import io.helidon.config.Config;
import io.helidon.microprofile.server.Server;
import io.helidon.webclient.WebClient;
import io.helidon.webclient.WebClientRequestBuilder;
import io.helidon.webclient.WebClientRequestHeaders;
import io.helidon.webclient.WebClientResponse;
import io.helidon.webclient.WebClientResponseHeaders;
import io.helidon.webserver.cors.CrossOriginConfig;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -16,7 +18,11 @@ import java.util.List;
import java.util.Optional;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;

class TestCORS {

Expand Down Expand Up @@ -47,16 +53,16 @@ class TestCORS {
@Test
void testAnonymousGreetWithCors() {
WebClientRequestBuilder builder = client.get();
WebClientRequestHeaders headers = builder.headers();
Headers headers = builder.headers();
headers.add("Origin", "http://foo.com");
headers.add("Host", "here.com");

WebClientResponse r = getResponse(builder);
assertThat("HTTP response", r.status().code(), is(200));
String payload = fromPayload(r);
assertThat("HTTP response payload", payload, is("{\"message\":\"Hello World!\"}"));
WebClientResponseHeaders resHeaders = r.headers();
Optional<String> allowOrigin = resHeaders.value(Http.Header.ACCESS_CONTROL_ALLOW_ORIGIN);
assertThat("HTTP response payload", payload.contains("Hello World!"), is(true));
headers = r.headers();
Optional<String> allowOrigin = headers.value(CrossOriginConfig.ACCESS_CONTROL_ALLOW_ORIGIN);
assertThat("Expected CORS header " + CrossOriginConfig.ACCESS_CONTROL_ALLOW_ORIGIN + " is present",
allowOrigin.isPresent(), is(true));
assertThat("CORS header " + CrossOriginConfig.ACCESS_CONTROL_ALLOW_ORIGIN, allowOrigin.get(), is("http://foo.com"));
Expand Down