Skip to content

Commit

Permalink
Fixed the codestarts artifactId
Browse files Browse the repository at this point in the history
  • Loading branch information
aloubyansky committed Apr 1, 2021
1 parent e51b06d commit 3ddbe97
Show file tree
Hide file tree
Showing 22 changed files with 81 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ metadata:
languages:
- "java"
- "kotlin"
artifact: "io.quarkus:quarkus-descriptor-json"
artifact: "io.quarkus:quarkus-platform-descriptor-json"
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ metadata:
name: "funqy-google-cloud-functions-example"
kind: "singleton-example"
languages: "java"
artifact: "io.quarkus:quarkus-descriptor-json"
artifact: "io.quarkus:quarkus-platform-descriptor-json"
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ metadata:
codestart:
name: "kotlin"
kind: "core"
artifact: "io.quarkus:quarkus-descriptor-json"
artifact: "io.quarkus:quarkus-platform-descriptor-json"
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ metadata:
languages:
- "java"
- "kotlin"
artifact: "io.quarkus:quarkus-descriptor-json"
artifact: "io.quarkus:quarkus-platform-descriptor-json"
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ metadata:
languages:
- "java"
- "kotlin"
artifact: "io.quarkus:quarkus-descriptor-json"
artifact: "io.quarkus:quarkus-platform-descriptor-json"
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ metadata:
languages:
- "java"
- "kotlin"
artifact: "io.quarkus:quarkus-descriptor-json"
artifact: "io.quarkus:quarkus-platform-descriptor-json"
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ metadata:
languages:
- "java"
- "kotlin"
artifact: "io.quarkus:quarkus-descriptor-json"
artifact: "io.quarkus:quarkus-platform-descriptor-json"
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ metadata:
- "java"
- "kotlin"
- "scala"
artifact: "io.quarkus:quarkus-descriptor-json"
artifact: "io.quarkus:quarkus-platform-descriptor-json"
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ metadata:
- "java"
- "kotlin"
- "scala"
artifact: "io.quarkus:quarkus-descriptor-json"
artifact: "io.quarkus:quarkus-platform-descriptor-json"
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ metadata:
codestart:
name: "scala"
kind: "core"
artifact: "io.quarkus:quarkus-descriptor-json"
artifact: "io.quarkus:quarkus-platform-descriptor-json"
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ metadata:
- "java"
- "kotlin"
- "scala"
artifact: "io.quarkus:quarkus-descriptor-json"
artifact: "io.quarkus:quarkus-platform-descriptor-json"

Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -90,7 +91,7 @@ public class ExtensionDescriptorMojo extends AbstractMojo {
RemoteRepositoryManager remoteRepoManager;

@Component
BootstrapWorkspaceProvider workpaceProvider;
BootstrapWorkspaceProvider workspaceProvider;

/**
* The current repository/network configuration of Maven.
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions independent-projects/tools/codestarts/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down

0 comments on commit 3ddbe97

Please sign in to comment.