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 5.2 #102

Closed
radarsh opened this issue Dec 13, 2018 · 7 comments · Fixed by #107
Closed

Upgrade to Gradle 5.2 #102

radarsh opened this issue Dec 13, 2018 · 7 comments · Fixed by #107
Assignees
Milestone

Comments

@radarsh
Copy link
Owner

radarsh commented Dec 13, 2018

Upgrade to Gradle 5.2

@radarsh radarsh self-assigned this Dec 13, 2018
@GFriedrich
Copy link

GFriedrich commented Dec 18, 2018

Hi @radarsh,
can you make sure that with this upgrade the lines here

project.tasks.withType(Test).each { task ->
task.extensions.create('testlogger', TestLoggerExtension, project)
}
project.tasks.whenTaskAdded { task ->
if (task instanceof Test) {
task.extensions.create('testlogger', TestLoggerExtension, project)
}
}
are replaced by something like

project.tasks.withType(Test).configureEach { task ->
    task.extensions.create('testlogger', TestLoggerExtension, project)
}

Reason is that currently the call to whenTaskAdded results in all tasks of Gradle to be realized, which is discouraged by the Gradle team. (see also https://docs.gradle.org/current/userguide/task_configuration_avoidance.html)
Of course this would break backward compatibility so you need to add a check on the specific Gradle version you're running on.
In case you already knew that, I didn't say a word. 🤐

@radarsh
Copy link
Owner Author

radarsh commented Jan 23, 2019

This is going to be trickier than I thought as I am utilising whenTaskAdded as a hook to be able to create new extensions. Doing the same inside a configureEach block seems to result in an error.

@GFriedrich
Copy link

@radarsh: Oh ... weird ... it worked for me when applying your plugin by overriding the plugin class implementation to make it work for now with Gradle 5.

@radarsh
Copy link
Owner Author

radarsh commented Jan 23, 2019

I've got a branch if you want to try it. The acid test is to run ./gradlew clean build. I haven't made the switch to configureEach in the branch but if you make that change and run the above task, you will get an error.

@GFriedrich
Copy link

@radarsh: Worked just fine for me after switching to configureEach:

BUILD SUCCESSFUL in 1m 1s
14 actionable tasks: 14 executed

By the way: You could update to Gradle 5.1.1 too (I didn't do this for the test, just FYI).

@radarsh radarsh changed the title Upgrade to Gradle 5.0 Upgrade to Gradle 5.2 Feb 6, 2019
@radarsh
Copy link
Owner Author

radarsh commented Feb 6, 2019

Indeed it works. It was my bad as I was replacing just the line with whenTaskAdded which was resulting in the plugin attempting to add a duplicate extension resulting in an error.

@radarsh radarsh added this to the 2.0.0 milestone Mar 15, 2019
@radarsh radarsh pinned this issue Jun 19, 2019
@mattdkerr
Copy link

would love to have this addressed, as the plugin can't be configured as-is in gradle 5.x (although default config runs)

@radarsh radarsh unpinned this issue Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants