Skip to content

Commit

Permalink
Merge pull request #11248 from gytis/rest-data-fail-hal-without-seria…
Browse files Browse the repository at this point in the history
…liser

Fail build with HAL resource without serializer #11246
  • Loading branch information
geoand authored Mar 15, 2021
2 parents 7a2b463 + bda2e56 commit 087b300
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public enum Capability {
RESTEASY_JSON,
RESTEASY_MUTINY,
RESTEASY_REACTIVE,
RESTEASY_JACKSON,
RESTEASY_JSONB,
JWT,
TIKA,
MONGODB_PANACHE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ void implementResources(CombinedIndexBuildItem index, List<RestDataResourceBuild
ResourceMetadata resourceMetadata = resourceBuildItem.getResourceMetadata();
ResourceProperties resourceProperties = getResourceProperties(resourcePropertiesProvider,
resourceMetadata, resourcePropertiesBuildItems);
if (resourceProperties.isHal() && !hasHalCapability(capabilities)) {
throw new IllegalStateException(
"Cannot generate HAL endpoints without a RESTEasy JSON-B or Jackson capability");
}
if (resourceProperties.isExposed()) {
jaxRsResourceImplementor.implement(classOutput, resourceMetadata, resourceProperties);
}
Expand Down Expand Up @@ -93,4 +97,8 @@ private ResourceProperties getResourceProperties(ResourcePropertiesProvider reso
private boolean hasValidatorCapability(Capabilities capabilities) {
return capabilities.isPresent(Capability.HIBERNATE_VALIDATOR);
}

private boolean hasHalCapability(Capabilities capabilities) {
return capabilities.isPresent(Capability.RESTEASY_JSONB) || capabilities.isPresent(Capability.RESTEASY_JACKSON);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ void feature(BuildProducer<FeatureBuildItem> feature) {
void capabilities(BuildProducer<CapabilityBuildItem> capability) {
capability.produce(new CapabilityBuildItem(Capability.RESTEASY_JSON));
capability.produce(new CapabilityBuildItem(Capability.REST_JACKSON));
capability.produce(new CapabilityBuildItem(Capability.RESTEASY_JACKSON));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ void feature(BuildProducer<FeatureBuildItem> feature) {
void capabilities(BuildProducer<CapabilityBuildItem> capability) {
capability.produce(new CapabilityBuildItem(Capability.RESTEASY_JSON));
capability.produce(new CapabilityBuildItem(Capability.REST_JSONB));
capability.produce(new CapabilityBuildItem(Capability.RESTEASY_JSONB));
}

@BuildStep
Expand Down

0 comments on commit 087b300

Please sign in to comment.