Skip to content

Commit

Permalink
remove string templates
Browse files Browse the repository at this point in the history
seems that api will change in a future release
  • Loading branch information
SentryMan committed Mar 9, 2024
1 parent 9c3ca8d commit f39f34c
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/main/java/io/avaje/inject/mojo/ModuleSPIMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public void execute() throws MojoExecutionException {

var dirPath = directory.getAbsolutePath();

var moduleCF = Paths.get(STR."\{dirPath}\\classes\\module-info.class");
var servicesDirectory = Paths.get(STR."\{dirPath}\\classes\\META-INF\\services");
var moduleCF = Paths.get(dirPath + "dirPath\\classes\\module-info.class");
var servicesDirectory = Paths.get(dirPath + "dirPath\\classes\\META-INF\\services");

if (!moduleCF.toFile().exists()) {
// no module-info to modify
Expand Down Expand Up @@ -95,7 +95,8 @@ private byte[] transform(final Path moduleCF, Path metaInfServicesPath) throws I

var newModule =
ModuleAttribute.of(
ma.moduleName().asSymbol(), b -> transformDirectives(ma, b, metaInfServicesPath));
ma.moduleName().asSymbol(),
b -> transformDirectives(ma, b, metaInfServicesPath));

classBuilder.with(newModule);
}
Expand All @@ -104,7 +105,9 @@ private byte[] transform(final Path moduleCF, Path metaInfServicesPath) throws I
}

private void transformDirectives(
ModuleAttribute moduleAttribute, ModuleAttributeBuilder moduleBuilder, Path metaInfServicesPath) {
ModuleAttribute moduleAttribute,
ModuleAttributeBuilder moduleBuilder,
Path metaInfServicesPath) {

moduleAttribute.moduleFlags().forEach(moduleBuilder::moduleFlags);
moduleBuilder.moduleFlags(moduleAttribute.moduleFlagsMask());
Expand Down Expand Up @@ -158,8 +161,10 @@ private void requires(ModuleRequireInfo moduleRequires, ModuleAttributeBuilder m
moduleRequires.requiresFlagsMask(),
moduleRequires.requiresVersion().map(Utf8Entry::stringValue).orElse(null));
moduleBuilder.requires(plugin);
log.info(STR."Adding `requires \{IO_AVAJE_JSONB_PLUGIN};` to compiled module-info.class");
}
log.info(
"Adding `requires %s;` to compiled module-info.class"
.formatted(IO_AVAJE_JSONB_PLUGIN));
}
}

case "io.avaje.validation" -> {
Expand All @@ -176,15 +181,17 @@ private void requires(ModuleRequireInfo moduleRequires, ModuleAttributeBuilder m
moduleRequires.requiresFlagsMask(),
moduleRequires.requiresVersion().map(Utf8Entry::stringValue).orElse(null));
moduleBuilder.requires(plugin);
log.info(STR."Adding `requires \{pluginModule};` to compiled module-info.class");
log.info("Adding `requires %s;` to compiled module-info.class".formatted(pluginModule));
} else if (!avajeModuleNames.contains(IO_AVAJE_VALIDATOR_HTTP_PLUGIN) && hasHttp) {
var plugin =
ModuleRequireInfo.of(
ModuleDesc.of(IO_AVAJE_VALIDATOR_HTTP_PLUGIN),
moduleRequires.requiresFlagsMask(),
moduleRequires.requiresVersion().map(Utf8Entry::stringValue).orElse(null));
moduleBuilder.requires(plugin);
log.info(STR."Adding `requires \{IO_AVAJE_VALIDATOR_HTTP_PLUGIN};` to compiled module-info.class");
log.info(
"Adding `requires %s;` to compiled module-info.class"
.formatted(IO_AVAJE_VALIDATOR_HTTP_PLUGIN));
}
}
}
Expand All @@ -194,7 +201,10 @@ private void requires(ModuleRequireInfo moduleRequires, ModuleAttributeBuilder m
}
}

private void addServices(ModuleAttribute moduleAttribute, ModuleAttributeBuilder moduleBuilder, Stream<Path> servicesDir) {
private void addServices(
ModuleAttribute moduleAttribute,
ModuleAttributeBuilder moduleBuilder,
Stream<Path> servicesDir) {
var serviceMap =
servicesDir
.skip(1)
Expand Down Expand Up @@ -223,7 +233,9 @@ private void addServices(ModuleAttribute moduleAttribute, ModuleAttributeBuilder
(k, v) -> {
var provides = ClassDesc.of(k);
var with = v.stream().map(ClassDesc::displayName).collect(joining(","));
log.info(STR."Adding `provides \{provides.displayName()} with \{with};` to compiled module-info.class");
log.info(
"Adding `provides %s with %s;` to compiled module-info.class"
.formatted(provides.displayName(), with));

moduleBuilder.provides(ModuleProvideInfo.of(provides, v));
});
Expand Down

0 comments on commit f39f34c

Please sign in to comment.