Skip to content

Recipe to remove build cache configuration for Develocity #6466

@div-bargali

Description

@div-bargali

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v1.2.3
  • Maven/Gradle plugin v1.2.3
  • rewrite-module v1.2.3

How are you running OpenRewrite?

The tests that are present currently works because buildCache extension is added inside the develocity extension in the test cases. This is incorrect configuration.

The buildCache extension is made available by Gradle and not Develocity, so it will always be present as a standalone extension in the settings.gradle(.kts) file.
(Refer - https://docs.gradle.com/develocity/gradle/current/gradle-plugin/#using_the_develocity_connector)

What is the smallest, simplest way to reproduce the problem?

buildCache {
  remote(HttpBuildCache) {
    url = "some-url"
    push = true
    enabled = true
  }
}

What did you expect to see?

// buildCache configuration removed

What did you see instead?

Unit tests fail.

What is the full stack trace of any errors you encountered?

> Task :rewrite-gradle:test

RemoveDevelocityTest > develocityBuildCacheWithAdvancedConfiguration() FAILED
    org.opentest4j.AssertionFailedError: [Unexpected result in "settings.gradle":
    diff --git a/settings.gradle b/settings.gradle
    index e69de29..3f74314 100644
    --- a/settings.gradle
    +++ b/settings.gradle
    @@ -0,0 +1,9 @@ 
    +
    +
    +buildCache {
    +    remote(develocity.buildCache) {
    +        enabled = true
    +        push = true
    +        // DevelocityBuildCache connector configuration
    +    }
    +}
    \ No newline at end of file
    ] 
    expected: 
      ""
     but was: 
      "
  
      buildCache {
          remote(develocity.buildCache) {
              enabled = true
              push = true
              // DevelocityBuildCache connector configuration
          }
      }"
        at app//org.openrewrite.test.RewriteTest.assertContentEquals(RewriteTest.java:644)
        at app//org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:534)
        at app//org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:132)
        at app//org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:127)
        at app//org.openrewrite.gradle.plugins.RemoveDevelocityTest.develocityBuildCacheWithAdvancedConfiguration(RemoveDevelocityTest.java:123)

RemoveDevelocityTest > develocityBuildCacheConnectorConfiguration() FAILED
    org.opentest4j.AssertionFailedError: [Unexpected result in "settings.gradle":
    diff --git a/settings.gradle b/settings.gradle
    index e69de29..0fcda9b 100644
    --- a/settings.gradle
    +++ b/settings.gradle
    @@ -0,0 +1,8 @@ 
    +
    +
    +buildCache {
    +    remote(develocity.buildCache) {
    +        // Build Cache connector is registered and configured
    +        enabled = true
    +    }
    +}
    \ No newline at end of file
    ] 
    expected: 
      ""
     but was: 
      "
  
      buildCache {
          remote(develocity.buildCache) {
              // Build Cache connector is registered and configured
              enabled = true
          }
      }"
        at app//org.openrewrite.test.RewriteTest.assertContentEquals(RewriteTest.java:644)
        at app//org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:534)
        at app//org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:132)
        at app//org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:127)
        at app//org.openrewrite.gradle.plugins.RemoveDevelocityTest.develocityBuildCacheConnectorConfiguration(RemoveDevelocityTest.java:98)

4 tests completed, 2 failed

Are you interested in contributing a fix to OpenRewrite?

Yes, I will add a fix for this in my PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtest providedAlready replicated with a unit test, using JUnit pioneer's ExpectedToFail

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions