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

Updating to Gradle 6.7 or above causes compile error in buildSrc #892

Closed
msridhar opened this issue Jun 10, 2021 · 4 comments · Fixed by #931
Closed

Updating to Gradle 6.7 or above causes compile error in buildSrc #892

msridhar opened this issue Jun 10, 2021 · 4 comments · Fixed by #931
Assignees
Labels
gradle WALA’s Gradle build system

Comments

@msridhar
Copy link
Member

msridhar commented Jun 10, 2021

If I run ./gradlew wrapper --gradle-version 7.0.2 and then ./gradlew --dry-run, I get errors when compiling buildSrc:

> Task :buildSrc:compileJava FAILED
/Users/msridhar/git-repos/WALA/buildSrc/src/main/java/com/ibm/wala/gradle/EclipseJavaCompilerFactory.java:5: error: cannot find symbol
import org.gradle.api.internal.tasks.compile.JavaCompilerFactory;
                                            ^
  symbol:   class JavaCompilerFactory
  location: package org.gradle.api.internal.tasks.compile
/Users/msridhar/git-repos/WALA/buildSrc/src/main/java/com/ibm/wala/gradle/EclipseJavaCompilerFactory.java:11: error: cannot find symbol
class EclipseJavaCompilerFactory implements JavaCompilerFactory {
                                            ^
  symbol: class JavaCompilerFactory
/Users/msridhar/git-repos/WALA/buildSrc/src/main/java/com/ibm/wala/gradle/EclipseJavaCompilerToolChain.java:5: error: cannot find symbol
import org.gradle.api.internal.tasks.AbstractJavaToolChain;
                                    ^
  symbol:   class AbstractJavaToolChain
  location: package org.gradle.api.internal.tasks
/Users/msridhar/git-repos/WALA/buildSrc/src/main/java/com/ibm/wala/gradle/EclipseJavaCompilerToolChain.java:15: error: cannot find symbol
public class EclipseJavaCompilerToolChain extends AbstractJavaToolChain {
                                                  ^
  symbol: class AbstractJavaToolChain
/Users/msridhar/git-repos/WALA/buildSrc/src/main/java/com/ibm/wala/gradle/EclipseJavaCompilerFactory.java:27: error: method does not override or implement a method from a supertype
  @Override
  ^
/Users/msridhar/git-repos/WALA/buildSrc/src/main/java/com/ibm/wala/gradle/EclipseJavaCompilerToolChain.java:22: error: method does not override or implement a method from a supertype
  @Override
  ^
/Users/msridhar/git-repos/WALA/buildSrc/src/main/java/com/ibm/wala/gradle/EclipseJavaCompilerToolChain.java:27: error: method does not override or implement a method from a supertype
  @Override
  ^
7 errors

We are likely blocked on upgrading Gradle until we can fix these. @liblit could you take a look when you have some time?

Update: in further searching, I found that the relevant changes were introduced in Gradle 6.7, so we are also blocked from updating to more recent Gradle 6.x releases.

@liblit
Copy link
Contributor

liblit commented Jun 10, 2021

Will do.

@liblit
Copy link
Contributor

liblit commented Jun 12, 2021

Unfortunately, I don't think that this will be possible until gradle/gradle#15942 is fixed. I tried sneaking around Gradle 7's Java compiler limitations in various ways but got nowhere. Even if we were willing to have the ECJ builds run completely separately from regular builds (as we used to do), I don't see any way to convince Gradle 7 to use ECJ instead of a JDK-installation-based compiler.

We may have to remove our whole ECJ infrastructure, and give up on the corresponding extra checks, until gradle/gradle#15942 makes this possible again. 😞 I could certainly do that if we decide that it's the best way forward. Or we could linger on Gradle 6.x for a while longer to see if anything happens with gradle/gradle#15942.

@msridhar
Copy link
Member Author

msridhar commented Jun 12, 2021

Thanks for the investigation, @liblit. I am not in an extreme hurry to update to Gradle 7, though I would like to do it eventually. I'm not too optimistic about quick progress on gradle/gradle#15942, given it's been open since January. Still, we can wait for a bit and see what happens. If there is no progress, and we need to remove the ECJ infrastructure, we could do at least some of the checking using Error Prone, which integrates with OpenJDK's javac and is well supported in Gradle. Since the code already passes the ECJ checks, swapping in an "equivalent" config of Error Prone may not be too difficult.

@msridhar msridhar changed the title Updating to Gradle 7.0.2 causes compile error in buildSrc Updating to Gradle 6.7 or above causes compile error in buildSrc Jun 29, 2021
@liblit
Copy link
Contributor

liblit commented Aug 29, 2021

I wrote:

I don't see any way to convince Gradle 7 to use ECJ instead of a JDK-installation-based compiler.

I believe that I have figured out how to make this work. I have a simple, stand-alone Java project that builds using Gradle 7.2 and a standard JVM 1.8 installation, but which compiles Java by running an external ecj command. This use of an external command can be configured per task, which is exactly what we want to allow both standard and ECJ tasks in the same Gradle invocation.

I need to do some more work to incorporate this solution into WALA’s build system. But at least I now believe that it can be done, which is a big improvement.

liblit added a commit to liblit/WALA that referenced this issue Aug 29, 2021
Fixes wala#892, thereby allowing us to continue using ECJ as a secondary
compiler.
liblit added a commit that referenced this issue Aug 30, 2021
Fixes #892, thereby allowing us to continue using ECJ as a secondary
compiler.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gradle WALA’s Gradle build system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants