Skip to content

Commit

Permalink
Fix create app exception min java version not thrown up
Browse files Browse the repository at this point in the history
  • Loading branch information
ia3andy committed Jun 23, 2023
1 parent 4e30b33 commit 8992255
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion devtools/cli/src/main/java/io/quarkus/cli/CreateApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public Integer call() throws Exception {
return CommandLine.ExitCode.SOFTWARE;
} catch (Exception e) {
return output.handleCommandException(e,
"Unable to create project: " + e.getMessage());
"Unable to create project: " + e.getLocalizedMessage());
}
}

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

import io.fabric8.maven.Maven;
import io.fabric8.maven.merge.SmartModelMerger;
import io.quarkus.devtools.codestarts.CodestartStructureException;
import io.quarkus.devtools.codestarts.CodestartException;
import io.quarkus.devtools.codestarts.core.CodestartData;
import io.quarkus.devtools.codestarts.core.reader.TargetFile;

Expand All @@ -32,7 +32,7 @@ public void process(Path targetDirectory, String relativePath, List<TargetFile>
createDirectories(targetPath);
CodestartData.getBuildtool(data)
.filter(b -> Objects.equals(b, "maven"))
.orElseThrow(() -> new CodestartStructureException(
.orElseThrow(() -> new CodestartException(
"something is wrong, smart-pom-merge file strategy must only be used on maven projects"));

final SmartModelMerger merger = new SmartModelMerger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,11 @@ public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws

List<Extension> extensionsToAdd = computeRequiredExtensions(invocation.getExtensionsCatalog(), extensionsQuery,
invocation.log());
final List<ExtensionCatalog> extensionOrigins;
ExtensionCatalog mainCatalog = invocation.getExtensionsCatalog(); // legacy platform initialization

final String javaVersion = invocation.getStringValue(JAVA_VERSION);
try {
checkMinimumJavaVersion(javaVersion, extensionsToAdd);
extensionOrigins = getExtensionOrigins(mainCatalog, extensionsToAdd);
} catch (QuarkusCommandException e) {
invocation.log().error(e.getLocalizedMessage());
return QuarkusCommandOutcome.failure();
}
checkMinimumJavaVersion(javaVersion, extensionsToAdd);
final List<ExtensionCatalog> extensionOrigins = getExtensionOrigins(mainCatalog, extensionsToAdd);

final List<ArtifactCoords> platformBoms = new ArrayList<>(Math.max(extensionOrigins.size(), 1));
if (extensionOrigins.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.devtools.project.create;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import java.nio.file.Path;
import java.util.ArrayList;
Expand All @@ -13,6 +14,7 @@
import org.junit.jupiter.api.Test;

import io.quarkus.devtools.commands.CreateProject;
import io.quarkus.devtools.commands.data.QuarkusCommandException;
import io.quarkus.devtools.project.BuildTool;
import io.quarkus.devtools.project.QuarkusProject;
import io.quarkus.devtools.project.QuarkusProjectHelper;
Expand Down Expand Up @@ -222,7 +224,8 @@ public void addNonPlatformExtensionWithGA() throws Exception {
@Test
public void attemptCreateWithIncompatibleExtensions() throws Exception {
final Path projectDir = newProjectDir("create-with-incompatible-extensions");
assertThat(createProject(projectDir, Arrays.asList("acme-bar", "other-five-one")).isSuccess()).isFalse();
assertThatExceptionOfType(QuarkusCommandException.class)
.isThrownBy(() -> createProject(projectDir, Arrays.asList("acme-bar", "other-five-one")));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.devtools.project.create;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import java.nio.file.Path;
import java.util.ArrayList;
Expand All @@ -13,6 +14,7 @@
import org.junit.jupiter.api.Test;

import io.quarkus.devtools.commands.CreateProject;
import io.quarkus.devtools.commands.data.QuarkusCommandException;
import io.quarkus.devtools.project.BuildTool;
import io.quarkus.devtools.project.QuarkusProject;
import io.quarkus.devtools.project.QuarkusProjectHelper;
Expand Down Expand Up @@ -200,7 +202,8 @@ public void addExtensionAndImportMemberBom() throws Exception {
@Test
public void attemptCreateWithIncompatibleExtensions() throws Exception {
final Path projectDir = newProjectDir("create-with-incompatible-extensions");
assertThat(createProject(projectDir, Arrays.asList("acme-bar", "other-five-one")).isSuccess()).isFalse();
assertThatExceptionOfType(QuarkusCommandException.class)
.isThrownBy(() -> createProject(projectDir, Arrays.asList("acme-bar", "other-five-one")));
}

@Test
Expand Down

0 comments on commit 8992255

Please sign in to comment.