Skip to content

Commit 870ba59

Browse files
authored
Merge pull request quarkusio#36202 from cescoffier/ignore-module-info-in-dev-mode
2 parents ebe4832 + 7911bf5 commit 870ba59

File tree

6 files changed

+45
-4
lines changed

6 files changed

+45
-4
lines changed

core/deployment/src/main/java/io/quarkus/deployment/dev/CompilationProvider.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class Context {
5050
private final String targetJvmVersion;
5151
private final List<String> compilePluginArtifacts;
5252
private final List<String> compilerPluginOptions;
53+
private final boolean ignoreModuleInfo;
5354

5455
public Context(
5556
String name,
@@ -64,7 +65,7 @@ public Context(
6465
String sourceJavaVersion,
6566
String targetJvmVersion,
6667
List<String> compilePluginArtifacts,
67-
List<String> compilerPluginOptions) {
68+
List<String> compilerPluginOptions, String ignoreModuleInfo) {
6869
this.name = name;
6970
this.classpath = classpath;
7071
this.reloadableClasspath = reloadableClasspath;
@@ -78,6 +79,7 @@ public Context(
7879
this.targetJvmVersion = targetJvmVersion;
7980
this.compilePluginArtifacts = compilePluginArtifacts;
8081
this.compilerPluginOptions = compilerPluginOptions;
82+
this.ignoreModuleInfo = Boolean.parseBoolean(ignoreModuleInfo);
8183
}
8284

8385
public String getName() {
@@ -131,5 +133,9 @@ public List<String> getCompilePluginArtifacts() {
131133
public List<String> getCompilerPluginOptions() {
132134
return compilerPluginOptions;
133135
}
136+
137+
public boolean ignoreModuleInfo() {
138+
return ignoreModuleInfo;
139+
}
134140
}
135141
}

core/deployment/src/main/java/io/quarkus/deployment/dev/JavaCompilationProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public void compile(Set<File> filesToCompile, CompilationProvider.Context contex
7474

7575
final QuarkusFileManager.Context sourcesContext = new QuarkusFileManager.Context(
7676
context.getClasspath(), context.getReloadableClasspath(),
77-
context.getOutputDirectory(), context.getSourceEncoding());
77+
context.getOutputDirectory(), context.getSourceEncoding(),
78+
context.ignoreModuleInfo());
7879

7980
if (this.fileManager == null) {
8081
final Supplier<StandardJavaFileManager> supplier = () -> {

core/deployment/src/main/java/io/quarkus/deployment/dev/QuarkusCompiler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ public void setupSourceCompilationContext(DevModeContext context,
209209
context.getSourceJavaVersion(),
210210
context.getTargetJvmVersion(),
211211
context.getCompilerPluginArtifacts(),
212-
context.getCompilerPluginsOptions()));
212+
context.getCompilerPluginsOptions(),
213+
context.getBuildSystemProperties().getOrDefault("quarkus.live-reload.ignore-module-info",
214+
"true")));
213215
}
214216
}
215217
}

core/deployment/src/main/java/io/quarkus/deployment/dev/QuarkusDevModeLauncher.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ protected void prepare() throws Exception {
407407
devModeContext.getBuildSystemProperties().putIfAbsent("quarkus.application.name", applicationName);
408408
devModeContext.getBuildSystemProperties().putIfAbsent("quarkus.application.version", applicationVersion);
409409

410+
devModeContext.getBuildSystemProperties().putIfAbsent("quarkus.live-reload.ignore-module-info", "true");
411+
410412
devModeContext.setSourceEncoding(sourceEncoding);
411413
devModeContext.setCompilerOptions(compilerOptions);
412414

core/deployment/src/main/java/io/quarkus/deployment/dev/filesystem/QuarkusFileManager.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ public static class Context {
4444
private final Set<File> reloadableClassPath;
4545
private final File outputDirectory;
4646
private final Charset sourceEncoding;
47+
private final boolean ignoreModuleInfo;
4748

4849
public Context(Set<File> classPath, Set<File> reloadableClassPath,
49-
File outputDirectory, Charset sourceEncoding) {
50+
File outputDirectory, Charset sourceEncoding, boolean ignoreModuleInfo) {
5051
this.classPath = classPath;
5152
this.reloadableClassPath = reloadableClassPath;
5253
this.outputDirectory = outputDirectory;
5354
this.sourceEncoding = sourceEncoding;
55+
this.ignoreModuleInfo = ignoreModuleInfo;
5456
}
5557

5658
public Set<File> getClassPath() {
@@ -68,5 +70,9 @@ public File getOutputDirectory() {
6870
public Charset getSourceEncoding() {
6971
return sourceEncoding;
7072
}
73+
74+
public boolean ignoreModuleInfo() {
75+
return ignoreModuleInfo;
76+
}
7177
}
7278
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
11
package io.quarkus.deployment.dev.filesystem;
22

33
import java.io.File;
4+
import java.io.IOException;
5+
import java.util.concurrent.atomic.AtomicBoolean;
46
import java.util.function.Supplier;
57

68
import javax.tools.JavaFileObject;
79
import javax.tools.StandardJavaFileManager;
810

11+
import org.jboss.logging.Logger;
12+
913
/**
1014
* This static file manager handle the class-paths and file locations of a single manager instance.
1115
*/
1216
public class StaticFileManager extends QuarkusFileManager {
1317

18+
private final Context context;
19+
private final AtomicBoolean once = new AtomicBoolean();
20+
1421
public StaticFileManager(Supplier<StandardJavaFileManager> supplier, Context context) {
1522
super(supplier.get(), context);
23+
this.context = context;
1624
}
1725

1826
@Override
1927
public Iterable<? extends JavaFileObject> getJavaSources(Iterable<? extends File> files) {
2028
return this.fileManager.getJavaFileObjectsFromFiles(files);
2129
}
30+
31+
@Override
32+
public JavaFileObject getJavaFileForInput(Location location, String className, JavaFileObject.Kind kind)
33+
throws IOException {
34+
// Ignore the module info of the application in dev mode.
35+
if (context.ignoreModuleInfo() && "CLASS_OUTPUT".equalsIgnoreCase(location.getName())
36+
&& "module-info".equalsIgnoreCase(className)) {
37+
if (once.compareAndSet(false, true)) {
38+
Logger.getLogger(StaticFileManager.class).info("Ignoring module-info.java in dev mode, " +
39+
"set the `quarkus.live-reload.ignore-module-info` property to `false` in your project descriptor (`pom.xml` or `build.gradle`) to disable this behavior.");
40+
}
41+
return null;
42+
}
43+
return this.fileManager.getJavaFileForInput(location, className, kind);
44+
}
45+
2246
}

0 commit comments

Comments
 (0)