-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Fix projects that failed to build within Intellij #62258
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
/** Runs rest tests against external cluster */ | ||
// TODO: Remove this timeout increase once this test suite is broken up | ||
@TimeoutSuite(millis = 60 * TimeUnits.MINUTE) | ||
public class AbstractXPackRestTest extends ESClientYamlSuiteTestCase { |
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.
There are not any actual changes to this file...just renamed and moved back to the test source set.
I think this change this makes sense since independent of any other reason since there are a few runners that extend this... however the real reason i am introducing this is that I could not figure out how to get Intellij to share classes x-project and x-non-standard source set...it works fine from the test sourceset, but when shared from the custom source set (yamlRestTest) Intellij seems to have issues (the command line works fine).
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 believe that's due to setting up the source sets correctly. This should work, and we do it in other places.
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 believe that's due to setting up the source sets correctly. This should work, and we do it in other places.
I'm not sure I follow the comment... I tried a variety of ways to get Intellij to honor the configuration, it always works when defined in the test sourceset , but fails with identical config with a different sourceset name. I am sure I am missing something (or there is a bug in intellij), but not sure what. I don't believe it is related to the GradleUtils comment below since it is a different failure that addresses. Is there something specific you would like me to try ? I think this changes as-is actually a net positive change, with the benefit that it does not show red squiggly lines in Intellij.
from sourceSets.test.output | ||
from sourceSets.yamlRestTest.output | ||
from sourceSets.javaRestTest.output |
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 am pretty sure the only reason we expose this is for the yaml tests and the custom parent runner, both of which are (now) in the test source set...so only expose that in the jar and testArtifact config.
@@ -155,7 +155,7 @@ public static void setupIdeForTestSourceSet(Project project, SourceSet testSourc | |||
project.getPluginManager().withPlugin("idea", p -> { | |||
IdeaModel idea = project.getExtensions().getByType(IdeaModel.class); | |||
idea.getModule().setTestSourceDirs(testSourceSet.getJava().getSrcDirs()); | |||
idea.getModule().getScopes().put("TEST", Map.of("plus", List.of(runtimeClasspathConfiguration))); | |||
idea.getModule().getScopes().put(testSourceSet.getName(), Map.of("plus", List.of(runtimeClasspathConfiguration))); |
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 doesn't seem to have any functional impact, just noticed I missed this before and I think it is a bit more correct.
@@ -1,8 +1,8 @@ | |||
apply plugin: 'elasticsearch.yaml-rest-test' | |||
|
|||
dependencies { | |||
yamlRestTestImplementation project(path: xpackModule('core'), configuration: 'testArtifacts') | |||
yamlRestTestImplementation project(path: xpackModule('core')) |
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.
wierd dependency ordering thing...likely a subtle in Intellij
@@ -2,6 +2,8 @@ apply plugin: 'elasticsearch.java-rest-test' | |||
|
|||
dependencies { | |||
javaRestTestImplementation project(path: xpackProject('plugin').path, configuration: 'testArtifacts') | |||
// let the javaRestTest see the classpath of main | |||
javaRestTestImplementation project.sourceSets.main.runtimeClasspath |
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 might be why intellij gets confused. Instead we should add sourcets.main.runtimeClasspath
to sourcesets.javaRestTest.runtimeClasspath
rather than wire this up as a filecollection dependency. Basically, we should use GradleUtils.extendSourceSet()
here if we need javaRestTest
to "extend from" main
.
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.
relevant prior comment: https://github.com/elastic/elasticsearch/pull/59444/files/c89b5de16f777a00a7be76280565debd6014728f#diff-3f6ea6fd97c3537cc14d8d9f622aac7b
Are there any concerns with using GradleUtils here (and about 5 other places) ? Concerns with example project different from rest of the projects?
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.
Yes, since example projects are meant for external plugin authors to use as a baseline for their own projects. Internal use is not so much an issue.
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.
done 87c2493
@mark-vieira - ready for another pass. I had to add a method to GradleUtils that will re-load the classpath for a test task since these RestIntegTestTask's are eagerly created (as opposed to lazily like the internalClusterTests). d2aceef |
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.
👍
Thanks @mark-vieira ! |
Pinging @elastic/es-core-infra (:Core/Infra/Build) |
This commit address some build failures from the perspective of Intellij. These changes include: * changing an order of a dependency definition that seems to can cause Intellij build to fail. * introduction of an abstract class out of the test source set (seems to be an issue sharing classes cross projects with non-standard source sets. * a couple of missing dependency definitions (not sure how the command line worked prior to this) # Conflicts: # x-pack/qa/security-example-spi-extension/build.gradle
Thanks for this! I had been getting the build error, but this fixes the problem for me. |
) This commit address some build failures from the perspective of Intellij. These changes include: * changing an order of a dependency definition that seems to can cause Intellij build to fail. * introduction of an abstract class out of the test source set (seems to be an issue sharing classes cross projects with non-standard source sets. * a couple of missing dependency definitions (not sure how the command line worked prior to this)
This commit address some build failures from the perspective of Intellij.
These changes include:
classes cross projects with non-standard source sets.
This has been tested to work with
-> a clean checkout (clean -xdf) -> restart and invalidate cache -> rebuild project and no errors.