Skip to content

Commit 9bb56fa

Browse files
committed
Add workaround for 'transformation runs too early' issue
Fixes #15
1 parent 3c3ee71 commit 9bb56fa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/de/jjohannes/gradle/javamodules/ExtraModuleInfoTransform.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ public void transform(@Nonnull TransformOutputs outputs) {
8686
}
8787

8888
private boolean isModule(File jar) {
89+
if (!jar.isFile()) {
90+
// If the jar does not exist, we assume that the file, which is produced later is a local artifact and a module.
91+
// For local files this behavior is ok, because this transform is targeting published artifacts.
92+
// See also: https://github.com/jjohannes/extra-java-module-info/issues/15
93+
try {
94+
//noinspection ResultOfMethodCallIgnored
95+
jar.getParentFile().mkdirs();
96+
//noinspection ResultOfMethodCallIgnored
97+
jar.createNewFile();
98+
} catch (IOException e) {
99+
throw new RuntimeException(e);
100+
}
101+
return true;
102+
}
89103
try (JarInputStream inputStream = new JarInputStream(new FileInputStream(jar))) {
90104
boolean isMultiReleaseJar = containsMultiReleaseJarEntry(inputStream);
91105
ZipEntry next = inputStream.getNextEntry();

0 commit comments

Comments
 (0)