From 1a7563f915b17a7a97c583ac2470b200d80f24f0 Mon Sep 17 00:00:00 2001 From: Holly Cummins Date: Mon, 21 Nov 2022 13:13:04 +0000 Subject: [PATCH] Move scm information to metadata from top-level, and remove nesting --- .../extension/gradle/tasks/ExtensionDescriptorTask.java | 5 +++-- .../gradle/tasks/ExtensionDescriptorTaskTest.java | 7 +++---- .../java/io/quarkus/maven/ExtensionDescriptorMojo.java | 5 ++--- .../java/io/quarkus/maven/ExtensionDescriptorMojo.java | 5 +++-- .../java/io/quarkus/maven/ExtensionDescriptorMojoTest.java | 3 +-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/devtools/gradle/gradle-extension-plugin/src/main/java/io/quarkus/extension/gradle/tasks/ExtensionDescriptorTask.java b/devtools/gradle/gradle-extension-plugin/src/main/java/io/quarkus/extension/gradle/tasks/ExtensionDescriptorTask.java index 5b5b067b11b0d..c700936e4f733 100644 --- a/devtools/gradle/gradle-extension-plugin/src/main/java/io/quarkus/extension/gradle/tasks/ExtensionDescriptorTask.java +++ b/devtools/gradle/gradle-extension-plugin/src/main/java/io/quarkus/extension/gradle/tasks/ExtensionDescriptorTask.java @@ -313,9 +313,10 @@ private void computeArtifactCoords(ObjectNode extObject) { private void computeSourceLocation(ObjectNode extObject) { Map repo = ScmInfoProvider.getSourceRepo(); if (repo != null) { - ObjectNode scm = extObject.putObject("scm"); + ObjectNode metadata = getMetadataNode(extObject); + for (Map.Entry e : repo.entrySet()) { - scm.put(e.getKey(), e.getValue()); + metadata.put("scm-" + e.getKey(), e.getValue()); } } diff --git a/devtools/gradle/gradle-extension-plugin/src/test/java/io/quarkus/extension/gradle/tasks/ExtensionDescriptorTaskTest.java b/devtools/gradle/gradle-extension-plugin/src/test/java/io/quarkus/extension/gradle/tasks/ExtensionDescriptorTaskTest.java index c4d8acf9b22da..4bf80758222d0 100644 --- a/devtools/gradle/gradle-extension-plugin/src/test/java/io/quarkus/extension/gradle/tasks/ExtensionDescriptorTaskTest.java +++ b/devtools/gradle/gradle-extension-plugin/src/test/java/io/quarkus/extension/gradle/tasks/ExtensionDescriptorTaskTest.java @@ -200,10 +200,9 @@ public void shouldGenerateScmInformation() throws IOException { File extensionDescriptorFile = new File(testProjectDir, "build/resources/main/META-INF/quarkus-extension.yaml"); assertThat(extensionDescriptorFile).exists(); ObjectNode extensionDescriptor = TestUtils.readExtensionFile(extensionDescriptorFile.toPath()); - assertThat(extensionDescriptor.get("scm")).isNotNull(); - assertThat(extensionDescriptor.get("scm").get("url")).isNotNull(); - assertThat(extensionDescriptor.get("scm").get("url").asText()) - .as("Check source location %s", extensionDescriptor.get("scm")) + assertThat(extensionDescriptor.get("metadata").get("scm-url")).isNotNull(); + assertThat(extensionDescriptor.get("metadata").get("scm-url").asText()) + .as("Check source location %s", extensionDescriptor.get("scm-url")) .isEqualTo("https://github.com/some/repo"); } 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 330a716ca5414..851edeeb722cf 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 @@ -660,10 +660,9 @@ public boolean visitLeave(DependencyNode node) { private void addSource(ObjectNode extObject) throws MojoExecutionException { Map repo = getSourceRepo(); if (repo != null) { - ObjectNode scm = extObject.putObject("scm"); + ObjectNode metadata = getMetadataNode(extObject); for (Map.Entry e : repo.entrySet()) { - scm.put(e.getKey(), e.getValue()); - + metadata.put("scm-" + e.getKey(), e.getValue()); } } } diff --git a/independent-projects/extension-maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java b/independent-projects/extension-maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java index 79c7599a78fe2..79240d2cfa5d5 100644 --- a/independent-projects/extension-maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java +++ b/independent-projects/extension-maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java @@ -676,9 +676,10 @@ public boolean visitLeave(DependencyNode node) { private void addSource(ObjectNode extObject) throws MojoExecutionException { Map repo = ScmInfoProvider.getSourceRepo(); if (repo != null) { - ObjectNode scm = extObject.putObject("scm"); + ObjectNode metadata = getMetadataNode(extObject); for (Map.Entry e : repo.entrySet()) { - scm.put(e.getKey(), e.getValue()); + // Tools may not be able to handle nesting in metadata, so do fake-nesting + metadata.put("scm-" + e.getKey(), e.getValue()); } } diff --git a/independent-projects/extension-maven-plugin/src/test/java/io/quarkus/maven/ExtensionDescriptorMojoTest.java b/independent-projects/extension-maven-plugin/src/test/java/io/quarkus/maven/ExtensionDescriptorMojoTest.java index 4d2b39a424d52..acbb2ca6fa75c 100644 --- a/independent-projects/extension-maven-plugin/src/test/java/io/quarkus/maven/ExtensionDescriptorMojoTest.java +++ b/independent-projects/extension-maven-plugin/src/test/java/io/quarkus/maven/ExtensionDescriptorMojoTest.java @@ -100,8 +100,7 @@ public void shouldCreateMetadata() // From maven this property should be set, running in an IDE it won't be unless specially configured if (System.getenv("GITHUB_REPOSITORY") != null) { // Lazily test that the scm is there but is an object - assertYamlContainsObject(fileContents, "scm"); - assertYamlContains(fileContents, "url", "https://github.com/some/repo"); + assertYamlContains(fileContents, "scm-url", "https://github.com/some/repo"); } }