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

build: declare dependency from KSP #15

Merged
merged 1 commit into from
Dec 16, 2023

Conversation

MasaHirano
Copy link
Contributor

Overview:

I find this plugin helpful while I migrate my app to a single-activity architecture. I use KSP for annotation processing but the build fails due to a missing dependency declaration.

* What went wrong:
A problem was found with the configuration of task ':<my-module>:kspDebugKotlin' (type 'KspTaskJvm').
  - Gradle detected a problem with the following location: '<my-module-path>/build/generated/source/quadrant'.
    
    Reason: Task ':<my-module>:kspDebugKotlin' uses this output of task ':<my-module>:generateActivityClassNameConstants' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':<my-module>:generateActivityClassNameConstants' as an input of ':<my-module>:kspDebugKotlin'.
      2. Declare an explicit dependency on ':<my-module>:generateActivityClassNameConstants' from ':<my-module>:kspDebugKotlin' using Task#dependsOn.
      3. Declare an explicit dependency on ':<my-module>:generateActivityClassNameConstants' from ':<my-module>:kspDebugKotlin' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.4/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

Dear @gaelmarhic, I don't know if you still maintain this repository but if you can have time to look at this PR, it's highly appreciated.

@gaelmarhic
Copy link
Owner

Hey @alpaca0984!
Thanks for your interest in Quadrant and for your PR!
Could you provide the detailed steps of how to reproduce the issue myself (or a sample project)?
Once I can reproduce it, I'll look at the PR and test it!
Thanks again!

@MasaHirano
Copy link
Contributor Author

MasaHirano commented Dec 11, 2023

Hello @gaelmarhic, thank you for your reply :)

I created a sample project where I could see the build error.
https://github.com/alpaca0984/QuadrantKspCompileSample
It imports this Quadrant plugin and also uses the KSP for the Glide plugin. Once you run "Make Project", you should be able to see the error.

My environment is:

  • Android Studio: Giraffe | 2022.3.1 Patch 4
  • Gradle JDK: Java 17.0.6

Let me know if you need more information. Many thanks

Copy link
Owner

@gaelmarhic gaelmarhic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@gaelmarhic gaelmarhic merged commit 23b6984 into gaelmarhic:master Dec 16, 2023
@gaelmarhic
Copy link
Owner

Hi @alpaca0984!

Thanks for providing the sample project.

I have been able to reproduce this issue and test your fix.

I have merged the PR and published a new version (1.8). It is still pending for approval from Gradle.

I'll let you know once it is available.

Thanks for your contribution!

@MasaHirano MasaHirano deleted the build-work-with-ksp branch December 17, 2023 13:00
@MasaHirano
Copy link
Contributor Author

Hello @gaelmarhic,
Thank you for publishing the new version.

Besides this PR, I found that this project needs to be updated to support partially qualified class names (related to #3 ).
From Android Gradle Plugin 7.3.0, package attribute in manifest file is deprecated.
https://developer.android.com/build/releases/past-releases/agp-7-3-0-release-notes#package-deprecated

I will open another PR in several days :)

@gaelmarhic
Copy link
Owner

Hi @alpaca0984,
The new version has not been approved yet. Feel free to track it here: https://plugins.gradle.org/plugin/com.gaelmarhic.quadrant.

@gaelmarhic
Copy link
Owner

Thanks for noticing that!

Looking forward to your PR!

Thank you for your interest and for the help! :)

@gaelmarhic
Copy link
Owner

Hey @alpaca0984.
Version 1.8 was finally published!

I wanted to test it against your sample project, but I can't build it because of the following error:

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugKotlin'.
> No matching toolchains found for requested specification: {languageVersion=8, vendor=any, implementation=vendor-specific}.
   > No locally installed toolchains match (see https://docs.gradle.org/8.0/userguide/toolchains.html#sec:auto_detection) and toolchain download repositories have not been configured (see https://docs.gradle.org/8.0/userguide/toolchains.html#sub:download_repositories).

I saw that you made some changes regarding the toolchain in the last few days.

Does it build on your side?

Thanks!

@MasaHirano
Copy link
Contributor Author

Hi @gaelmarhic ,

On my end, I can build the sample project with Quadrant 1.8.
I use Java 17.0.7 for build.

Build logs are here
Executing tasks: [:app:assembleDebug, :module1:assembleDebug, :module2:assembleDebug] in project /Users/<username>/StudioProjects/QuadrantKspCompilesSample

Starting Gradle Daemon...
Gradle Daemon started in 492 ms
Configuration 'kspDebugKotlinProcessorClasspath' was resolved during configuration time.
This is a build performance and scalability issue.
See https://github.com/gradle/gradle/issues/2298
Run with --info for a stacktrace.
> Task :app:createDebugVariantModel UP-TO-DATE
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
> Task :app:checkDebugAarMetadata UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:mapDebugSourceSetPaths UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources UP-TO-DATE
> Task :app:packageDebugResources UP-TO-DATE
> Task :app:parseDebugLocalResources UP-TO-DATE
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:extractDeepLinksDebug UP-TO-DATE
> Task :app:processDebugMainManifest UP-TO-DATE
> Task :app:processDebugManifest UP-TO-DATE
> Task :app:processDebugManifestForPackage UP-TO-DATE
> Task :app:processDebugResources UP-TO-DATE
> Task :app:kspDebugKotlin UP-TO-DATE
> Task :app:compileDebugKotlin UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:compileDebugJavaWithJavac NO-SOURCE
> Task :app:mergeDebugShaders UP-TO-DATE
> Task :app:compileDebugShaders NO-SOURCE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :app:mergeDebugAssets UP-TO-DATE
> Task :app:compressDebugAssets UP-TO-DATE
> Task :app:processDebugJavaRes UP-TO-DATE
> Task :app:mergeDebugJavaResource UP-TO-DATE
> Task :app:checkDebugDuplicateClasses UP-TO-DATE
> Task :app:desugarDebugFileDependencies UP-TO-DATE
> Task :app:mergeExtDexDebug UP-TO-DATE
> Task :app:mergeLibDexDebug UP-TO-DATE
> Task :app:dexBuilderDebug UP-TO-DATE
> Task :app:mergeProjectDexDebug UP-TO-DATE
> Task :app:mergeDebugJniLibFolders UP-TO-DATE
> Task :app:mergeDebugNativeLibs NO-SOURCE
> Task :app:stripDebugDebugSymbols NO-SOURCE
> Task :app:validateSigningDebug UP-TO-DATE
> Task :app:writeDebugAppMetadata UP-TO-DATE
> Task :app:writeDebugSigningConfigVersions UP-TO-DATE
> Task :app:packageDebug UP-TO-DATE
> Task :app:createDebugApkListingFileRedirect UP-TO-DATE
> Task :app:assembleDebug UP-TO-DATE
> Task :module1:preBuild UP-TO-DATE
> Task :module1:preDebugBuild UP-TO-DATE
> Task :module1:mergeDebugJniLibFolders UP-TO-DATE
> Task :module1:mergeDebugNativeLibs NO-SOURCE
> Task :module1:stripDebugDebugSymbols NO-SOURCE
> Task :module1:copyDebugJniLibsProjectAndLocalJars UP-TO-DATE
> Task :module1:generateActivityClassNameConstants UP-TO-DATE
> Task :module1:generateDebugResValues UP-TO-DATE
> Task :module1:generateDebugResources UP-TO-DATE
> Task :module1:packageDebugResources UP-TO-DATE
> Task :module1:parseDebugLocalResources UP-TO-DATE
> Task :module1:processDebugManifest UP-TO-DATE
> Task :module1:generateDebugRFile UP-TO-DATE
> Task :module1:compileDebugKotlin UP-TO-DATE
> Task :module1:extractDebugAnnotations UP-TO-DATE
> Task :module1:extractDeepLinksForAarDebug UP-TO-DATE
> Task :module1:javaPreCompileDebug UP-TO-DATE
> Task :module1:compileDebugJavaWithJavac NO-SOURCE
> Task :module1:mergeDebugGeneratedProguardFiles UP-TO-DATE
> Task :module1:mergeDebugConsumerProguardFiles UP-TO-DATE
> Task :module1:mergeDebugShaders UP-TO-DATE
> Task :module1:compileDebugShaders NO-SOURCE
> Task :module1:generateDebugAssets UP-TO-DATE
> Task :module1:packageDebugAssets UP-TO-DATE
> Task :module1:prepareDebugArtProfile UP-TO-DATE
> Task :module1:prepareLintJarForPublish UP-TO-DATE
> Task :module1:processDebugJavaRes UP-TO-DATE
> Task :module1:mergeDebugJavaResource UP-TO-DATE
> Task :module1:syncDebugLibJars UP-TO-DATE
> Task :module1:writeDebugAarMetadata UP-TO-DATE
> Task :module1:bundleDebugAar UP-TO-DATE
> Task :module1:createDebugVariantModel UP-TO-DATE
> Task :module1:assembleDebug UP-TO-DATE
> Task :module2:preBuild UP-TO-DATE
> Task :module2:preDebugBuild UP-TO-DATE
> Task :module2:mergeDebugJniLibFolders UP-TO-DATE
> Task :module2:mergeDebugNativeLibs NO-SOURCE
> Task :module2:stripDebugDebugSymbols NO-SOURCE
> Task :module2:copyDebugJniLibsProjectAndLocalJars UP-TO-DATE
> Task :module2:generateDebugResValues UP-TO-DATE
> Task :module2:generateDebugResources UP-TO-DATE
> Task :module2:packageDebugResources UP-TO-DATE
> Task :module2:parseDebugLocalResources UP-TO-DATE
> Task :module2:processDebugManifest UP-TO-DATE
> Task :module2:generateDebugRFile UP-TO-DATE
> Task :module2:compileDebugKotlin UP-TO-DATE
> Task :module2:extractDebugAnnotations UP-TO-DATE
> Task :module2:extractDeepLinksForAarDebug UP-TO-DATE
> Task :module2:javaPreCompileDebug UP-TO-DATE
> Task :module2:compileDebugJavaWithJavac NO-SOURCE
> Task :module2:mergeDebugGeneratedProguardFiles UP-TO-DATE
> Task :module2:mergeDebugConsumerProguardFiles UP-TO-DATE
> Task :module2:mergeDebugShaders UP-TO-DATE
> Task :module2:compileDebugShaders NO-SOURCE
> Task :module2:generateDebugAssets UP-TO-DATE
> Task :module2:packageDebugAssets UP-TO-DATE
> Task :module2:prepareDebugArtProfile UP-TO-DATE
> Task :module2:prepareLintJarForPublish UP-TO-DATE
> Task :module2:processDebugJavaRes UP-TO-DATE
> Task :module2:mergeDebugJavaResource UP-TO-DATE
> Task :module2:syncDebugLibJars UP-TO-DATE
> Task :module2:writeDebugAarMetadata UP-TO-DATE
> Task :module2:bundleDebugAar UP-TO-DATE
> Task :module2:createDebugVariantModel UP-TO-DATE
> Task :module2:assembleDebug UP-TO-DATE

BUILD SUCCESSFUL in 8s
80 actionable tasks: 80 up-to-date

Build Analyzer results available

I saw that you made some changes regarding the toolchain in the last few days.

Yes, I made the changes to address an error raised by the Android Studio. I use the KSP in the app module.

Execution failed for task ':app:kspDebugKotlin'.
> 'compileDebugJavaWithJavac' task (current target is 1.8) and 'kspDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
  Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain

Let me know if you need further information. I will be happy to jump in.

@MasaHirano
Copy link
Contributor Author

MasaHirano commented Dec 27, 2023

Apparently, ↓ is the specific issue with KSP 1.8.XX.

Execution failed for task ':app:kspDebugKotlin'.
> 'compileDebugJavaWithJavac' task (current target is 1.8) and 'kspDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
  Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain

I updated it from 1.8.10-1.0.9 to 1.9.0-1.0.13 with MasaHirano/QuadrantKspCompileSample#1 and now kotlinOptions.jvmTarget works as expected.

Also, I configured GitHub actions to confirm the build succeeds.
https://github.com/alpaca0984/QuadrantKspCompileSample/actions/runs/7307638930/job/19913531756

@gaelmarhic
Copy link
Owner

Hey @alpaca0984!
I downloaded the latest version of your repo and was finally able to test 1.8.
Thanks for fixing it :)

@MasaHirano
Copy link
Contributor Author

Hi @gaelmarhic and Happy New Year 🎉

You're welcome. You might notice that although build succeeds, the Quadrant failed to create fully qualified class names.

package com.gaelmarhic.quadrant

import kotlin.String

public object QuadrantConstants {
  public const val MAIN_ACTIVITY: String = ".MainActivity"

  public const val ACTIVITY1: String = ".Activity1"

  public const val ACTIVITY2: String = ".Activity2"
}

It should be fixed with #16 .

@gaelmarhic
Copy link
Owner

Hi @alpaca0984! Happy new year to you too!
Indeed, I noticed it!
I am going on holidays tomorrow and will be back on the 23rd.
I don't think I'll have time to have a look at the PR before I leave, but I will definitely do it as the first thing when I get back!

@MasaHirano
Copy link
Contributor Author

Have a nice vacation Gaël :)

@gaelmarhic
Copy link
Owner

Thank you so much :)

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.

2 participants