Skip to content

Commit

Permalink
Use runtime classpath to run generator
Browse files Browse the repository at this point in the history
fixes: #260

The old use of compile time classpath wasn't bringing in transient dependencies from modules. Using runtime classpath does.

Also added some logging to help debug future issues.
  • Loading branch information
big-andy-coates committed Jun 24, 2024
1 parent 5dc3618 commit 92c18c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private void registerGenerateSchemaTask(
afterEvaluate(
proj,
GENERATE_SCHEMA_TASK_NAME,
JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME,
JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME,
List.of(
JavaPlugin.COMPILE_JAVA_TASK_NAME,
"compileKotlin",
Expand All @@ -144,7 +144,7 @@ private void registerGenerateTestSchemaTask(
afterEvaluate(
proj,
GENERATE_TEST_SCHEMA_TASK_NAME,
JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME,
JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME,
List.of(
JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME,
"compileTestKotlin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,17 +251,30 @@ public void setExtraArgumentsFromOption(final List<String> args) {
public void run() {
checkDependenciesIncludesRunner();

final boolean useModulePath = useModulePath();
final List<String> arguments = arguments();
final List<String> jvmArgs = jvmArgs();

if (getLogger().isInfoEnabled()) {
getLogger().info("Executing JSON schema generator with:");
getLogger().info("useModulePath: {}", useModulePath);
getLogger().info("arguments: {}", arguments);
getLogger().info("jvmArgs: {}", jvmArgs);
getLogger().info("classpath:");
classPath.forEach(f -> getLogger().info(f.getAbsolutePath()));
}

getProject()
.javaexec(
spec -> {
spec.getMainClass()
.set(
"org.creekservice.api.json.schema.generator.JsonSchemaGenerator");
spec.getMainModule().set("creek.json.schema.generator");
spec.getModularity().getInferModulePath().set(useModulePath());
spec.getModularity().getInferModulePath().set(useModulePath);
spec.setClasspath(classPath);
spec.setArgs(arguments());
spec.jvmArgs(jvmArgs());
spec.setArgs(arguments);
spec.jvmArgs(jvmArgs);
});
}

Expand Down

0 comments on commit 92c18c8

Please sign in to comment.