What the agent does
Gradle 7.0 removed the compile, runtime, testCompile and testRuntime configurations after several years of deprecation. A build script that still declares compile 'group:name:version' stops at configuration time with Could not find method compile() for arguments [...] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. The message reads like a missing plugin and is a removed keyword. Choosing the replacement takes one fact about the project, whether anything consumes it as a library. Getting the build to finish afterwards usually takes more, because a script old enough to say compile carries other things of the same age.
EnterpriseQualityCoding/FizzBuzzEnterpriseEdition shows the whole set in one short build.gradle. Its dependencies block has one compile statement listing five Spring 3.2.13.RELEASE artifacts and one testCompile 'junit:junit:4.8.2'. The script applies the java and application plugins, so this is a program and no other build depends on its API. The agent writes implementation and testImplementation. Had the project applied java-library and exposed Spring types in public signatures, it would use api for those and explain which signatures made the difference.
Then it deals with why the error appears at all. gradle/wrapper/gradle-wrapper.properties pins gradle-2.8-bin.zip, a 2015 release that predates Java 9 and does not start on a current JDK. Anyone who tried ./gradlew, watched it fail and reached for a newer gradle on their path lands on the compile() error. The agent regenerates the wrapper at a current release so ./gradlew build is the one documented way in again. It also replaces jcenter() in repositories with mavenCentral(), since JCenter stopped taking new packages in 2021 and Gradle deprecated the shorthand, and it moves the top-level mainClassName = ... into application { mainClass = ... }, the form current Gradle expects.
The last check is the one most likely to surprise. build.gradle sets no Java level, while the pom.xml beside it compiles with <source>1.7</source>. Under the old wrapper that mismatch was invisible. On a current JDK, Gradle compiles for that JDK's own class-file version, and Spring 3.2 reads class files with a bundled parser from its own era. The agent runs ./gradlew test and ./gradlew run to find out whether Spring can load the classes it just compiled; if it cannot, it sets options.release to a level that both the JDK and Spring 3.2 accept and says which one it picked. It does not upgrade Spring in this pull request.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "This Gradle build fails with \"Could not find method compile() for arguments [...] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler\" (or the same for testCompile, runtime or testRuntime). In every build.gradle and build.gradle.kts, replace compile with implementation, testCompile with testImplementation, runtime with runtimeOnly and testRuntime with testRuntimeOnly. If a module applies java-library and exposes a dependency's types in its public API, use api for that dependency and name the signature that requires it. Also replace these names where they are used as configuration references (configurations.compile, from configurations.runtime in jar or shadow tasks). Read gradle/wrapper/gradle-wrapper.properties: if the pinned Gradle cannot run on a current JDK, regenerate the wrapper at the newest stable Gradle and commit all wrapper files. Then run ./gradlew build and fix only what stops it: removed repositories such as jcenter(), the deprecated mainClassName convention, removed task properties. Do not upgrade any dependency version. If the build script sets no Java level, check whether the compiled classes load with the dependency versions in use by running the tests and the application's main class; if they do not, set options.release to the highest level that works and explain why. If a pom.xml exists beside the Gradle build, say where the two disagree. Run ./gradlew build with --warning-mode all and include the commands, their output, and every remaining deprecation warning. Open a pull request.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
A pull request with the build script changes in one commit and the regenerated wrapper in another, so the reviewer can read the first as a diff and accept the second as generated files: gradlew, gradlew.bat, the wrapper jar and its properties. For the project above the first commit renames two configurations, swaps one repository, moves the main class declaration and, only if the test run required it, adds a Java release level.
The description holds the output of ./gradlew build --warning-mode all and of the application's run task, and a short list of where build.gradle and pom.xml disagree, such as the Java level and the fact that the Travis configuration only names JDK 7. A reviewer checks three things before merging: that implementation is right for every dependency and none needed api, that no dependency version moved, and that the remaining deprecation warnings listed are ones they are content to leave for a later change.
Run it on every repository still on an old wrapper
Organisations that have one build like this usually have a dozen. A short script on your side can list repositories, read each gradle/wrapper/gradle-wrapper.properties through the GitHub API, and send the request above once for every repository whose wrapper is older than 7. Give each call a request_id that is a UUID v5 of the repository's full name and the wrapper version it found, so running the script twice starts nothing twice.
The runs do not have to be paced by hand. A key runs up to its max_concurrent at once and the rest answer 202 with status: "queued", starting oldest first as slots free. Set a webhook_url on the key and each run posts run.completed or run.failed to your endpoint when it ends, with the session URL to read the pull request from.
The use case this job follows, with its automation and trigger: Fix a bug from an alert.
Why run it on Rush?
A Gradle migration is judged by whether the build goes green on a clean machine, and a developer's machine is not clean: it has a warm ~/.gradle cache, a daemon from another project and whichever JDK was installed last. The agent's sandbox starts with none of that. It downloads the new distribution through the wrapper, resolves every dependency from the repositories the script names, and the transcript keeps each command with its output. If mavenCentral() lacks an artifact that only JCenter had, that shows up here and not on a colleague's laptop next month.
The question about Spring 3.2 and new class files can only be answered by running the program. The agent can try more than one JDK and more than one release level in the same session and report the combination that works, with the failing output for the ones that do not. That table is tedious to produce by hand and is exactly what the reviewer needs to trust a one-line options.release setting.
Frequently asked questions
Should I use implementation or api?
implementation unless the module is a library whose public methods expose the dependency's types to callers. api needs the java-library plugin and puts the dependency on consumers' compile classpath. For an application, such as the example above, implementation is always right.
Can I keep compile by staying on Gradle 6?
Until you need a JDK that Gradle 6 cannot run on. Each Gradle release supports JDKs up to a fixed version, so an old wrapper eventually stops starting, which is what happened to the 2.8 wrapper in this example. The rename is valid on Gradle 3.4 and later, so you can make it before you upgrade.
Will the published POM of my library change?
It can. Dependencies declared with implementation are published with runtime scope, where compile gave them compile scope. Consumers that relied on your transitive dependencies at compile time will need to declare them or you will need api. The agent lists the published scope of each dependency before and after when the project applies a publishing plugin.
What about plugins that still call compile internally?
The error then names the plugin's class in the stack trace instead of your build script. The agent identifies the plugin and its version, raises it to the first release that supports the target Gradle, and reports it separately, since that is a version change you asked it not to make for ordinary dependencies.