Skip to content

Commit 0360fb9

Browse files
authored
Merge pull request #131 from KyoriPowered/feat/98
feat: Automatically configure project module version for Indra projects
2 parents a266700 + f2df533 commit 0360fb9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

indra-common/src/main/java/net/kyori/indra/IndraPlugin.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ public void apply(final @NotNull Project project, final @NotNull PluginContainer
105105
});
106106
this.applyIdeConfigurationOptions(project.getPluginManager(), extensions, tasks);
107107

108+
final Provider<String> projectVersion = project.provider(() -> {
109+
final String raw = String.valueOf(project.getVersion());
110+
if (raw.equals("unspecified")) {
111+
return null;
112+
} else {
113+
return raw;
114+
}
115+
});
108116
tasks.withType(JavaCompile.class).configureEach(task -> {
109117
final CompileOptions options = task.getOptions();
110118
options.getCompilerArgs().addAll(Arrays.asList(
@@ -116,6 +124,9 @@ public void apply(final @NotNull Project project, final @NotNull PluginContainer
116124

117125
// Enable preview features if option is set in extension
118126
options.getCompilerArgumentProviders().add(indra.previewFeatureArgumentProvider());
127+
128+
// Provide a module version when compiling module infos
129+
options.getJavaModuleVersion().set(projectVersion);
119130
});
120131

121132
tasks.withType(JavaExec.class).configureEach(task -> {

0 commit comments

Comments
 (0)