Skip to content
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

Upgrade to Gradle Wrapper 4.8 #31271

Closed
wants to merge 17 commits into from
Closed

Conversation

alpar-t
Copy link
Contributor

@alpar-t alpar-t commented Jun 12, 2018

relates to #31230 : move to gradle 4.8 so we can start using JDK 11 in CI

Changes:

@alpar-t alpar-t added >non-issue :Delivery/Build Build or test infrastructure labels Jun 12, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@@ -561,3 +561,27 @@ gradle.projectsEvaluated {
}
}
}

apply plugin: 'compare-gradle-builds'
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should keep this long term. I just feel like we won't need it again for six months and when we want it again we'll have to edit all of this to make it work.

Copy link
Member

Choose a reason for hiding this comment

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

Is it worth applying the plugin at all if we don't have build.compare set?

if (assemble) {
assemble.dependsOn(t)
project.getGradle().getTaskGraph().whenReady {
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom t ->
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment with the gradle issue number?

@@ -1,6 +1,6 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
distributionBase=GRADLE_USER_HOME
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -625,6 +630,10 @@ class BuildPlugin implements Plugin<Project> {
jarTask.manifest.attributes('Change': shortHash)
}
}
// Force manifest entries that change by nature to a constant to be able to compare builds more effectively
Copy link
Member

Choose a reason for hiding this comment

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

I feel the same way about this one too. Until we need it again it'll sit there making folks wonder "when do we set this!?" and when we finally go to use it again we'll need to make other changes.

Copy link
Member

Choose a reason for hiding this comment

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

I think it is worth adding something like "when comparing builds, force manifest entries..." that way it is clear to the reader that we only do this when it is required to compare builds.

configuration.resolutionStrategy.failOnVersionConflict()
configuration.resolutionStrategy {
failOnVersionConflict()
preferProjectModules()
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment with the gradle issue number?

@@ -106,7 +106,6 @@ GradleVersion logVersion = GradleVersion.current() > GradleVersion.version('4.3'

dependencies {
compileOnly "org.gradle:gradle-logging:${logVersion.getVersion()}"
compile 'ru.vyarus:gradle-animalsniffer-plugin:1.2.0' // Gradle 2.14 requires a version > 1.0.1
Copy link
Member

Choose a reason for hiding this comment

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

👍

@alpar-t
Copy link
Contributor Author

alpar-t commented Jun 12, 2018

I don't have a strong opinion on comparing the builds. I don't like the change to generate an empty manifest, but unfortunately the plugin doesn't give us any options to influence how it compares ( however it does seem from how it's implemented it's a future goal ). That being said, I think this will be useful way sooner than 6 months. In fact I think that it will be useful as a sanity check for most build related changes, just looking at what I plan to do next, comparing building with jdk11, and dealing with deprications in 4.8, like stable publishing, i'll be able to use this.

@nik9000
Copy link
Member

nik9000 commented Jun 12, 2018

Do you think it'd make sense to only set up the compare plugin if you set -Dbuild.compare=path_to_reference?

@alpar-t
Copy link
Contributor Author

alpar-t commented Jun 12, 2018

@nik9000 generally, I like command line options with conventions that help one avoid typing, but in this case, it could replace -Dbuild.compare_friendly because we could just check that the property is set, making it less confusing. Could also have -Dbuild.compare=true and default to the current path, or even --build-compare=. As a side note, I think it would make sense to start moving from properties to options for things that we expect to change for different use-cases ( e.x. in CI ) and restrict the scope of properties to debugging. In other words, properties that act as arguments should really be arguments.

@nik9000
Copy link
Member

nik9000 commented Jun 12, 2018

As a side note, I think it would make sense to start moving from properties to options for things that we expect to change for different use-cases ( e.x. in CI ) and restrict the scope of properties to debugging. In other words, properties that act as arguments should really be arguments.

We had some options but we had them integrated in way that caused trouble and we ended up switching to options.

I'd prefer we not develop a convention for "where to check out the old version of Elasticsearch to compare the builds" so I like the idea of a command line option for it. And as a side benefit we don't have to apply the plugin if you don't set the option.

@alpar-t
Copy link
Contributor Author

alpar-t commented Jun 13, 2018

ci, test this please

@alpar-t
Copy link
Contributor Author

alpar-t commented Jun 14, 2018

@nik9000 I just added a property to make build compare conditional for now, we'll see where it goes from here. There's also a work around for #31324 to get the tests passing.

@@ -221,14 +221,16 @@ static Policy readPolicy(URL policyFile, Map<String, URL> codebases) {
if (aliasProperty.equals(property) == false) {
propertiesSet.add(aliasProperty);
String previous = System.setProperty(aliasProperty, url.toString());
if (previous != null) {
// allow to re-set to what was previously there. https://github.com/elastic/elasticsearch/issues/31324
Copy link
Member

Choose a reason for hiding this comment

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

When I pulled this locally and reverted the changes to this file I didn't have any trouble. We've traditionally been very weary of making changes to this file so I'd really like to make sure we need this before we do it, even if it is temporary.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, wait, I just got it! Neat.

Copy link
Member

Choose a reason for hiding this comment

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

This looks like it is caused by gradle not passing any system properties to the test sometimes. We use the absence of a system property set by gradle to engage "IDE mode" when running tests which mucks with the security features a bit. If you run tests from gradle in IDE mode they won't work right. Security, at least, won't work right. If these were to happen for other tests then it'd explode in other ways.

Copy link
Member

Choose a reason for hiding this comment

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

I've dug some more. This is caused by us running the tests with the built in gradle test runner rather than the randomized runner. We configure the randomized runner to run with the system properties but we don't ever configure the standard runner.

Copy link
Member

Choose a reason for hiding this comment

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

And some more: this is not caused by the build compare plugin. Maybe by gradle 4.8 or maybe by one of our hacks to make 4.8 work.

Copy link
Member

Choose a reason for hiding this comment

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

Ok - I reverted the 4.8 change locally but kept the other changes and everything looks to work. I don't think we can upgrade to 4.8 until we get to the bottom of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for looking into this @nik9000. I'll create a feature branch.
I won't revert this change just yet, as it does allow us to uncover additional issues, like the CI run here just found, the build hangs, and it's easily reproducible with ./gradlew :example-plugins:painless-whitelist:check.
This upgrade of Gradle and JDK is turning out to be much harder than it should.

I was under the impression that we always replace the Gradle test runner with the randomized one. I wonder if for some reason that doesn't happen, or doesn't always happen for some reason. I did have a suspicion that we are not running with the randomized runner, but when I looked at it I didn't find evidence of this being the case.

@ywelsch ywelsch mentioned this pull request Jun 18, 2018
@dobbbb
Copy link

dobbbb commented Jun 18, 2018

help!!!😭
gradle idea

  • Where:
    Build file '/Users/zhouwuhong/elasticsearch/benchmarks/build.gradle' line: 31

  • What went wrong:
    A problem occurred evaluating project ':benchmarks'.

Failed to apply plugin [id 'elasticsearch.build']
JAVA_HOME must be set to build Elasticsearch

but!!!!!
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home

@alpar-t
Copy link
Contributor Author

alpar-t commented Jun 18, 2018

Closing this as the work was move to feature/31230_gradle48_jdk11 branch.

@alpar-t alpar-t closed this Jun 18, 2018
@alpar-t alpar-t deleted the upgrade/gradle_4.8 branch June 18, 2018 14:50
@alpar-t
Copy link
Contributor Author

alpar-t commented Jun 18, 2018

@doubleuhy I added that to #31399. Please find the proper channels to communicate. This has nothing to do with this PR, having it hare makes everything more difficult to track and organize PR.

@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants