Skip to content

Commit

Permalink
Remove codestarts shared-data overrides from example codestarts
Browse files Browse the repository at this point in the history
Add logs to codestarts
  • Loading branch information
ia3andy committed Sep 2, 2020
1 parent 7bb9b3b commit 6c2f87e
Show file tree
Hide file tree
Showing 54 changed files with 430 additions and 298 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.gradle.api.logging.Logger;

import io.quarkus.platform.tools.MessageWriter;
import io.quarkus.devtools.messagewriter.MessageWriter;

public class GradleMessageWriter implements MessageWriter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

import io.quarkus.devtools.commands.AddExtensions;
import io.quarkus.devtools.commands.data.QuarkusCommandOutcome;
import io.quarkus.devtools.messagewriter.MessageWriter;
import io.quarkus.devtools.project.QuarkusProject;
import io.quarkus.platform.tools.MessageWriter;
import io.quarkus.registry.DefaultExtensionRegistry;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.apache.maven.plugins.annotations.Parameter;

import io.quarkus.devtools.commands.ListExtensions;
import io.quarkus.devtools.messagewriter.MessageWriter;
import io.quarkus.devtools.project.QuarkusProject;
import io.quarkus.platform.tools.MessageWriter;
import io.quarkus.registry.DefaultExtensionRegistry;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException;
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
import io.quarkus.bootstrap.resolver.maven.workspace.ModelUtils;
import io.quarkus.devtools.messagewriter.MessageWriter;
import io.quarkus.devtools.project.BuildTool;
import io.quarkus.devtools.project.QuarkusProject;
import io.quarkus.platform.descriptor.CombinedQuarkusPlatformDescriptor;
import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor;
import io.quarkus.platform.descriptor.resolver.json.QuarkusJsonPlatformDescriptorResolver;
import io.quarkus.platform.tools.MessageWriter;
import io.quarkus.platform.tools.ToolsConstants;
import io.quarkus.platform.tools.maven.MojoMessageWriter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

import io.quarkus.devtools.commands.RemoveExtensions;
import io.quarkus.devtools.commands.data.QuarkusCommandOutcome;
import io.quarkus.devtools.messagewriter.MessageWriter;
import io.quarkus.devtools.project.QuarkusProject;
import io.quarkus.platform.tools.MessageWriter;

/**
* Allow removing an extension from an existing pom.xml file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.apache.maven.plugin.logging.Log;

import io.quarkus.platform.tools.MessageWriter;
import io.quarkus.devtools.messagewriter.MessageWriter;

public class MojoMessageWriter implements MessageWriter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@

import io.quarkus.dependencies.Category;
import io.quarkus.dependencies.Extension;
import io.quarkus.devtools.messagewriter.MessageWriter;
import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor;
import io.quarkus.platform.descriptor.ResourceInputStreamConsumer;
import io.quarkus.platform.descriptor.ResourcePathConsumer;
import io.quarkus.platform.descriptor.loader.json.ResourceLoader;
import io.quarkus.platform.tools.DefaultMessageWriter;
import io.quarkus.platform.tools.MessageWriter;

public class QuarkusJsonPlatformDescriptor implements QuarkusPlatformDescriptor, Serializable {

Expand Down Expand Up @@ -74,7 +73,7 @@ void setQuarkusVersion(String quarkusVersion) {
}

private MessageWriter getLog() {
return log == null ? log = new DefaultMessageWriter() : log;
return log == null ? log = MessageWriter.DEFAULT : log;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ language:
maven-surefire-plugin:
version: 2.22.1
shared-data:
uberjar: false
supports:
native: true
buildtool:
build-dir: target
guide: https://quarkus.io/guides/maven-tooling.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ This project uses Quarkus, the Supersonic Subatomic Java Framework.

If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .

{#if supports.dev-mode}
## Running the application in dev mode

You can run your application in dev mode that enables live coding using:
```shell script
{buildtool.cmd.dev}
```
{#else}
## Quarkus Dev Mode

Quarkus dev mode is not supported for your extension combination.
{/if}

## Packaging and running the application

Expand All @@ -32,7 +26,6 @@ If you want to build an _über-jar_, just add the `--uber-jar` option to the com

The application is now runnable using `java -jar {buildtool.build-dir}/{project.artifact-id}-{project.version}-runner.jar`.

{#if supports.native}
## Creating a native executable

You can create a native executable using:
Expand All @@ -48,8 +41,4 @@ Or, if you don't have GraalVM installed, you can run the native executable build
You can then execute your native executable with: `./{buildtool.build-dir}/{project.artifact-id}-{project.version}-runner`

If you want to learn more about building native executables, please consult {buildtool.guide}.
{#else}
## Native Executable Support

Your extension combination does not support native executable generation.
{/if}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Azure Functions Integration

> :warning: **INCOMPATIBLE WITH NATIVE**: Azure Functions Integration is not compatible with native yet!
Guide: https://quarkus.io/guides/azure-functions-http
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
quarkus.http.root-path: {root-context-path}
quarkus:
http:
root-path: {root-context-path}
package:
type: uber-jar
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ tags:
- maven-only
language:
base:
shared-data:
uberjar: true
supports:
native: false
data:
# /api is the default root context azure functions will prepend
root-context-path: "/api"
data:
app-region:
westus
resource-group:
Expand Down
17 changes: 7 additions & 10 deletions independent-projects/tools/codestarts/codestarts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ Each codestart consists of:
When generating a Quarkus project:

. Codestarts to use are resolved depending on the input
. The Codestarts' `shared-data` (defined in the different codestart.yml) is merge together and made available to all codestarts
. The Codestarts' `shared-data` (defined in the different codestart.yml) is merged together and made available to all codestarts (conflicts are forbidden)
. The relevant files are processed:
** Only the files that are related to the selected language are processed
** The files are processed differently based on a naming convention.
** The data is used to render Qute templates
** We always process in this order:

. language
. project
. buildtool
. config
. tooling
. code
... language
... project
... buildtool
... config
... tooling
... code


The data used to generate a specific codestart is a merge of:
Expand Down Expand Up @@ -92,9 +92,6 @@ spec:
=== Common Shared and Built In Data

There's a few built `shared-data` variables that you should know about
* `supports.native` can be toggled if your example does not support native. This will omit README and relevant build scripts
* `supports.dev-mode` can be toggled if your example does not support Quarkus devmode. This will omit README information
* `uberjar` can be toggled to switch on the uberjar flag in the pom.xml
* `gen-info.time` is hardcoded to current time milliseconds of when the codestart was generated. Useful if you need a random value in your codestart.


Expand Down
4 changes: 4 additions & 0 deletions independent-projects/tools/codestarts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-app-model</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-devtools-message-writer</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>maven-model-helper</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.devtools.codestarts;

import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
Expand All @@ -10,6 +11,11 @@ public final class Codestart {
private final CodestartSpec spec;
private final Set<String> implementedLanguages;

static final Comparator<Codestart> PROCESSING_ORDER = Comparator.comparingInt(Codestart::getTypeOrder)
.thenComparing(Codestart::getName);

static final Comparator<Codestart> SHARED_DATA_MERGE_ORDER = PROCESSING_ORDER;

public Codestart(final String resourceName, final CodestartSpec spec, Set<String> implementedLanguages) {
this.resourceDir = resourceName;
this.spec = spec;
Expand All @@ -33,14 +39,14 @@ public String getRef() {
}

public int getTypeOrder() {
return spec.getType().getOrder();
return spec.getType().getProcessingOrder();
}

public boolean isSelected(Set<String> selection) {
return selection.contains(getName()) || selection.contains(spec.getRef());
}

public CodestartSpec.Type getType() {
public CodestartType getType() {
return spec.getType();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static java.util.Objects.requireNonNull;

import io.quarkus.bootstrap.model.AppArtifactKey;
import io.quarkus.devtools.messagewriter.MessageWriter;
import java.util.Collection;
import java.util.Map;

Expand All @@ -11,18 +12,24 @@ public class CodestartInput {
private final Collection<AppArtifactKey> dependencies;
private final Map<String, Object> data;
private final Collection<String> codestarts;
private final MessageWriter messageWriter;

CodestartInput(final CodestartInputBuilder builder) {
this.resourceLoader = requireNonNull(builder.resourceLoader, "resourceLoader is required");
this.dependencies = requireNonNull(builder.dependencies, "dependencies is required");
this.codestarts = requireNonNull(builder.codestarts, "codestarts is required");
this.data = NestedMaps.unflatten(requireNonNull(builder.data, "data is required"));
this.messageWriter = requireNonNull(builder.messageWriter, "messageWriter is required");
}

public static CodestartInputBuilder builder(CodestartResourceLoader resourceLoader) {
return new CodestartInputBuilder(resourceLoader);
}

public MessageWriter log() {
return messageWriter;
}

public CodestartResourceLoader getResourceLoader() {
return resourceLoader;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.devtools.codestarts;

import io.quarkus.bootstrap.model.AppArtifactKey;
import io.quarkus.devtools.messagewriter.MessageWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand All @@ -13,6 +14,7 @@ public class CodestartInputBuilder {
Collection<AppArtifactKey> dependencies = new ArrayList<>();
Collection<String> codestarts = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
MessageWriter messageWriter = MessageWriter.DEFAULT;

CodestartInputBuilder(CodestartResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
Expand Down Expand Up @@ -47,6 +49,11 @@ public CodestartInputBuilder putData(String key, Object value) {
return this;
}

public CodestartInputBuilder messageWriter(MessageWriter messageWriter) {
this.messageWriter = messageWriter;
return this;
}

public CodestartInput build() {
return new CodestartInput(this);
}
Expand Down
Loading

0 comments on commit 6c2f87e

Please sign in to comment.