-
Notifications
You must be signed in to change notification settings - Fork 5
Lazily configure dependencies #1545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| project.getPluginManager().withPlugin("idea", _plugin -> { | ||
| IdeaModel ideaModel = project.getExtensions().getByType(IdeaModel.class); | ||
|
|
||
| ideaModel.getModule().getSourceDirs().add(generatedJavaDir.get().getAsFile()); |
There was a problem hiding this comment.
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.
| 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(); | ||
| })); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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)
...
There was a problem hiding this comment.
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
|
Released 0.36.0 |
Follow up from #1544 (comment).