Skip to content

Conversation

@jasontedor
Copy link
Member

This commit simplifies how we find jps to instead use built-in Gradle functionality for the same.

Relates #45666

This commit simplifies how we find jps to instead use built-in Gradle
functionality for the same.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Contributor

@mark-vieira mark-vieira left a comment

Choose a reason for hiding this comment

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

One comment, otherwise LGTM.

if (!jps.exists()) {
throw new GradleException("jps executable not found; ensure that you're running Gradle with the JDK rather than the JRE")
}
final File jps = Jvm.forHome(project.runtimeJavaHome).getExecutable('jps')
Copy link
Contributor

Choose a reason for hiding this comment

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

So project.runtimeJavaHome may or may not be Java home used to run the build. Since jps in this case is a build dependency, it seems to make sense to use the Java runtime that Gradle is using via Jvm.current(). Realistically, we should be able to set RUNTIME_JAVA_HOME to a JRE, since it's just used for execution bits, not anything build related.

Copy link
Member Author

Choose a reason for hiding this comment

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

So project.runtimeJavaHome may or may not be Java home used to run the build.

Yup. The way I’ve always thought of it is:

  • we have the JVM running Gradle
  • we have the JVM compiling code (compiler Java home)
  • we have the JVM running tests and all other executions that require a JVM (runtime Java home)

It’s not perfect (I think third-party audit runs in the Gradle JVM, although we want to move it out). I’d rather not break this mental model more though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, giving this another think this makes sense. We should use the same version of jps that's used to launch any ES processes, even though it's actually the build that's executing jps here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Precisely.

Copy link
Contributor

Choose a reason for hiding this comment

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

ThirdPartyAuditTask does have a javaHome property which we set to runtimeJavaHome.
CheckForbiddenApis runs in the same jvm ( does not work ) and has a target compatibility specific
to runtimeJavaVersion

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the correction @atorok, I knew there was a precommit task that runs in the Gradle JVM that we ideally would want running in the runtime Java home JVM, I couldn't remember which though.

Copy link
Contributor

@mark-vieira mark-vieira Aug 19, 2019

Choose a reason for hiding this comment

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

We actually are slowly migrating to the opposite @jasontedor. There's no reason for most precommit checks to run in the runtime JVM when javac, checkstyle and most other build-time verification runs using the Gradle JVM. These are "build" operations, not runtime ones so realistically they should run the the Gradle JVM. Also, forking them has a significant build time penalty as we are creating and throwing away lots of JVMs for each of these tasks.

This is a separate issue though and I think the usage of runtimeJavaHome is appropriate in this case. For others, we'll address them case-by-case but we are definitely misusing it in several places.

@jasontedor jasontedor merged commit 68d0385 into elastic:master Aug 16, 2019
jasontedor added a commit that referenced this pull request Aug 16, 2019
This commit simplifies how we find jps to instead use built-in Gradle
functionality for the same.
@jasontedor jasontedor removed the v6.8.3 label Aug 16, 2019
@jasontedor jasontedor deleted the jps-executable branch August 16, 2019 22:50
Copy link
Contributor

@alpar-t alpar-t left a comment

Choose a reason for hiding this comment

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

LGTM

jakelandis added a commit to elastic/elasticsearch-hadoop that referenced this pull request Aug 23, 2019
As of elastic/elasticsearch#45677 build tools
now uses a function that requires JavaHome to be a File type.

This commit updates the JavaHome property to be a File type. This
commit also bumps the latest supported version of build-tools 
(8.0.0-SNAPSHOT is not supported yet).
jakelandis added a commit to elastic/elasticsearch-hadoop that referenced this pull request Aug 23, 2019
As of elastic/elasticsearch#45677 build tools
now uses a function that requires JavaHome to be a File type.

This commit updates the JavaHome property to be a File type.
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Delivery/Build Build or test infrastructure >non-issue Team:Delivery Meta label for Delivery team v7.4.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants