-
Notifications
You must be signed in to change notification settings - Fork 275
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
Add 7.4.2 gradle version in tests #565
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The s/compile/implementation/ changes look really easy to accept. The AGP version bump is going to be rockier; it may make sense to separate into separate PRs so the easy thing isn't blocked on the hard thing.
src/test/groovy/com/google/protobuf/gradle/AndroidProjectDetectionTest.groovy
Outdated
Show resolved
Hide resolved
src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginTest.groovy
Outdated
Show resolved
Hide resolved
I expect the AGP upgrade is failing because of #540 |
Extracted the compile/implementation migration to #567. |
JDK 11 is required for AGP 7.0 Is it possible to run all tests with java 11? Or is it necessary to run old tests with java 8, and for AGP 7.0 with java 11? |
Hmm... Java 8 no longer has Premier Support from Oracle. But new Gradle versions still support it. We could try to see whether animalsniffer can work for groovy. If it does, then we could use Java 11 JDK to build and test while also being reasonably confident things still work with Java 8. |
I just tried, and the animalsniffer plugin isn't triggering, even though it claims to support Groovy. Unclear why. I expected this to fail: diff --git a/build.gradle b/build.gradle
index 6c16702..86cab8f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,6 +7,7 @@ buildscript {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath "com.gradle.publish:plugin-publish-plugin:0.11.0"
classpath "com.github.ben-manes:gradle-versions-plugin:0.12.0"
+ classpath "ru.vyarus:gradle-animalsniffer-plugin:1.5.4"
}
}
@@ -33,6 +34,7 @@ apply plugin: 'signing'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.gradle.plugin-publish'
apply plugin: 'com.github.ben-manes.versions'
+apply plugin: 'ru.vyarus.animalsniffer'
group = 'com.google.protobuf'
version = '0.8.19-SNAPSHOT'
@@ -65,6 +67,8 @@ dependencies {
exclude module: 'groovy-all'
}
testImplementation 'commons-io:commons-io:2.5'
+
+ signature "org.codehaus.mojo.signature:java17:1.0@signature"
}
test.inputs.files fileTree("$projectDir/testProject")
diff --git a/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy b/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy
index cbf51b5..27afc44 100644
--- a/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy
+++ b/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy
@@ -111,6 +111,7 @@ public abstract class GenerateProtoTask extends DefaultTask {
if (Utils.isAndroidProject(project)) {
return isTestVariant
}
+ System.out.println("" + java.util.Collections.emptyNavigableMap());
return Utils.isTest(sourceSet.name)
}
|
Interestingly, I would try to build the project and run the test with JDK 11 in a separate PR. |
@ejona86 I took some time to understand how In our case, the checks don't work, thanks to the Details under the spoiler. DetailsI compiled the same class three times:
Compiled class sources: class Default {
def foo() {
// From Path.of JavaDoc
// @since 11
System.out.println(Path.of("Hello World"));
}
} Bytecode compiled from a class with
Bytecode compiled from class with
As result animalsniffer throw only one exception for class compiled with
About compiling important things with java 8. Since all important classes have the Some ways can help us to be confident in Java 8 support. a. We can run test two times:
b. Mark all groovy files with |
I think the best solution is mark all groovy files with @CompileStatic. It's will add extra compiler type checks, and allow animalsniffer do work. |
If groovy compiles without CompileStatic - code will be compiled in dynamic way, e.g. All type checks will be in runtime. Erased types in bytecode. With CompileStatic - compiler will save all typed in bytecode. If all types saved, we can do static analysis of bytecode with java 8 capability. More details can be found here: google#565 (comment)
If groovy compiles without CompileStatic - code will be compiled in dynamic way, e.g. All type checks will be in runtime. Erased types in bytecode. With CompileStatic - compiler will save all typed in bytecode. If all types saved, we can do static analysis of bytecode with java 8 capability. More details can be found here: google#565 (comment)
If groovy compiles without CompileStatic - code will be compiled in dynamic way, e.g. All type checks will be in runtime. Erased types in bytecode. With CompileStatic - compiler will save all typed in bytecode. If all types saved, we can do static analysis of bytecode with java 8 capability. More details can be found here: google#565 (comment)
If groovy compiles without CompileStatic - code will be compiled in dynamic way, e.g. All type checks will be in runtime. Erased types in bytecode. With CompileStatic - compiler will save all typed in bytecode. If all types saved, we can do static analysis of bytecode with java 8 capability. More details can be found here: google#565 (comment)
If groovy compiles without CompileStatic - code will be compiled in dynamic way, e.g. All type checks will be in runtime. Erased types in bytecode. With CompileStatic - compiler will save all typed in bytecode. If all types saved, we can do static analysis of bytecode with java 8 capability. More details can be found here: google#565 (comment)
If groovy compiles without CompileStatic - code will be compiled in dynamic way, e.g. All type checks will be in runtime. Erased types in bytecode. With CompileStatic - compiler will save all typed in bytecode. If all types saved, we can do static analysis of bytecode with java 8 capability. More details can be found here: google#565 (comment)
I thought I had started a comment, but I can't find it now. CompileStatic sounds fair. Java rewrite wouldn't be unacceptable, but obviously is a much larger change. I started poking at this and most classes look easy. Although the interesting classes are a bit harder. I have a feeling we are probably using CompileDynamic some places to avoid depending on Android Gradle Plugin. We'll probably keep the specific methods doing something like that as dynamic. |
If groovy compiles without CompileStatic - code will be compiled in dynamic way, e.g. All type checks will be in runtime. Erased types in bytecode. With CompileStatic - compiler will save all typed in bytecode. If all types saved, we can do static analysis of bytecode with java 8 capability. More details can be found here: #565 (comment)
As discussed at google#565 (comment)
As a solution to use AnimalSniffer to detect incompatibilities with Java 8, as discussed at google#565 (comment)
6f068b5
to
f82c96e
Compare
As a solution to use AnimalSniffer to detect incompatibilities with Java 8, as discussed at #565 (comment)
ecc9244
to
fa34f3c
Compare
Locally ProtobufKotlinDslPluginTest runs in 15 minutes. Have any ideas why the pipeline might get stuck? |
No, I saw it got stuck yesterday so restarted it. An hour later it was still running which surprised me. That's when I noticed the first run had been cancelled after 6 hours! Best hope I'd have is some memory limit needs to be increased. But that's really just shooting in the dark. |
7ed658c
to
c81e1a3
Compare
You're right.
|
60eda6e
to
e2f49a0
Compare
I turn on some logs and the pipeline stuck in the dex task, and only for new agp version.
Set memory limit for whole android gradle runner. Its working. I think we need to improve the test project configuration. Add customization options for each version of gradle/agp/kotlin. Like, use |
Let's just ignore the issue for AGP 7 for now. I hoped we might end up dropping support for some AGP versions. For example, if a version doesn't support new enough API levels for the Google Play store that's a trivial thing to drop. But it looks like 3.x is still usable today. Maybe once we deal with AGP 8 we can drop at least one version. |
|
Also bump java version to 11. agp 7.2.1 requires java 11
More details can be found here: google#540
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on a patch release now. After that this could be merged, since this will be a new minor release.
Background:
To add support for version catalogs, build caches, incremental build and other new gradle features - project need a newer version of the gradle.
Changes:
Run tests also with 7.4.2 gradle version and 7.2.1 agp version. To be sure that project works as expected on the 7.4.2 gradle version of gradle
Test plan:
Green pipelines, production code was not changed.