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

Bump Kotlin to 1.7.10 #7497

Merged
merged 4 commits into from Oct 17, 2022
Merged

Bump Kotlin to 1.7.10 #7497

merged 4 commits into from Oct 17, 2022

Conversation

utzcoz
Copy link
Member

@utzcoz utzcoz commented Aug 13, 2022

The AGP 7.3.0 only supports kotlin-android 1.5.20 and higher version.

@utzcoz utzcoz requested a review from hoisie August 13, 2022 12:17
gradle.properties Outdated Show resolved Hide resolved
@utzcoz
Copy link
Member Author

utzcoz commented Aug 17, 2022

@brettchabot Looks like current Kotlin configuration can't use Kotlin 7.10 directly. I will investigate it at weekend to see why.

@utzcoz utzcoz changed the title Bump kotlin-android to 1.5.20 Bump kotlin-android to 1.7.10 Aug 17, 2022
@utzcoz
Copy link
Member Author

utzcoz commented Aug 20, 2022

@brettchabot I didn't find the root cause of building error after bumping Kotlin to 1.7.10, but I found that the utils module's Kotlin plugin dependency has affected its usage by other modules, like shadowapi module when bumping Kotlin to latest version. I think I can understand a little of what @kingargyle said about Kotlin's compatibility. cc @hellosagar @hoisie .

@utzcoz
Copy link
Member Author

utzcoz commented Aug 20, 2022

The stacktrace is here:

* What went wrong:
Could not determine the dependencies of task ':errorprone:test'.
> Could not resolve all task dependencies for configuration ':errorprone:testRuntimeClasspath'.
   > Could not resolve project :utils.
     Required by:
         project :errorprone > project :shadowapi
      > The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'artifactType' with value 'jar'. However we cannot choose between the following variants of project :utils:
          - kotlinCompilerClasspath
          - kotlinKlibCommonizerClasspath
        All of them match the consumer attributes:
          - Variant 'kotlinCompilerClasspath' capability org.robolectric:utils:4.9-SNAPSHOT declares a component, as well as attribute 'artifactType' with value 'jar':
              - Unmatched attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its usage (required a runtime)
          - Variant 'kotlinKlibCommonizerClasspath' capability org.robolectric:utils:4.9-SNAPSHOT declares a component, as well as attribute 'artifactType' with value 'jar':
              - Unmatched attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its usage (required a runtime)
        The following variants were also considered but didn't match the requested attributes:
          - Variant 'apiElements' capability org.robolectric:utils:4.9-SNAPSHOT declares a library compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally:
              - Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
              - Other compatible attribute:
                  - Doesn't say anything about artifactType (required 'jar')
          - Variant 'mainSourceElements' capability org.robolectric:utils:4.9-SNAPSHOT declares a component, and its dependencies declared externally:
              - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about artifactType (required 'jar')
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its usage (required a runtime)
          - Variant 'testResultsElementsForTest' capability org.robolectric:utils:4.9-SNAPSHOT:
              - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about artifactType (required 'jar')
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its usage (required a runtime)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
2 actionable tasks: 2 up-to-date

@utzcoz
Copy link
Member Author

utzcoz commented Oct 15, 2022

@brettchabot From your work to using latest AndroidX test libraries at #7683, I think we also need to add @aar or @jar to utils module to bypass resolving problem. I will give a try.

Signed-off-by: utzcoz <utzcoz@outlook.com>
@utzcoz utzcoz changed the title Bump kotlin-android to 1.7.10 Bump Kotlin to 1.7.10 Oct 15, 2022
Update with command `./gradlew wrapper --gradle-version 7.5.1`.

Signed-off-by: utzcoz <utzcoz@outlook.com>
Signed-off-by: utzcoz <utzcoz@outlook.com>
@utzcoz utzcoz force-pushed the bump-kotlin-android branch 2 times, most recently from fb5294d to e6845ec Compare October 16, 2022 10:32
1. Add artifactType with jar for utils' runtimeElements

We should add artifactType with jar to ensure standard
runtimeElements variant has a max priority selection
sequence than other variants that brought by kotlin plugin.

2. Use annotations module to replace shadowapi for androidx_test

androidx_test only needs annotations module, instead of a larger one
called shadowapi.

3. Use java/main to replace kotlin/main for utils modules

Use java/main classes directory to replace default kotlin/main to
avoid d8 error when dexing & desugaring kotlin classes with non-exist
kotlin/main directory because utils module doesn't have kotlin code
in production. If utils module starts to add Kotlin code in main source
set, we can remove this destinationDirectory modification.

Signed-off-by: utzcoz <utzcoz@outlook.com>
@utzcoz utzcoz marked this pull request as ready for review October 16, 2022 11:11
@utzcoz
Copy link
Member Author

utzcoz commented Oct 16, 2022

@brettchabot @hoisie I think we can bump Kotlin to 1.7.10 now after some weekend's work. There are some changes that need to highlight:

  1. Remove gradle module metadata for utils module to avoid potential compatibility problems after released. When Robolectric other modules use utils module, we have encountered compatibility problems of variant resolving. Before we introduce Kotlin code for release code, IMO it's safe to remove gradle module metadata from Robolectric's modules that use Kotlin for testing code.
  2. Using java/main to replace kotlin/main for utils module to avoid d8 error when analyzing empty kotlin/main directory. Although utils module doesn't have code in kotlin main source set, but Kotlin plugin adds it to utils module variant's artifacts that are recognized by d8 tasks.

@utzcoz
Copy link
Member Author

utzcoz commented Oct 17, 2022

Friendly ping @hoisie @brettchabot for review.

@utzcoz utzcoz merged commit 1389558 into robolectric:master Oct 17, 2022
@utzcoz utzcoz deleted the bump-kotlin-android branch October 17, 2022 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants