From d193de9236c874040eb1bd3a8e91d79d6b560034 Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Thu, 18 Mar 2021 19:14:47 +0100 Subject: [PATCH] Validation of codestart artifacts configured in extension descriptors --- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../resources/META-INF/quarkus-extension.yaml | 2 +- .../maven/ExtensionDescriptorMojo.java | 49 +++++++++++++++++++ pom.xml | 1 + 21 files changed, 69 insertions(+), 19 deletions(-) diff --git a/extensions/amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml index caa4652ad141ac..9db4f5a338b433 100644 --- a/extensions/amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -12,4 +12,4 @@ metadata: name: "amazon-lambda" kind: "singleton-example" languages: "java" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/azure-functions-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/azure-functions-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 628632236297d2..bb29d1946a9032 100644 --- a/extensions/azure-functions-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/azure-functions-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -12,4 +12,4 @@ metadata: name: "azure-functions-http" kind: "singleton-example" languages: "java" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/config-yaml/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/config-yaml/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 3335e7ff29e838..547aecd3e49dcd 100644 --- a/extensions/config-yaml/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/config-yaml/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -14,4 +14,4 @@ metadata: languages: - "java" - "kotlin" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/funqy/funqy-amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/funqy/funqy-amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 3f17a02242044d..f6a7d5afed358d 100644 --- a/extensions/funqy/funqy-amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/funqy/funqy-amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -14,4 +14,4 @@ metadata: name: "funqy-amazon-lambda" kind: "singleton-example" languages: "java" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/funqy/funqy-google-cloud-functions/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/funqy/funqy-google-cloud-functions/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 6edd7d48904e6a..3baf2173a12c37 100644 --- a/extensions/funqy/funqy-google-cloud-functions/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/funqy/funqy-google-cloud-functions/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -15,4 +15,4 @@ metadata: name: "funqy-google-cloud-functions-example" kind: "singleton-example" languages: "java" - artifact: "io.quarkus:quarkus-descriptor-json" \ No newline at end of file + artifact: "io.quarkus:quarkus-platform-descriptor-json" \ No newline at end of file diff --git a/extensions/funqy/funqy-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/funqy/funqy-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 5513c07da82135..7c90afcc6e108d 100644 --- a/extensions/funqy/funqy-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/funqy/funqy-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -12,4 +12,4 @@ metadata: name: "funqy-http" kind: "example" languages: "java" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/funqy/funqy-knative-events/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/funqy/funqy-knative-events/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 2a97adcc96f8fd..687c09b6be8984 100644 --- a/extensions/funqy/funqy-knative-events/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/funqy/funqy-knative-events/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -13,4 +13,4 @@ metadata: name: "funqy-knative-events" kind: "singleton-example" languages: "java" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/google-cloud-functions-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/google-cloud-functions-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 977d107cd6f2e9..c616d8e936a042 100644 --- a/extensions/google-cloud-functions-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/google-cloud-functions-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -14,4 +14,4 @@ metadata: name: "google-cloud-functions-http" kind: "singleton-example" languages: "java" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/google-cloud-functions/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/google-cloud-functions/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 1f487b0e0caae1..33c6f6764b8918 100755 --- a/extensions/google-cloud-functions/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/google-cloud-functions/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -13,4 +13,4 @@ metadata: name: "google-cloud-functions" kind: "singleton-example" languages: "java" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/kotlin/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/kotlin/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 9671121f1d978f..4ae4815ef4a0d5 100644 --- a/extensions/kotlin/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/kotlin/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -9,4 +9,4 @@ metadata: codestart: name: "kotlin" kind: "core" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/logging-json/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/logging-json/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 52d5bb37bc5db5..3ae7d997b55907 100644 --- a/extensions/logging-json/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/logging-json/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -15,4 +15,4 @@ metadata: languages: - "java" - "kotlin" - artifact: "io.quarkus:quarkus-descriptor-json" \ No newline at end of file + artifact: "io.quarkus:quarkus-platform-descriptor-json" \ No newline at end of file diff --git a/extensions/picocli/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/picocli/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 8e0578be53ce30..3dd33f801b7f5e 100644 --- a/extensions/picocli/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/picocli/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -13,4 +13,4 @@ metadata: languages: - "java" - "kotlin" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/resteasy-classic/resteasy-jackson/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/resteasy-classic/resteasy-jackson/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 82e96447cc9d02..152261ed532310 100644 --- a/extensions/resteasy-classic/resteasy-jackson/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/resteasy-classic/resteasy-jackson/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -18,4 +18,4 @@ metadata: languages: - "java" - "kotlin" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/resteasy-classic/resteasy-qute/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/resteasy-classic/resteasy-qute/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 52c45b00b27920..794d34cfe3ecc9 100644 --- a/extensions/resteasy-classic/resteasy-qute/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/resteasy-classic/resteasy-qute/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -15,4 +15,4 @@ metadata: languages: - "java" - "kotlin" - artifact: "io.quarkus:quarkus-descriptor-json" \ No newline at end of file + artifact: "io.quarkus:quarkus-platform-descriptor-json" \ No newline at end of file diff --git a/extensions/resteasy-classic/resteasy/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/resteasy-classic/resteasy/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 19c44114cb2ea9..931aba72c8ab66 100644 --- a/extensions/resteasy-classic/resteasy/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/resteasy-classic/resteasy/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -17,4 +17,4 @@ metadata: - "java" - "kotlin" - "scala" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 44cce2716d9f71..82837778f30e60 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -16,4 +16,4 @@ metadata: - "java" - "kotlin" - "scala" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/scala/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/scala/runtime/src/main/resources/META-INF/quarkus-extension.yaml index b35474f9c4a46b..5bb8ae6878ddac 100644 --- a/extensions/scala/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/scala/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -8,4 +8,4 @@ metadata: codestart: name: "scala" kind: "core" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/spring-web/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/spring-web/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 98bc5d3eab823e..fd6ef19b2fa96f 100644 --- a/extensions/spring-web/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/spring-web/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -14,5 +14,5 @@ metadata: - "java" - "kotlin" - "scala" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/extensions/websockets/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/websockets/runtime/src/main/resources/META-INF/quarkus-extension.yaml index cda7e43db787a9..f7704802efeba2 100644 --- a/extensions/websockets/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/websockets/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -15,4 +15,4 @@ metadata: name: "undertow-websockets" kind: "example" languages: "java" - artifact: "io.quarkus:quarkus-descriptor-json" + artifact: "io.quarkus:quarkus-platform-descriptor-json" diff --git a/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java b/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java index 0fdc2cea198313..c86c741a84a869 100644 --- a/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java +++ b/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java @@ -176,6 +176,9 @@ public class ExtensionDescriptorMojo extends AbstractMojo { @Parameter private List dependencyCondition = new ArrayList<>(0); + @Parameter(property = "skipCodestartValidation") + boolean skipCodestartValidation; + AppArtifactCoords deploymentCoords; CollectResult collectedDeploymentDeps; @@ -353,6 +356,8 @@ public void execute() throws MojoExecutionException { setBuiltWithQuarkusCoreVersion(mapper, extObject); + completeCodestartArtifact(mapper, extObject); + final DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter(); prettyPrinter.indentArraysWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE); @@ -365,6 +370,50 @@ public void execute() throws MojoExecutionException { } } + private void completeCodestartArtifact(ObjectMapper mapper, ObjectNode extObject) throws MojoExecutionException { + JsonNode mvalue = getJsonElement(extObject, METADATA, "codestart"); + if (mvalue == null || !mvalue.isObject()) { + return; + } + final ObjectNode codestartObject = (ObjectNode) mvalue; + mvalue = mvalue.get("artifact"); + if (mvalue == null) { + if (!skipCodestartValidation) { + throw new MojoExecutionException("Codestart artifact is missing from the " + extensionFile); + } + return; + } + org.eclipse.aether.artifact.Artifact codestartArtifact = DependencyNodeUtils.toArtifact(mvalue.asText()); + if (codestartArtifact.getVersion() == null || codestartArtifact.getVersion().isEmpty()) { + codestartArtifact = codestartArtifact.setVersion(project.getVersion()); + codestartObject.put("artifact", + codestartArtifact.getGroupId() + ":" + codestartArtifact.getArtifactId() + ":" + + codestartArtifact.getClassifier() + ":" + codestartArtifact.getExtension() + ":" + + codestartArtifact.getVersion()); + } + if (!skipCodestartValidation) { + try { + resolve(codestartArtifact); + } catch (MojoExecutionException e) { + throw new MojoExecutionException("Failed to resolve codestart artifact " + codestartArtifact, e); + } + } + } + + private static JsonNode getJsonElement(ObjectNode extObject, String... elements) { + JsonNode mvalue = extObject.get(elements[0]); + int i = 1; + while (i < elements.length) { + if (mvalue == null || !mvalue.isObject()) { + return null; + } + final String element = elements[i++]; + extObject = (ObjectNode) mvalue; + mvalue = extObject.get(element); + } + return mvalue; + } + private void setBuiltWithQuarkusCoreVersion(ObjectMapper mapper, ObjectNode extObject) throws MojoExecutionException { final QuarkusCoreDeploymentVersionLocator coreVersionLocator = new QuarkusCoreDeploymentVersionLocator(); collectDeploymentDeps().getRoot().accept(coreVersionLocator); diff --git a/pom.xml b/pom.xml index a07874feaefe62..132e44a0b1b459 100644 --- a/pom.xml +++ b/pom.xml @@ -124,6 +124,7 @@ true true true + true clean install