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

archetypes generating poorly formatted code #6622

Merged
merged 1 commit into from
Apr 17, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions archetypes/helidon/src/main/archetype/common/docker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ docker build -t {{artifactId}} .

## Running the Docker Image

{{#docker-run-readme-section}}{{.}}
{{#docker-run-readme-section}}
{{.}}
{{/docker-run-readme-section}}
{{^docker-run-readme-section}}
```
Expand All @@ -91,7 +92,8 @@ Exercise the application as described above.
<![CDATA[
## Building a Native Image

{{#native-sections}}{{.}}
{{#native-sections}}
{{.}}
{{/native-sections}}
]]>
</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

## Build and run

{{#readme-run-notes}}{{.}}
{{#readme-run-notes}}
{{.}}
{{/readme-run-notes}}

{{#readme-run-commands}}{{.}}
{{#readme-run-commands}}
{{.}}
{{/readme-run-commands}}
{{^readme-run-commands}}
With JDK19+
Expand All @@ -18,8 +20,10 @@ java --enable-preview -jar target/{{artifactId}}.jar
{{/readme-run-commands}}

## Exercise the application
{{#readme-exercise-the-application}}{{.}}
{{#readme-exercise-the-application}}
{{.}}
{{/readme-exercise-the-application}}

{{#readme-sections}}{{.}}
{{#readme-sections}}
{{.}}
{{/readme-sections}}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
</execution>
</executions>
</plugin>
{{#maven-plugins}}{{.}}
{{#maven-plugins}}
{{.}}
{{/maven-plugins}}
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics
<value template="mustache" order="0"><![CDATA[
HealthSupport health = HealthSupport.builder()
.add(HealthChecks.healthChecks()) // Adds a convenient set of checks
{{#Main-healthBuilder}}{{.}}
{{#Main-healthBuilder}}
{{.}}
{{/Main-healthBuilder}}
.build();]]>
</value>
Expand Down
3 changes: 2 additions & 1 deletion archetypes/helidon/src/main/archetype/common/packaging.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ kubectl get pods # Verify connectivity to cluster
{{#k8s-readme-sections}}
{{#first}}

{{/first}}{{.}}
{{/first}}
{{.}}
{{/k8s-readme-sections}}

### Deploy the application to Kubernetes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ server.host=0.0.0.0
# Change the following to true to enable the optional MicroProfile Metrics REST.request metrics
metrics.rest-request.enabled=false

{{#microprofile-config-entries}}{{.}}
{{#microprofile-config-entries}}
{{.}}
{{/microprofile-config-entries}}

{{#database-hikari}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
{{#security}}
security:
providers:
{{#providers-config-entries}}{{.}}
{{#providers-config-entries}}
{{.}}
{{/providers-config-entries}}
web-server:
# protected paths on the web server - do not include paths served by Jersey, as those are protected directly
paths:
{{#paths-config-entries}}{{.}}
{{#paths-config-entries}}
{{.}}
{{/paths-config-entries}}
{{/security}}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ handlers=io.helidon.logging.jul.HelidonConsoleHandler
{{#oci-logging-entries}}
{{#first}}

{{/first}}{{.}}
{{/first}}
{{.}}
{{/oci-logging-entries}}

# HelidonConsoleHandler uses a SimpleFormatter subclass that replaces "!thread!" with the current thread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ import {{.}};
{{/helidon-test}}
class MainTest {
{{#helidon-test}}
{{#MainTest-static-fields}}{{.}}
{{#MainTest-static-fields}}
{{.}}
{{/MainTest-static-fields}}

@Inject
private WebTarget target;

{{#MainTest-methods}}{{.}}
{{#MainTest-methods}}
{{.}}
{{/MainTest-methods}}
{{/helidon-test}}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import org.eclipse.microprofile.config.inject.ConfigProperty;
*/
@Path("/simple-greet")
public class SimpleGreetResource {
{{#SimpleGreetResource-static-fields}}{{.}}
{{#SimpleGreetResource-static-fields}}
{{.}}
{{/SimpleGreetResource-static-fields}}
private final String message;

Expand All @@ -49,7 +50,8 @@ public class SimpleGreetResource {
return message;
}

{{#SimpleGreetService-methods}}{{.}}
{{#SimpleGreetService-methods}}
{{.}}
{{/SimpleGreetService-methods}}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import org.eclipse.microprofile.config.inject.ConfigProperty;
*/
@Path("/simple-greet")
public class SimpleGreetResource {
{{#SimpleGreetResource-static-fields}}{{.}}
{{#SimpleGreetResource-static-fields}}
{{.}}
{{/SimpleGreetResource-static-fields}}
private static final JsonBuilderFactory JSON = Json.createBuilderFactory(Collections.emptyMap());

Expand All @@ -54,7 +55,8 @@ public class SimpleGreetResource {
.build();
}

{{#SimpleGreetService-methods}}{{.}}
{{#SimpleGreetService-methods}}
{{.}}
{{/SimpleGreetService-methods}}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import org.eclipse.microprofile.config.inject.ConfigProperty;
*/
@Path("/simple-greet")
public class SimpleGreetResource {
{{#SimpleGreetResource-static-fields}}{{.}}
{{#SimpleGreetResource-static-fields}}
{{.}}
{{/SimpleGreetResource-static-fields}}

private final String message;
Expand All @@ -47,7 +48,8 @@ public class SimpleGreetResource {
return String.format("%s %s!", message, "World");
}

{{#SimpleGreetService-methods}}{{.}}
{{#SimpleGreetService-methods}}
{{.}}
{{/SimpleGreetService-methods}}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ public final class Main {
* Updates HTTP Routing.
*/
static void routing(HttpRouting.Builder routing) {
{{#Main-routing}}{{.}}
{{#Main-routing}}
{{.}}
{{/Main-routing}}

routing{{#Main-routing-builder}}{{.}}{{#last}}; {{/last}}
routing{{#Main-routing-builder}}
{{.}}{{#last}}; {{/last}}
{{/Main-routing-builder}}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ server:
port: 8080
host: 0.0.0.0

{{#application-yaml-entries}}{{.}}
{{#application-yaml-entries}}
{{.}}
{{/application-yaml-entries}}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ abstract class AbstractMainTest {
Main.routing(builder);
}

{{#Abstract-tests}}{{.}}
{{#Abstract-tests}}
{{.}}
{{/Abstract-tests}}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ server:
port: 8080
host: 0.0.0.0

{{#config-test}}{{.}}
{{#config-test}}
{{.}}
{{/config-test}}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public final class Main {

WebServer server = WebServer.builder(createRouting(config))
.config(config.get("server"))
{{#Main-serverBuilder}}{{.}}
{{#Main-serverBuilder}}
{{.}}
{{/Main-serverBuilder}}
.build();

Expand All @@ -76,14 +77,17 @@ public final class Main {
* @param config configuration of this server
*/
private static Routing createRouting(Config config) {
{{#Main-createRouting}}{{.}}
{{#Main-createRouting}}
{{.}}
{{/Main-createRouting}}

Routing.Builder builder = Routing.builder()
{{#Main-routingBuilder}}{{.}}{{#last}}; {{/last}}
{{#Main-routingBuilder}}
{{.}}{{#last}}; {{/last}}
{{/Main-routingBuilder}}

{{#Main-security-routing-section}}{{.}}
{{#Main-security-routing-section}}
{{.}}
{{/Main-security-routing-section}}

return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ server:
port: 8080
host: 0.0.0.0

{{#application-yaml-entries}}{{.}}
{{#application-yaml-entries}}
{{.}}
{{/application-yaml-entries}}

{{#security}}
security:
providers:
{{#providers-config-entries}}{{.}}
{{#providers-config-entries}}
{{.}}
{{/providers-config-entries}}
web-server:
# protected paths on the web server - do not include paths served by Jersey, as those are protected directly
paths:
{{#paths-config-entries}}{{.}}
{{#paths-config-entries}}
{{.}}
{{/paths-config-entries}}
{{/security}}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {{.}};

class MainTest {

{{#MainTest-static-fields}}{{.}}
{{#MainTest-static-fields}}
{{.}}
{{/MainTest-static-fields}}

private static WebServer webServer;
Expand All @@ -31,7 +32,8 @@ class MainTest {

webClient = WebClient.builder()
.baseUri("http://localhost:" + webServer.port())
{{#MainTest-clientBuilder}}{{.}}
{{#MainTest-clientBuilder}}
{{.}}
{{/MainTest-clientBuilder}}
.build();
}
Expand All @@ -45,6 +47,7 @@ class MainTest {
}
}

{{#MainTest-methods}}{{.}}
{{#MainTest-methods}}
{{.}}
{{/MainTest-methods}}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ app:
security:
enabled: false

{{#config-test}}{{.}}
{{#config-test}}
{{.}}
{{/config-test}}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import io.helidon.reactive.webserver.Service;
public class SimpleGreetService implements Service {

private static final Logger LOGGER = Logger.getLogger(SimpleGreetService.class.getName());
{{#SimpleGreetResource-static-fields}}{{.}}
{{#SimpleGreetResource-static-fields}}
{{.}}
{{/SimpleGreetResource-static-fields}}

private final String greeting;
Expand All @@ -31,7 +32,8 @@ public class SimpleGreetService implements Service {
greeting = config.get("app.greeting").asString().orElse("Ciao");
}

{{#SimpleGreetResource-constructor}}{{.}}
{{#SimpleGreetResource-constructor}}
{{.}}
{{/SimpleGreetResource-constructor}}

/**
Expand All @@ -42,7 +44,8 @@ public class SimpleGreetService implements Service {
@Override
public void update(Routing.Rules rules) {
rules.get("/", this::getDefaultMessageHandler);
{{#SimpleGreetResource-update}}{{.}}
{{#SimpleGreetResource-update}}
{{.}}
{{/SimpleGreetResource-update}}
}

Expand All @@ -62,6 +65,7 @@ public class SimpleGreetService implements Service {
response.send(message);
}

{{#SimpleGreetService-methods}}{{.}}
{{#SimpleGreetService-methods}}
{{.}}
{{/SimpleGreetService-methods}}
}