Skip to content

Commit

Permalink
Merge pull request #5517 from aloubyansky/platform-resolver-descripto…
Browse files Browse the repository at this point in the history
…r-jar-allows-fallback

Allow falling back to the bundled platform in case quarkus-platform-descriptor-json:jar couldn't be resolved
  • Loading branch information
gsmet authored Nov 18, 2019
2 parents ceb4ed1 + 0782c32 commit e70441f
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ public QuarkusPlatformDescriptor resolve() {
return loadFromFile(jsonDescriptor);
}
return resolveJsonDescriptor(artifactResolver);
} catch (PlatformDescriptorLoadingException e) {
} catch (VersionNotAvailableException | PlatformDescriptorLoadingException e) {
throw new IllegalStateException("Failed to load Quarkus platform descriptor", e);
}
}

private QuarkusPlatformDescriptor loadFromFile(Path jsonFile) throws PlatformDescriptorLoadingException {
private QuarkusPlatformDescriptor loadFromFile(Path jsonFile) throws PlatformDescriptorLoadingException, VersionNotAvailableException {
log.debug("Loading Quarkus platform descriptor from %s", jsonFile);
if(!Files.exists(jsonFile)) {
throw new IllegalArgumentException("Failed to locate extensions JSON file at " + jsonFile);
Expand All @@ -176,6 +176,8 @@ private QuarkusPlatformDescriptor loadFromFile(Path jsonFile) throws PlatformDes

try (InputStream is = Files.newInputStream(jsonFile)) {
return loadPlatformDescriptor(artifactResolver, is, quarkusCoreVersion);
} catch (VersionNotAvailableException e) {
throw e;
} catch (Exception e) {
throw new PlatformDescriptorLoadingException("Failed to load Quarkus platform descriptor from " + jsonFile, e);
}
Expand Down Expand Up @@ -295,7 +297,7 @@ private QuarkusPlatformDescriptor resolveJsonArtifactFromBom(AppModelResolver ar
bomGroupId = this.bomGroupId;
if(bomGroupId != null) {
if(!bomGroupId.equals(getGroupId(bundledBom))) {
throw new IllegalStateException("Failed to resolve Quarkus platform BOM with the requested groupId " + bomGroupId);
throw new IllegalStateException("Failed to resolve Quarkus platform using the requested BOM groupId " + bomGroupId);
}
} else {
bomGroupId = getGroupId(bundledBom);
Expand All @@ -307,7 +309,7 @@ private QuarkusPlatformDescriptor resolveJsonArtifactFromBom(AppModelResolver ar
bomArtifactId = this.bomArtifactId;
if(bomArtifactId != null) {
if(!bomArtifactId.equals(getArtifactId(bundledBom))) {
throw new IllegalStateException("Failed to resolve Quarkus platform BOM with the requested artifactId " + bomArtifactId);
throw new IllegalStateException("Failed to resolve Quarkus platform using the requested BOM artifactId " + bomArtifactId);
}
} else {
bomArtifactId = getArtifactId(bundledBom);
Expand All @@ -319,7 +321,7 @@ private QuarkusPlatformDescriptor resolveJsonArtifactFromBom(AppModelResolver ar
bomVersion = this.bomVersion;
if(bomVersion != null) {
if(!bomVersion.equals(getVersion(bundledBom))) {
throw new IllegalStateException("Failed to resolve Quarkus platform BOM with the requested version " + bomVersion);
throw new IllegalStateException("Failed to resolve Quarkus platform using the requested BOM version " + bomVersion);
}
} else if(this.bomVersionRange == null) {
bomVersion = getVersion(bundledBom);
Expand Down Expand Up @@ -418,7 +420,7 @@ private QuarkusPlatformDescriptor loadFromJsonArtifact(AppModelResolver artifact

@SuppressWarnings("rawtypes")
private QuarkusPlatformDescriptor loadPlatformDescriptor(AppModelResolver mvn, final InputStream jsonStream,
String quarkusCoreVersion) throws PlatformDescriptorLoadingException {
String quarkusCoreVersion) throws PlatformDescriptorLoadingException, VersionNotAvailableException {

ClassLoader jsonDescrLoaderCl = null;

Expand Down Expand Up @@ -453,6 +455,8 @@ private QuarkusPlatformDescriptor loadPlatformDescriptor(AppModelResolver mvn, f
resourceLoader = Files.isDirectory(path) ? new DirectoryResourceLoader(path) : new ZipResourceLoader(path);
log.debug("Quarkus platform resources will be loaded from %s", path);
jsonDescrUrl = path.toUri().toURL();
} catch (AppModelResolverException e) {
throw new VersionNotAvailableException("Failed to resolve " + jsonDescrArtifact, e);
} catch (Exception e) {
throw new PlatformDescriptorLoadingException("Failed to resolve " + jsonDescrArtifact, e);
}
Expand Down

0 comments on commit e70441f

Please sign in to comment.