Skip to content

Conversation

@pkoenig10
Copy link
Member

@pkoenig10 pkoenig10 commented Oct 23, 2025

Follow up from #1544 (comment).

project.getPluginManager().withPlugin("idea", _plugin -> {
IdeaModel ideaModel = project.getExtensions().getByType(IdeaModel.class);

ideaModel.getModule().getSourceDirs().add(generatedJavaDir.get().getAsFile());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary. The IDEA plugin knows the source and resource directories from the source sets. The only thing it can't know is which source directories should be considered generated sources.

Comment on lines +136 to +145
metricSchemaSourceDirectorySet.getElements().map(files -> {
// Don't add dependencies if we're not going to generate code
if (files.isEmpty()) {
return List.of();
}

return dependencies.stream()
.map(project.getDependencies()::create)
.toList();
}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we end up doing this, I wonder if it would be possible to inspect the outputs from GenerateMetricsTask instead, as this is the actual codegen task, which means we could actually check whether files were generated, rather than rely on the inputs existing. Both should work, but the latter seems semantically more correct

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation seems better to me - I don't think we want dependency resolution to depend on the result of running tasks. If we can know this information without executing the task, that seems preferrable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this in b8c9b8f.

It looks like this doesn't set up a task dependency, so dependency resolution just fails if the task has not yet been run and the output directory does not exist.

https://app.circleci.com/pipelines/github/palantir/metric-schema/5077/workflows/0e731f44-c7f7-4cfb-a789-dbd257cf68c7/jobs/16689/tests

org.gradle.api.GradleException: Build aborted because of an internal error.
	at nebula.test.functional.internal.DefaultExecutionResult.rethrowFailure(DefaultExecutionResult.groovy:97)
	at nebula.test.Integration$Trait$Helper.runTasksSuccessfully(Integration.groovy:151)
	at com.palantir.metric.schema.gradle.MetricSchemaPluginIntegrationSpec.setup(MetricSchemaPluginIntegrationSpec.groovy:91)
Caused by: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'generates-java'.
	...
Caused by: org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'generates-java'.
	...
Caused by: java.io.UncheckedIOException: java.nio.file.NoSuchFileException: /home/circleci/project/gradle-metric-schema/build/nebulatest/com.palantir.metric.schema.gradle.MetricSchemaPluginIntegrationSpec/generates-java/build/generated/sources/metricSchema/java/main
	at com.palantir.metric.schema.gradle.MetricSchemaPlugin.lambda$configureDependencies$7(MetricSchemaPlugin.java:149)
	...
Caused by: java.nio.file.NoSuchFileException: /home/circleci/project/gradle-metric-schema/build/nebulatest/com.palantir.metric.schema.gradle.MetricSchemaPluginIntegrationSpec/generates-java/build/generated/sources/metricSchema/java/main
	at org.gradle.internal.classpath.declarations.NioFileInterceptors.intercept_list(NioFileInterceptors.java:274)
	at com.palantir.metric.schema.gradle.MetricSchemaPlugin.lambda$configureDependencies$7(MetricSchemaPlugin.java:144)
	...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's too bad, but your earlier point makes sense anyway, so this is fine by me

@bulldozer-bot bulldozer-bot bot merged commit 83042b2 into develop Oct 23, 2025
5 checks passed
@bulldozer-bot bulldozer-bot bot deleted the pkoenig/dependencies branch October 23, 2025 15:17
@autorelease3
Copy link

autorelease3 bot commented Oct 23, 2025

Released 0.36.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants