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

Replace custom caching with Gradle's incremental build #1187

Merged

Conversation

anatoliy-balakirev
Copy link
Contributor

Replaced custom caching of the downloaded contracts with Gradle's
incremental build. After that InitContractsTask is not needed any
more, as its main purpose was to be a bridge between custom caching
and Gradle's one. Simplified code to download contracts is now part of
the ContractsCopyTask.

Fixes gh-1133

Copy link
Contributor

@marcingrzejszczak marcingrzejszczak left a comment

Choose a reason for hiding this comment

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

Lgtm!

Have you checked it against the 2.2.x od spring cloud contract samples?

@anatoliy-balakirev
Copy link
Contributor Author

I'm trying to do it now. So far checked against two projects: one from there, that was failing before and one my private sample. Is there some way to check it against spring cloud contract samples automatically somehow or should be checked manually for each sub project?

@marcingrzejszczak
Copy link
Contributor

You can run the scripts in the scripts folder. One is responsible for running the gradle tests.

@anatoliy-balakirev
Copy link
Contributor Author

I executed that script and found a couple more issues with PublishStubsToScmTask. It used to be customisable, which was lost during migration (previous big PR). Also incremental build can't be used there as there is no clear output (or at least I'm not understanding it good enough to define it). Fixed both of those.

@anatoliy-balakirev
Copy link
Contributor Author

@marcingrzejszczak is there some new issue with CI? It's now constantly failing with [INFO] Spring Cloud Contract Verifier ..................... FAILURE [ 39.185 s], but that module wasn't touched by my changes (and it works locally).

@anatoliy-balakirev
Copy link
Contributor Author

Found one more issue there: in the copy contracts task contractsDirectory had a default, pointing to contracts folder in resources and was failing the build if that directory was not present (e.g. when contracts are downloaded). Fixed that.

@anatoliy-balakirev
Copy link
Contributor Author

So I executed runGradleBuilds.sh and everything was ok (for producers), except for following two:

In the producer_with_empty_git I got:

Caused by: org.eclipse.jgit.errors.NotSupportedException: URI not supported: file://null/target/contract_empty_git/.git
        at org.eclipse.jgit.transport.Transport.open(Transport.java:561)
        at org.eclipse.jgit.transport.Transport.open(Transport.java:429)
        at org.eclipse.jgit.transport.Transport.open(Transport.java:308)
        at org.eclipse.jgit.transport.Transport.open(Transport.java:277)
        at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:236)
        ... 97 more

Looks like this: repositoryUrl = "git://file://${System.getenv("ROOT")}/target/contract_empty_git/" is not getting
set properly.
If I replace it with my root like this:
repositoryUrl = "git://file://Users/anatolii.balakiriev/Developer/spring-cloud-contract-samples/target/contract_empty_git/"

Getting another error. Seems to be some issue with that module...

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':publishStubsToScm'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:148)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:145)
	at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:138)
	at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
	at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
	at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:73)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.IllegalStateException: Exception occurred while cloning repo
	at org.springframework.cloud.contract.stubrunner.GitRepo.cloneProject(GitRepo.java:116)
	at org.springframework.cloud.contract.stubrunner.GitContractsRepo.clonedRepo(ScmStubDownloaderBuilder.java:142)
	at org.springframework.cloud.contract.stubrunner.ContractProjectUpdater.updateContractProject(ContractProjectUpdater.java:76)
	at org.springframework.cloud.contract.verifier.plugin.PublishStubsToScmTask.publishStubsToScm(PublishStubsToScmTask.groovy:142)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:48)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:702)
	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:669)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:401)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:390)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:373)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:79)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:210)
	at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$1(ExecuteStep.java:33)
	at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:33)
	at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
	at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
	at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
	at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
	at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
	at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
	at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
	at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
	at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
	at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
	at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
	at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
	at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:201)
	at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:70)
	at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
	at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
	at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
	at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
	at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
	at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
	at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:77)
	at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
	at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
	at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
	at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:117)
	... 35 more
Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of fetch command
	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:261)
	at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:302)
	at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:200)
	at org.springframework.cloud.contract.stubrunner.GitRepo.cloneToBasedir(GitRepo.java:214)
	at org.springframework.cloud.contract.stubrunner.GitRepo.cloneProject(GitRepo.java:107)
	... 93 more
Caused by: org.eclipse.jgit.errors.NotSupportedException: URI not supported: file://Users/anatolii.balakiriev/Developer/spring-cloud-contract-samples/target/contract_empty_git/.git
	at org.eclipse.jgit.transport.Transport.open(Transport.java:561)
	at org.eclipse.jgit.transport.Transport.open(Transport.java:429)
	at org.eclipse.jgit.transport.Transport.open(Transport.java:308)
	at org.eclipse.jgit.transport.Transport.open(Transport.java:277)
	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:236)
	... 97 more

Skipped for now.

producer_proto is failing with:
/Users/anatolii.balakiriev/Developer/spring-cloud-contract-samples/producer_proto/src/main/bash/generate_proto.sh: line 11: target/protoc/bin/protoc: cannot execute binary file
Not sure, what it is. Skipped for now.

@marcingrzejszczak if you have those two set up locally - can you pls, check if they work for you? (with my latest changes)

Consumer module got some failed tests. I didn't check that further because didn't actually touch that part.

@anatoliy-balakirev
Copy link
Contributor Author

  1. producer_with_empty_git also fails in master with exactly the same. So seems to be just broken.
  2. producer_proto I managed to get working by installing protobuf locally and adjusting the script to use that (also aligning version in build.gradle with that one). So all good (however, that sample is quite not portable. Would be good to do something about it longer term).
  3. consumer is also failing in master.

@marcingrzejszczak
Copy link
Contributor

Meh, I'll check it out

@marcingrzejszczak
Copy link
Contributor

producer_with_empty_git also fails in master with exactly the same. So seems to be just broken.
consumer is also failing in master.

So master branch works fine locally and on our Jenkins. It's a problem with circleci. So the producer_with_empty_git is NOT broken. If it's broken for you locally on 2.2.x that means that the Gradle feature broke the sample.

producer_proto I managed to get working by installing protobuf locally and adjusting the script to use that (also aligning version in build.gradle with that one). So all good (however, that sample is quite not portable. Would be good to do something about it longer term).

good idea. I thought that it was portable but apparently it's not.

@anatoliy-balakirev
Copy link
Contributor Author

So the producer_with_empty_git is NOT broken. If it's broken for you locally on 2.2.x that means that the Gradle feature broke the sample.

Well, it's broken for me in both: master and 2.2.x branch and if it works for you in master then it's definitely something with my local setup... Could you pls, check if it works for you in branch 2.2.x with gradle plugin from this PR or suggest how to run it locally so that I can do it? Currently that's the only producer I didn't check against this PR. All other producers seem to work fine.

@marcingrzejszczak
Copy link
Contributor

Well, it's broken for me in both: master and 2.2.x branch and if it works for you in master then it's definitely something with my local setup... Could you pls, check if it works for you in branch 2.2.x with gradle plugin from this PR or suggest how to run it locally so that I can do it? Currently that's the only producer I didn't check against this PR. All other producers seem to work fine.

😬 how does it fail for you locally? What is the problem?

@anatoliy-balakirev
Copy link
Contributor Author

@marcingrzejszczak check my comment with two big stacktraces above. (producer_proto I eventually fixed, so that you can ignore)

@marcingrzejszczak
Copy link
Contributor

change

 repositoryUrl = "git://file://Users/anatolii.balakiriev/Developer/spring-cloud-contract-samples/target/contract_empty_git/"

to

 repositoryUrl = "git://file:///Users/anatolii.balakiriev/Developer/spring-cloud-contract-samples/target/contract_empty_git/"

you're missing one / in file cause the protocol is file:// and the path is /Users/...

@anatoliy-balakirev
Copy link
Contributor Author

Oh, I see... Thanks! :) With that it all works fine! (almost, see below) So all producers are good with this PR.
There are some failing tests, but I believe they have nothing to do with my changes to Gradle plugin (as generated test code is more less the same):

Caused by: java.lang.IllegalStateException: @ConditionalOnMissingBean did not specify a bean using type, name or annotation and the attempt to deduce the bean's type failed
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.validate(OnBeanCondition.java:483)
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.<init>(OnBeanCondition.java:430)
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:140)
	at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
	... 66 more
Caused by: org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanTypeDeductionException: Failed to deduce bean type for org.springframework.cloud.stream.config.BindersHealthIndicatorAutoConfiguration.bindersHealthContributor
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.deducedBeanTypeForBeanMethod(OnBeanCondition.java:513)
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.deducedBeanType(OnBeanCondition.java:502)
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.<init>(OnBeanCondition.java:423)
	... 68 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/actuate/health/CompositeHealthContributor
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.springframework.boot.autoconfigure.condition.FilteringSpringBootCondition.resolve(FilteringSpringBootCondition.java:108)
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.getReturnType(OnBeanCondition.java:521)
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.deducedBeanTypeForBeanMethod(OnBeanCondition.java:509)
	... 70 more
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.actuate.health.CompositeHealthContributor
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 85 more

@marcingrzejszczak
Copy link
Contributor

Ok so please resolve the conflicts and let's merge it. I'm still working on the build stability ;)

Replaced custom caching of the downloaded contracts with Gradle's
incremental build. After that `InitContractsTask` is not needed any
more, as its main purpose was to be a bridge between custom caching
and Gradle's one. Simplified code to download contracts is now part of
the `ContractsCopyTask`.
Also fixed `PublishStubsToScmTask` and removed incremental stuff from
there for now.

Fixes spring-cloudgh-1133
@anatoliy-balakirev
Copy link
Contributor Author

The latest build (synced with the latest master) failed with:

[INFO] Expiring Daemon because JVM heap space is exhausted
[INFO] Expiring Daemon because JVM heap space is exhausted
[INFO] Expiring Daemon because JVM heap space is exhausted
[INFO] Daemon is stopping immediately JVM garbage collector thrashing and after running out of JVM memory

@marcingrzejszczak
Copy link
Contributor

Meh, it's all about CircleCI and the memory. I think I've managed to finally fix it. Other than that I'll just merge this.

@marcingrzejszczak marcingrzejszczak added this to the 2.2.0.M3 milestone Aug 28, 2019
@marcingrzejszczak marcingrzejszczak merged commit d474070 into spring-cloud:master Aug 28, 2019
@anatoliy-balakirev
Copy link
Contributor Author

Cool, thx! Let me know if there are other issues caused by my PR.

@marcingrzejszczak
Copy link
Contributor

The following DSL fails to work and it used to:

contracts {
		baseClassForTests = "com.example.demo.BaseClass"
		contractsPath = "/"
		// pre Grenwich (2.1.0)
		contractsSnapshotCheckSkip = true
		contractRepository {
			repositoryUrl('http://localhost:8081/artifactory/libs-release-local')
		}
		setContractsMode("REMOTE")
		contractDependency {
			groupId = project.group
			artifactId = project.name
			delegate.classifier = "stubs"
			delegate.version = getProp("latestProductionVersion")
		}
	}

due to

13:51:11 * What went wrong:
13:51:11 A problem occurred evaluating root project '04_10_ci'.
13:51:11 > No signature of method: static org.springframework.cloud.contract.verifier.plugin.ContractVerifierExtension.repositoryUrl() is applicable for argument types: (String) values: [http://localhost:8081/artifactory/libs-release-local]

so apparently methods that used to have closures don't work anymore

@anatoliy-balakirev
Copy link
Contributor Author

Weird that is tries to get it from: ContractVerifierExtension.repositoryUrl()
There is this method (in fact, it was there before; that part wasn't changed):

	void contractRepository(@DelegatesTo(ContractRepository) Closure closure) {
		closure.delegate = contractRepository
		closure.call()
	}

And I would expect it to be looking for that repositoryUrl method in the ContractRepository as that method suggests...
Do you have some sample project to give it a try? I can't check it right now, but can take a look a bit later.

@marcingrzejszczak
Copy link
Contributor

Maybe it's related to the fact that contractRepository here is null? we used to create a new ContractRepository object, but now with this new, fabulous API we have to have it injected. I have no idea how the closures are supposed to work now.

void contractRepository(@DelegatesTo(ContractRepository) Closure closure) {
		closure.delegate = contractRepository
		closure.call()
	}

@marcingrzejszczak
Copy link
Contributor

That might have been an issue with Gradle cache. Gradle's incompatibility with local maven repo is astonishing.

@anatoliy-balakirev
Copy link
Contributor Author

Oh, ok. So it works?

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

Successfully merging this pull request may close these issues.

Support Up-to-date checks (AKA Incremental Build) in Gradle plugin
3 participants