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

[fix] gradle 6.4 incompatibility #71

Merged
merged 1 commit into from
May 24, 2020
Merged

Conversation

bomgar
Copy link

@bomgar bomgar commented May 18, 2020

closes #70

I actually have no idea what I'm doing here but it seems to work with 6.3 and 6.4.

@stevesaliman
Copy link
Collaborator

This doesn't seem to work fully on my system. There are no errors, but if I set a mainClassName in my build.gradle file, it doesn't get used. It is as if Gradle configures all the tasks, then processes the custom extensions, then executes the tasks. When I was calling setMain at execution time, I got the final value for all of the extension properties. When I call it in the configure phase, I don't

I'm curious to see if you get the same behavior. Can you try the following?

  1. Add a System.out.println to the OutputEnablingLiquibaseRunner. It doesn't matter what it says, you just want to see proof that the runner was used.
  2. Add mainClassName 'org.liquibase.gradle.OutputEnablingLiquibaseRunner' to the liquibase block of your build.gradle file
  3. Try running a liquibase task like gradlew dropAll. Do you see the output from step 1?

@bomgar
Copy link
Author

bomgar commented May 24, 2020

You're right it doesn't work. For some reason the mainClassName in the configure method is liquibase.integration.commandline.Main despite the configuration in build.gradle

@stevesaliman
Copy link
Collaborator

I think the issue is that configure() runs on once on each task when it is first created, which happens when the plugin is applied, but before Gradle has started processing the liquibase block is processed. This means we only ever get the default value. If we want the overridden value, we need to know how the value ended up, which was why I was using it at execution time.

I saw that the Lombok plugin had a similar issue - I wonder if they have a similar bug...

I also saw that there was a related Gradle issue that is now marked as closed. I'm starting to think that our best bet may be to wait for the next gradle release, though version 6.4.1 which was released after the gradle issue was closed still has the problem.

@bomgar
Copy link
Author

bomgar commented May 24, 2020

If I change the configure method like this:

	Task configure(Closure closure) {
		conventionMapping("main") {
			project.extensions.findByType(LiquibaseExtension.class).mainClassName
		}
		return super.configure(closure)
	}

it actually tries to load the configured main class. But:

Successfully started process 'command '/usr/lib/jvm/java-8-openjdk/bin/java''                                                                                              
Error: Could not find or load main class org.liquibase.gradle.OutputEnablingLiquibaseRunner                                                         

@bomgar
Copy link
Author

bomgar commented May 24, 2020

Ah I was missing the plugin in the liquibaseRuntime dependency. This actually seems to work now.

@bomgar
Copy link
Author

bomgar commented May 24, 2020

I pushed my changes. @stevesaliman Could you check again?

@stevesaliman stevesaliman merged commit 2bf2a60 into liquibase:master May 24, 2020
@stevesaliman
Copy link
Collaborator

That does indeed seem to work. I'm a little concerned about relying on an internal API, since they can change without warning, but at least it now works. The best part is that this won't break backwards compatibility.

Nice find, and thank you for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gradle 6.4 problems
2 participants