wala / WALA

T.J. Watson Libraries for Analysis, with frontends for Java, Android, and JavaScript, and may common static program analyses
http://github.com/wala/WALA
Eclipse Public License 2.0
762 stars 223 forks source link

Build crash trying to add Checker Framework Gradle Plugin #1454

Open msridhar opened 1 month ago

msridhar commented 1 month ago

I wanted to play around with running the Checker Framework on WALA code, so I tried adding its Gradle plugin. My WIP change is here. With these changes, when I try to run Gradle I get a crash:

$ ./gradlew --dry-run --stacktrace
[...]
FAILURE: Build failed with an exception.
[...]
Caused by: org.gradle.api.InvalidUserDataException: Cannot change resolution strategy of dependency configuration ':checkerFramework' after it has been resolved.
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.preventIllegalMutation(DefaultConfiguration.java:1507)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.validateMutation(DefaultConfiguration.java:1452)
        at org.gradle.api.internal.artifacts.ivyservice.resolutionstrategy.DefaultResolutionStrategy.eachDependency(DefaultResolutionStrategy.java:233)
        at com.diffplug.gradle.eclipse.MavenCentralExtension$ReleaseConfigurer.lambda$constrainTransitivesToThisReleaseExcept$5(MavenCentralExtension.java:127)
        at com.diffplug.gradle.eclipse.MavenCentralExtension$ReleaseConfigurer.constrainTransitivesToThisReleaseExcept(MavenCentralExtension.java:126)
        at com.diffplug.gradle.eclipse.MavenCentralExtension$ReleaseConfigurer.constrainTransitivesToThisRelease(MavenCentralExtension.java:121)
        at com.ibm.wala.gradle.Eclipse_maven_central_gradle$WalaMavenCentralReleaseConfigurerExtension.defaults$build_logic(eclipse-maven-central.gradle.kts:73)
        at com.ibm.wala.gradle.Eclipse_maven_central_gradle$2$1.invoke(eclipse-maven-central.gradle.kts:124)
        at com.ibm.wala.gradle.Eclipse_maven_central_gradle$2$1.invoke(eclipse-maven-central.gradle.kts:124)
        at com.ibm.wala.gradle.Eclipse_maven_central_gradle$2.execute(eclipse-maven-central.gradle.kts:128)
        at com.ibm.wala.gradle.Eclipse_maven_central_gradle$2.execute(eclipse-maven-central.gradle.kts:124)

Not too sure what the root cause would be. @liblit do you have any ideas? Nothing urgent.

Incidentally, we should probably document somewhere how to add new Gradle plugins to the WALA build. The set of changes I had to do seemed rather non-standard compared to any docs I found.

liblit commented 1 month ago

@liblit do you have any ideas?

I do not. ☹️

we should probably document somewhere how to add new Gradle plugins to the WALA build. The set of changes I had to do seemed rather non-standard compared to any docs I found.

That's a fine idea. The changes you made look correct to me, but they certainly grew complicated due to interactions with two advanced Gradle features we are already using: version catalogs and script plugins.

msridhar commented 1 month ago

@liblit do you have any ideas?

I do not. ☹️

Ok, will see when I can investigate.

we should probably document somewhere how to add new Gradle plugins to the WALA build. The set of changes I had to do seemed rather non-standard compared to any docs I found.

That's a fine idea. The changes you made look correct to me, but they certainly grew complicated due to interactions with two advanced Gradle features we are already using: version catalogs and script plugins.

Yup, ideally, we should have instructions for translating steps like these for adding a plugin to what needs to be done with our build config. Figuring out what should go in this line in particular was non-obvious to me.

liblit commented 1 month ago

Figuring out what should go in this line in particular was non-obvious to me.

Yeah, I can understand why. A simpler project would use the version catalog's [plugins] section, not the [libraries] section, to describe Gradle plugins. But in our case, you're not really using Checker Framework as a plugin. Rather, you are using it as a library in the implementation of java.gradle.kts, which is itself a so-called "script plugin". I think that's why quite a few other Gradle plugins are already listed in [libraries] rather than [plugins].