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 avaje-prisms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-prisms-parent</artifactId>
<version>1.44</version>
<version>2.0-RC1</version>
</parent>
<artifactId>avaje-prisms</artifactId>
<name>avaje-prisms</name>
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion blackbox-test-prism/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-prisms-parent</artifactId>
<version>1.44</version>
<version>2.0-RC1</version>
</parent>

<artifactId>blackbox-test-prism</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package io.avaje.prisms.test;

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

@GenerateUtils
@GenerateAPContext
@GenerateModuleInfoReader
public class CommonClass {

public void common() {
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-prisms-parent</artifactId>
<version>1.44</version>
<version>2.0-RC1</version>
<packaging>pom</packaging>
<name>avaje-prisms-parent</name>
<description>A modular fork of hickory</description>
Expand All @@ -17,7 +17,7 @@
</scm>

<properties>
<project.build.outputTimestamp>2025-12-01T15:33:21Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2025-12-01T16:13:45Z</project.build.outputTimestamp>
<nexus.staging.autoReleaseAfterClose>true</nexus.staging.autoReleaseAfterClose>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion prism-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-prisms-parent</artifactId>
<version>1.44</version>
<version>2.0-RC1</version>
</parent>
<name>avaje-prisms-core</name>
<artifactId>avaje-prism-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static String preview() {
+ " }\n";
}

public static void write(PrintWriter out, String packageName, boolean moduleReader) {
public static void write(PrintWriter out, String packageName) {
out.append(
"package "
+ packageName
Expand Down Expand Up @@ -81,7 +81,7 @@ public static void write(PrintWriter out, String packageName, boolean moduleRead
+ " private final Types typeUtils;\n"
+ " private ModuleElement module;\n"
+ " private final boolean isTestCompilation;\n"
+ (moduleReader ? " private ModuleInfoReader moduleReader;\n" : "")
+ " private ModuleInfoReader moduleReader;\n"
+ "\n"
+ " private Ctx(ProcessingEnvironment processingEnv) {\n"
+ "\n"
Expand Down Expand Up @@ -400,57 +400,16 @@ public static void write(PrintWriter out, String packageName, boolean moduleRead
+ " return getCtx().module;\n"
+ " }\n"
+ "\n"
+ (moduleReader
? " /** Retrieve the root module-info reader if it can be read */\n"
+ " public static Optional<ModuleInfoReader> moduleInfoReader() {\n"
+ " if (getCtx().moduleReader == null) {\n"
+ " try {\n"
+ " getCtx().moduleReader = new ModuleInfoReader();\n"
+ " } catch (Exception e) {\n"
+ " // could not retrieve\n"
+ " }\n"
+ " }\n"
+ " return Optional.ofNullable(getCtx().moduleReader);\n"
+ " }\n\n"
: "")
+ " /**\n"
+ " * Gets a {@link BufferedReader} for the project's {@code module-info.java} source file.\n"
+ " *\n"
+ " * <p>Calling {@link ModuleElement}'s {@code getDirectives()} method has a chance of making\n"
+ " * compilation fail in certain situations. Therefore, manually parsing {@code module-info.java}\n"
+ " * seems to be the safest way to get module information.\n"
+ " *\n"
+ " * @return\n"
+ " * @throws IOException if unable to read the module-info\n"
+ " */\n"
+ " public static BufferedReader getModuleInfoReader() throws IOException {\n"
+ "\n"
+ " var modulePath = isTestCompilation() ? \"src/main/test\" : \"src/main/java\";\n"
+ " // some JVM implementations do not implement SOURCE_PATH so gotta find the module path by trying\n"
+ " // to find the src folder\n"
+ " var path = Path.of(filer().createResource(StandardLocation.CLASS_OUTPUT, \"\", UUID.randomUUID().toString()).toUri());\n"
+ " var i = 0;\n"
+ " while (i < 5 && path != null && !path.resolve(modulePath).toFile().exists()) {\n"
+ " i++;\n"
+ " path = path.getParent();\n"
+ " }\n"
+ "\n"
+ " var moduleFile = path.resolve(modulePath + \"/module-info.java\");\n"
+ " if (moduleFile.toFile().exists()) {\n"
+ " return new BufferedReader(new InputStreamReader(moduleFile.toUri().toURL().openStream()));\n"
+ " }\n"
+ "\n"
+ " // if that fails try same directory\n"
+ " moduleFile = Path.of(\"module-info.java\");\n"
+ " if (moduleFile.toFile().exists()) {\n"
+ " return new BufferedReader(new InputStreamReader(moduleFile.toUri().toURL().openStream()));\n"
+ " /** Retrieve the root module-info reader if it can be read */\n"
+ " public static Optional<ModuleInfoReader> moduleInfoReader() {\n"
+ " if (getCtx().moduleReader == null && getCtx().module != null && !getCtx().module.isUnnamed()) {\n"
+ " try {\n"
+ " getCtx().moduleReader = new ModuleInfoReader();\n"
+ " } catch (Exception e) {\n"
+ " // could not retrieve\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " // if that fails try via SOURCE_PATH\n"
+ " var sourcePath =\n"
+ " Path.of(filer().getResource(StandardLocation.SOURCE_PATH, \"\", \"module-info.java\").toUri());\n"
+ "\n"
+ " return new BufferedReader(new InputStreamReader(sourcePath.toUri().toURL().openStream()));\n"
+ " return Optional.ofNullable(getCtx().moduleReader);\n"
+ " }\n\n"
+ " /**\n"
+ " * Given the relative path, gets a {@link Path} from the Maven {@code target}/Gradle {@code build} folder.\n"
Expand Down
Loading