From 3ddbe97599cd12092cb1fe63a905fde279a52904 Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Thu, 1 Apr 2021 11:48:02 +0200 Subject: [PATCH] Fixed the codestarts artifactId --- .../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 | 60 ++++++++++++++++++- .../tools/codestarts/README.adoc | 4 +- .../catalog/ExtensionProcessorTest.java | 4 +- 22 files changed, 81 insertions(+), 25 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 caa4652ad141a..9db4f5a338b43 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 628632236297d..bb29d1946a903 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 3335e7ff29e83..547aecd3e49dc 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 3f17a02242044..f6a7d5afed358 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 6edd7d48904e6..3baf2173a12c3 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 5513c07da8213..7c90afcc6e108 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 2a97adcc96f8f..687c09b6be898 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 977d107cd6f2e..c616d8e936a04 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 1f487b0e0caae..33c6f6764b891 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 9671121f1d978..4ae4815ef4a0d 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 52d5bb37bc5db..3ae7d997b5590 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 8e0578be53ce3..3dd33f801b7f5 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-jackson/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/resteasy-jackson/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 82e96447cc9d0..152261ed53231 100644 --- a/extensions/resteasy-jackson/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/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-qute/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/resteasy-qute/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 52c45b00b2792..794d34cfe3ecc 100644 --- a/extensions/resteasy-qute/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/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-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 44cce2716d9f7..82837778f30e6 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/resteasy/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/resteasy/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 19c44114cb2ea..931aba72c8ab6 100644 --- a/extensions/resteasy/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/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/scala/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/scala/runtime/src/main/resources/META-INF/quarkus-extension.yaml index b35474f9c4a46..5bb8ae6878dda 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 98bc5d3eab823..fd6ef19b2fa96 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 cda7e43db787a..f7704802efeba 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 4a3024af6bac7..05fac0a1d0ffb 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 @@ -16,6 +16,7 @@ import io.quarkus.bootstrap.model.AppModel; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException; +import io.quarkus.bootstrap.resolver.maven.DeploymentInjectingDependencyVisitor; import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -90,7 +91,7 @@ public class ExtensionDescriptorMojo extends AbstractMojo { RemoteRepositoryManager remoteRepoManager; @Component - BootstrapWorkspaceProvider workpaceProvider; + BootstrapWorkspaceProvider workspaceProvider; /** * The current repository/network configuration of Maven. @@ -167,6 +168,9 @@ public class ExtensionDescriptorMojo extends AbstractMojo { @Parameter(required = false, defaultValue = "${ignoreNotDetectedQuarkusCoreVersion") boolean ignoreNotDetectedQuarkusCoreVersion; + @Parameter(property = "skipCodestartValidation") + boolean skipCodestartValidation; + AppArtifactCoords deploymentCoords; CollectResult collectedDeploymentDeps; @@ -291,6 +295,8 @@ public void execute() throws MojoExecutionException { setBuiltWithQuarkusCoreVersion(mapper, extObject); + completeCodestartArtifact(mapper, extObject); + final DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter(); prettyPrinter.indentArraysWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE); @@ -303,6 +309,56 @@ 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 = DeploymentInjectingDependencyVisitor + .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) { + // first we look for it in the workspace, if it's in there we don't need to actually resolve the artifact, because it might not have been built yet + if (this.workspaceProvider.workspace().getProject(codestartArtifact.getGroupId(), + codestartArtifact.getArtifactId()) == null) { + 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); @@ -826,7 +882,7 @@ private MavenArtifactResolver resolver() throws MojoExecutionException { .setRemoteRepositoryManager(remoteRepoManager) .setRepositorySystemSession(repoSession) .setRemoteRepositories(repos) - .setCurrentProject(workpaceProvider.origin())); + .setCurrentProject(workspaceProvider.origin())); resolver = new MavenArtifactResolver(ctx); } catch (BootstrapMavenException e) { throw new MojoExecutionException("Failed to initialize Maven artifact resolver", e); diff --git a/independent-projects/tools/codestarts/README.adoc b/independent-projects/tools/codestarts/README.adoc index 27f94fd64a19c..9636e82ae3cf5 100644 --- a/independent-projects/tools/codestarts/README.adoc +++ b/independent-projects/tools/codestarts/README.adoc @@ -104,10 +104,10 @@ metadata: - "java" - "kotlin" - "scala" - artifact: "io.quarkus:quarkus-descriptor-json" # The artifact in which the codestart is located + artifact: "io.quarkus:quarkus-platform-descriptor-json" # The artifact in which the codestart is located ---- -*NOTE* Using "io.quarkus:quarkus-descriptor-json" as artifact is temporary, extension codestarts will soon live alongside the extension. +*NOTE* Using "io.quarkus:quarkus-platform-descriptor-json" as artifact is temporary, extension codestarts will soon live alongside the extension. === Tests diff --git a/integration-tests/devtools/src/test/java/io/quarkus/platform/catalog/ExtensionProcessorTest.java b/integration-tests/devtools/src/test/java/io/quarkus/platform/catalog/ExtensionProcessorTest.java index 935349d806cb8..38ac8311b0ecc 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/platform/catalog/ExtensionProcessorTest.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/platform/catalog/ExtensionProcessorTest.java @@ -24,7 +24,7 @@ void testRESTEasyMetadata() { assertThat(extensionProcessor.getCategories()).contains("web"); assertThat(extensionProcessor.getCodestartKind()).isEqualTo(ExtensionProcessor.CodestartKind.EXAMPLE); assertThat(extensionProcessor.getCodestartName()).isEqualTo("resteasy"); - assertThat(extensionProcessor.getCodestartArtifact()).isEqualTo("io.quarkus:quarkus-descriptor-json"); + assertThat(extensionProcessor.getCodestartArtifact()).isEqualTo("io.quarkus:quarkus-platform-descriptor-json"); assertThat(extensionProcessor.getCodestartLanguages()).contains("java", "kotlin", "scala"); assertThat(extensionProcessor.getKeywords()).contains("resteasy", "jaxrs", "web", "rest"); assertThat(extensionProcessor.getExtendedKeywords()).contains("resteasy", "jaxrs", "web", "rest"); @@ -42,7 +42,7 @@ void testKotlinMetadata() { assertThat(extensionProcessor.getCodestartKind()).isEqualTo(ExtensionProcessor.CodestartKind.CORE); assertThat(extensionProcessor.getCodestartName()).isEqualTo("kotlin"); assertThat(extensionProcessor.getCodestartLanguages()).isEmpty(); - assertThat(extensionProcessor.getCodestartArtifact()).isEqualTo("io.quarkus:quarkus-descriptor-json"); + assertThat(extensionProcessor.getCodestartArtifact()).isEqualTo("io.quarkus:quarkus-platform-descriptor-json"); assertThat(extensionProcessor.getKeywords()).contains("kotlin"); assertThat(extensionProcessor.getExtendedKeywords()).contains("kotlin", "quarkus-kotlin", "services", "write"); assertThat(extensionProcessor.getGuide()).isEqualTo("https://quarkus.io/guides/kotlin");