Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jsonb-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<name>avaje jsonb generator</name>
<description>annotation processor generating source code json adapters for avaje-jsonb</description>
<properties>
<avaje.prisms.version>1.44</avaje.prisms.version>
<avaje.prisms.version>2.0-RC1</avaje.prisms.version>
</properties>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@
import javax.tools.FileObject;

import io.avaje.prism.GenerateAPContext;
import io.avaje.prism.GenerateModuleInfoReader;
import io.avaje.prism.GenerateUtils;

@GenerateUtils
@GenerateAPContext
@GenerateModuleInfoReader
@SupportedAnnotationTypes({
CustomAdapterPrism.PRISM_TYPE,
JSON,
Expand Down Expand Up @@ -115,6 +113,10 @@ private void readModule() {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment round) {
if (generateComponent || round.errorRaised()) {
if (round.processingOver()) {
ProcessingContext.validateModule();
ProcessingContext.clear();
}
return false;
}
generateComponent = rounds++ > 0;
Expand Down Expand Up @@ -338,11 +340,8 @@ private void writeComponent(boolean processingOver) {
writer.write();
}
writeMetaInf();
ProcessingContext.validateModule();
} catch (final IOException e) {
logError("Error writing component", e);
} finally {
ProcessingContext.clear();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package io.avaje.jsonb.generator;

import static io.avaje.jsonb.generator.APContext.filer;
import static io.avaje.jsonb.generator.APContext.getModuleInfoReader;
import static io.avaje.jsonb.generator.APContext.getProjectModuleElement;
import static io.avaje.jsonb.generator.APContext.jdkVersion;
import static io.avaje.jsonb.generator.APContext.logError;
import static io.avaje.jsonb.generator.APContext.logWarn;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
Expand Down Expand Up @@ -86,31 +84,31 @@ private static boolean buildPluginAvailable() {

static void validateModule() {
var module = getProjectModuleElement();
if (module != null && !module.isUnnamed()) {
var injectPresent = CTX.get().injectPresent;

try (var reader = getModuleInfoReader()) {
var moduleInfo = new ModuleInfoReader(module, reader);

moduleInfo.validateServices("io.avaje.jsonb.spi.JsonbExtension", CTX.get().services);
var injectPresent = CTX.get().injectPresent;

boolean noInjectPlugin =
injectPresent && !moduleInfo.containsOnModulePath("io.avaje.jsonb.plugin");
APContext.moduleInfoReader()
.ifPresent(
moduleInfo -> {
moduleInfo.validateServices("io.avaje.jsonb.spi.JsonbExtension", CTX.get().services);

var buildPluginAvailable = buildPluginAvailable();
boolean noInjectPlugin =
injectPresent && !moduleInfo.containsOnModulePath("io.avaje.jsonb.plugin");

final var noDirectJsonb =
moduleInfo.requires().stream()
.noneMatch(r -> r.getDependency().getQualifiedName().contentEquals("io.avaje.jsonb"));
var buildPluginAvailable = buildPluginAvailable();

if (noInjectPlugin && (!buildPluginAvailable || noDirectJsonb)) {
logWarn(module, "`requires io.avaje.jsonb.plugin` must be explicitly added or else avaje-inject may fail to detect and wire the default Jsonb instance");
}
final var noDirectJsonb =
moduleInfo.requires().stream()
.noneMatch(
r ->
r.getDependency().getQualifiedName().contentEquals("io.avaje.jsonb"));

} catch (Exception e) {
// can't read module
}
}
if (noInjectPlugin && (!buildPluginAvailable || noDirectJsonb)) {
logWarn(
module,
"`requires io.avaje.jsonb.plugin` must be explicitly added or else avaje-inject may fail to detect and wire the default Jsonb instance");
}
});
}

static void addJsonSpi(String spi) {
Expand Down