galex
08/20/2021, 3:20 AMenvironment.logger
?Udi Cohen
08/20/2021, 7:53 PMsymbol-processing-cmdline
artifact locally?
I see it's only created to be published in Maven (https://github.com/google/ksp/pull/541), but I don't see a way to generate it myself in case I want to test the 1.5.30 branch for example.
It's also unclear to me what is the difference between that and the regular symbol-processing
artifact. I know the cmdline variant is necessary for Kotlin Native and command line, but why is that?Udi Cohen
08/23/2021, 8:31 PMkotlinc
command doesn't compile the project's classes and places them in the output folder.
As a repro example using the playground project, after running the following command I don't see anything in the build2/classes
folder. I do however see the generated AClassBuilder
class inside build2/generated/ksp/main/kotlin
.
kotlinc \
-d /Users/udinic/projects/ksp-playground4/workload/build2/classes \
-verbose \
-cp /Users/udinic/projects/ksp-playground4/test-processor/build/libs/test-processor-1.0-SNAPSHOT.jar \
-Xplugin=/Users/udinic/tmp/ksp-stuff/symbol-processing-api-1.5.21-1.0.0-beta07.jar \
-Xplugin=/Users/udinic/tmp/ksp-stuff/symbol-processing-cmdline-1.5.21-1.0.0-beta07.jar \
-P plugin:com.google.devtools.ksp.symbol-processing:apclasspath=/Users/udinic/projects/ksp-playground4/test-processor/build/libs/test-processor-1.0-SNAPSHOT.jar \
-P plugin:com.google.devtools.ksp.symbol-processing:projectBaseDir=/Users/udinic/projects/ksp-playground4/workload/src/main/java \
-P plugin:com.google.devtools.ksp.symbol-processing:classOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/classes/kotlin/main \
-P plugin:com.google.devtools.ksp.symbol-processing:kotlinOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/kotlin \
-P plugin:com.google.devtools.ksp.symbol-processing:javaOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/java \
-P plugin:com.google.devtools.ksp.symbol-processing:resourceOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/resources \
-P plugin:com.google.devtools.ksp.symbol-processing:cachesDir=/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/cache \
-P plugin:com.google.devtools.ksp.symbol-processing:kspOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/ksp \
/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/kotlin/ /Users/udinic/projects/ksp-playground4/workload/src/main/java
If I disable KSP, by removing the -Xplugin
params, I will see the compiled classes in the classes folder, but without any new generated classes of course.
Is there something missing in my command?Rafael Costa
08/24/2021, 12:25 PMKSValueParameter.hasDefault
), but not what that value is..edrd
08/24/2021, 9:44 PMCodeGeneration
API does not seem to support writing to a different source set rather than the one being processed. My workaround is to pass fileName = "../../(a lot more "../")/jsMain/OutputFileName"
.
Is there any other way to achieve this?elihart
08/25/2021, 5:14 PM@Attr(R2.layout.my_layout)
class MyClass
Where the resource is defined in a class like this
public final class R2 {
public static final class layout {
public static final int my_layout = 1616;
}
}
We borrowed this pattern from Butterknife, and the R2 class comes from the Butterknife gradle plugin to make the resource values final.
When a resource value is used as the annotation argument like this, KSP and the kotlin compiler don’t seem to recognize it. I’ve done some debugging and the whole argument is just absent in the compiler representation of the arguments list. However, if I use a constant Int directly the argument is available.
Does anyone know why KSP/Kotlin can’t recognize a value defined this way?yigit
08/25/2021, 5:15 PMAlex Beggs
08/26/2021, 4:24 PMnatario1
08/29/2021, 2:14 PM> Task :an-sample:kspTestKotlinAndroidNativeArm64 FAILED
e: Could not find "/Users/natario/Projects/ccc/ppp/an-sample/build/generated/ksp/androidNativeArm64Main/classes" in [/Users/natario/Projects/ccc/ppp, /Users/natario/.konan/klib, /Users/natario/.konan/kotlin-native-prebuilt-macos-x86_64-1.5.30/klib/common, /Users/natario/.konan/kotlin-native-prebuilt-macos-x86_64-1.5.30/klib/platform/android_arm64]
Trying to run processor on the test
compilation, gives the error above about missing class file in the main
compilation path. Indeed that "generated/ksp/classes" directory is empty, not sure what it's expecting to find there.
The error wording also seems suspicious, in Could not find "XXX" in [list of paths]
I'd expect XXX to be a filename, not a resolved path.elihart
08/30/2021, 7:49 PMnatario1
08/30/2021, 9:31 PMKotlinTarget
, named ksp<TargetName>
. For single-platform projects though, it might make sense to skip this step - when kotlin-jvm plugin is used for example, there's no point in having to write kspJvm
as it would be identical to root ksp
. What do you think?
2. Within each target, I create a configuration per KotlinCompilation
, named ksp<TargetName><CompilationName>
, extending the target configuration. As above, target name is omitted in single-platform. We could avoid creating this configuration for the main compilation, but after playing with it I think it's very nice to have fine grained control over main vs. test vs. both.
3. Within each compilation, I create a configuration per KotlinSourceSet
, named ksp<SourceSetName>
, but only if the source set is not the default one for that compilation. Basically this will be skipped 99% of the times?
4. Intermediate source sets do not have their own configuration. May be introduced in a future PR/version?
5. Android needs special handling. The KotlinSourceSet names are very confusing:
compilation=debug sourceSets=[androidDebug, androidMain]
compilation=debugAndroidTest sourceSets=[androidDebugAndroidTest, androidAndroidTest, androidAndroidTestDebug]
compilation=debugUnitTest sourceSets=[androidDebugUnitTest, androidTest, androidTestDebug]
compilation=release sourceSets=[androidRelease, androidMain]
compilation=releaseUnitTest sourceSets=[androidReleaseUnitTest, androidTest, androidTestRelease]
Looks to me that compilations == AGP variants, so one option is to create one config per variant named ksp<TargetName><VariantName>
. Another option is to read the `AndroidSourceSet`s from AGP (main, debug, release, test, testDebug, testRelease, androidTest, androidTestDebug, androidTestRelease). This gives more fine grained control, but it's harder to do (testDebug should extend both debug and test... Also not clear how to retrieve the correct configurations later in applyToCompilation()
).elihart
09/01/2021, 7:38 PMKSDeclaration.getVisibility()
returns the visibility of the original declaration by looking up the overridee if the declaration is an override. I was expecting, and hoping, to get the visibility of an overridden function and was pretty confused by this behavior.
Why was this approach chosen? It seems like a strange default. I suppose we can check modifiers directly to get visibility of a overridden declaration but it’s not ideal imoZac Sweers
09/04/2021, 8:58 PMjvmTarget
, languageVersion
, and apiVersion
in particular. Worth filing an issue?andylamax
09/06/2021, 2:46 PM> Failed to calculate the value of task ':compileTestDevelopmentExecutableKotlinJs' property 'entryModule$kotlin_gradle_plugin'.
> Collection has more than one element.
Asking here to know if it is an unknown bug, or I don't know how to configure this yet.
N.B: I am new to kspatsushieno
09/07/2021, 8:14 AMundefined reference to (my type)
. Any idea why this happens?jameskleeh
09/07/2021, 5:53 PMTing-Yuan Huang
09/07/2021, 9:31 PMescodro
09/08/2021, 4:48 PMPlugin with id 'com.google.devtools.ksp' not found.
.
I followed this article where it states that only by adding apply plugin: 'com.google.devtools.ksp'
and replacing kapt
with ksp
in the dependency it is good to go.
Am I missing something?
Thanks a lot! ❤️evant
09/08/2021, 5:08 PMpluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
}
To your settings.gradlerusshwolf
09/09/2021, 2:59 PMZac Sweers
09/10/2021, 5:52 AMJsonClassSymbolProcessorTest#disableProguardGeneration()
test, it runs successfully the first time and then is called a second time, upon which it throws an exception internally (in thread) that appears to originate from parsing the file generated by the first pass.
I think it's a bug, but I don't really know what exactly to file as I'm not sure where it's going wrong. Doing a second round makes sense to me, but I don't understand why it fails in this particular test case (and two others, but the rest are fine). The test runs fine in the moshix repo with no changes, but falls over in this repo and suggests something is up with the build. Let me know if there's somewhere specific I should dig!uli
09/11/2021, 5:07 PMWe have also updated a number of Android specific libraries which are ready for you to try today and offer significant performance improvements.
Is there any hint to a list or something?Zac Sweers
09/12/2021, 9:10 PMUdi Cohen
09/13/2021, 5:33 AMjameskleeh
09/14/2021, 4:03 PMjameskleeh
09/15/2021, 3:07 PMarguments
but I don’t see a way to know what the source type isAnton Popov
09/15/2021, 4:11 PMUdi Cohen
09/16/2021, 2:55 AMelihart
09/16/2021, 7:13 PMksp.incremental.log=true
(very helpful, btw!) so I think I understand what is going on.
My generated file (aggregating) relies on both a symbol in sources acquired with getSymbolsWithAnnotation
and a set of classes on the classpath (via getDeclarationsFromPackage
). The file’s originating elements reflect this, as do the ksp incremental logs, so the dependencies seem correctly understood by KSP.
My problem is that when there are classpath changes and the processor incrementally runs, KSP sees that only the classpath files changed and does not consider my source file as dirty, so my call to getSymbolsWithAnnotation
does not return anything. This is problematic because I need both the symbol in source as well as the classpath files to generate my output file, and this fails when I cannot get the source symbol with getSymbolsWithAnnotation
.
I understand why KSP does this, and it is optimal for some cases, but it makes generating a file that depends on both sources and classpath difficult - I think I would have to work around this by manually getting all files and parsing them.
Would it be reasonable instead for KSP to look at the set of inputs to a generated file, and if any one of those input is a classpath change then consider the rest of the inputs as dirty as well? according to the docs this is already done with sources, but maybe not for classpath changes?
Propagation by input-output correspondence: If a source file is changed or affected, all other source files having some output in common with that file are affected.
jameskleeh
09/20/2021, 3:59 PM