summaryrefslogtreecommitdiff
path: root/java/kotlin.go
AgeCommit message (Collapse)Author
2024-12-27Use test ([) instead of extended test ([[) in if statements jyeon.noh
- Using extended test is not portable since some /bin/sh doesn't support it. [ 4% 5228/128453 3h38m43s remaining] //external/javaparser:javaparser javac [linux_glibc common] /bin/sh: 1: [[: not found - Use "test" instead Change-Id: Ic29eb8cd04b8d29b4b8ca8863a826b073c2d2d71
2024-12-10Collect file delta metrics for java and kotlin compiles LaMont Jones
- Update the kotlinc and javac build rules to generate changed file metrics. - Upload the aggregated metrics at build completion. - Also fixes parsing of --inputs_file and --target to be consistent with existing use cases. Bug: b/365537477 Test: manual, TH Change-Id: I48efe06917baa98081e18b6351b63a624b55dba8
2024-09-17Merge "Pass the common sources rsp file as `--common_srcs` to extractor" ↵ Treehugger Robot
into main
2024-09-13Pass the common sources rsp file as `--common_srcs` to extractor Spandan Das
This additional metadata allows the indexer to differentiate between platform specific and platform agnostic kotlin code. Bug: 3266381 Test: ran the indexer on `kotlinx_serialization_core` java_library Change-Id: I860552808198cafa95fe0d5b6faa725b985e24d0
2024-09-12Use -language-version 1.9 in the kotlinKythe build rule Spandan Das
There are some instances of .kt code in android platform that are not fully compatible with kotlinc > 2. To account for this version skew when generating xrefs, implicitly add `-language-version 1.9` to the args in the .kzip file. The main kotlinc build rules remain the same. This value has been picked manually by running `external/kotlinc/bin/kotlinc -version` at ToT Bug: 265428637 Test: verified that `-language-version 1.9` is added to the build command of the .kzip files Test: ran the indexer locally on the .kzip of `PermissionController-lib` (this android_library contains .kt code that does not compile with verison >2) Change-Id: Icfb72800404d83f63204de23a1ec34b40ee05847
2024-09-11Create .kzip files for kotlin translation units Spandan Das
This CL creates the build rules to invoke the standalone kotlin extractor and create .kzip files for each kotlin translation unit. These will be indexed by the internal g3 kotlin indexers Implementation details - Create a `kotlinKytheExtract` static rule. Its inputs will be source .kt/.srcjar files and other verbatim args passed to kotlinc. The extrator will serialize this information into a .kzip file. The .kzip file should contain the necessary information to "replay" the compilation - Create a xref_kotlin phony rule to build all .kzip files corresponding to kotlin translation units. This implementation has one limitation. Since the kotlin indexers "replay" the compilation using its own version of kotlinc-jvm, there might be indexing issues caused by kotlinc version skew between android builds and indexing builds. `-kotlin-home` can likely solve that, but this CL defers that for now. Bug: 265428637 Test: Built the phony `xref_kotlin`, and ran the indexer locally using go/kythe-git-local-run#indexing-to-local-xrefs-server Change-Id: Ifb370f2df8aa46f71df3fe1ae7d7aa5da773cc8b
2024-08-07Use rsp for kotlin classpath Colin Cross
Support long classpaths by passing the classpath in a file to the script that generates build.xml. Bug: 308016794 Test: builds Flag: EXEMPT refactor Change-Id: Ib238a83a26acba7ede8e55298397dbeb9a57a866
2023-09-20Enable restat for kapt stubs rules Colin Cross
The output of the kapt stubs rules only change when the public interface of a kotlin class changes, which makes them a good candidate for restat. This will prevent some unnecessary reruns of turbine annotation processing. Bug: 297356926 Test: builds Change-Id: I39bd63284fd37058f69a0a3dace1ea5f4f50e8b5
2023-07-27Delete the javac/classes directory after zipping it Colin Cross
javac produces a directory containing class files, which is then zipped with soong_zip into a jar file. The class files are never used outside of the rule, so delete them after zipping them. This should save 19 GB of disk space in checkbuilds. Do the same for kotlinc/classes directories for consistency. Bug: 293352015 Test: treehugger Change-Id: Id1e889cfbee47eab552a5bb27134fa4b3b4c4d14
2023-06-14Support multiple filters in zipsync Zi Wang
Also applied this feature to kotlinc since it needs both java and kt files. Test: local test and presubmits Bug: 287071909 Change-Id: I28c725b03115aef47055448cb75412980015da15
2022-06-28Use the current java version for -jvm-target Cole Faust
This is a partial revert of aosp/541879. In that cl, the kotlin jvm version was always set to 1.8 because that's what the kotlin complier supported at the time, but now it supports more versions: $ ./external/kotlinc/bin/kotlinc -jvm-target foo error: unknown JVM target version: foo Supported versions: 1.6, 1.8, 9, 10, 11, 12, 13, 14, 15, 16, 17 Bug: 69160377 Bug: 236431222 Test: Treehugger Change-Id: I273e0b4d1f484013889e17c60bc1b299a3f975a1
2022-05-02Add missing dependency on compose plugin in kapt rules Colin Cross
The kapt rule uses kotlincFlags but was not using kotlincDeps, causing the rule to get the -Xplugin argument on the compose compiler plugin jar, but not have a dependency on it. Bug: 231222079 Test: TestKotlinCompose Change-Id: I4c2cf30fb7d8cad4eededa29f67f4ffd459caa41
2022-04-06Revert "Use kapt stubs for kotlin header jar for javac" Isaac Chiou
This reverts commit c6ef4853704080b1340170c5c30046cc4dacd418. Reason for revert: Multiple systemui presubmits are broken due to this change Bug: 228262695 Change-Id: I1efed519c49d8d0583815c7bf2b3801bf0ba12fa
2022-04-04Use kapt stubs for kotlin header jar for javac Colin Cross
When compling kotlin code with annotation processors we are generating java stubs for the kotlin sources using kapt, and parsing them in turbine when running the annotation processors. Passing --output to turbine will also compile the stubs into a header jar that can be used as a dependency to javac, allowing the javac and kotlinc rules to run in parallel. The turbine-apt header jar can't be used as the header jar for downstream modules as it doesn't contain the kotlin metadata needed by kotlinc rules, so the kotlinc gen-jvm-abi plugin output is still used for the module's final header jar. Test: TestKapt Bug: 222095735 Change-Id: I82d0900f3dc30f3e3ebd7cab0693dfe741d9b955
2022-04-04Enable kotlin's jvm-abi-gen plugin to generate header jars Colin Cross
Kotlin's jvm-abi-gen plugin can generate header jars similar to the turbine output for java sources, which can be used to avoid recompiling downstream modules when the ABI hasn't changed. Unlike turbine, the plugin runs as part of the main kotlinc invocation, so it doesn't allow the downstream modules to start compiling any sooner. A future possible optimization is to use turbine to compile the kapt stubs, at least for the kotlin+annotation processor modules that already generate them, which would allow compiling downstream modules before invoking kotlinc or javac, as well as invoking kotlinc and javac in parallel with each other. Bug: 222095735 Test: TestKotlin Test: m SystemUI Change-Id: Ib1bb2ecea47c851a108a26f9ed4f827f289d1321
2022-03-25Use turbine instead of kapt for kotlin annotation processors Colin Cross
Follow Bazel by using turbine instead of kapt to run annotation processors. This still requires using kapt to generate java stubs of kotlin soruces, then uses turbine to run annotation processors on the java stubs and any java sources to generate sources and resources, and passes the annotation processor generated sources to kotlinc and javac. Bug: 225013372 Test: m checkbuild Test: TestKapt Change-Id: I9c6fc496a9fba64658bb062538bc5f7b9478b07a
2022-03-18Prevent kotlinc from reading /tmp/build.txt Colin Cross
Pass -Didea.plugins.compatible.build=999.SNAPSHOT to kotlinc and kapt to prevent it from reading /tmp/build.txt and failing with an obscure exception: exception: java.lang.ExceptionInInitializerError at com.intellij.openapi.util.BuildNumber.currentVersion(BuildNumber.java:297) ... Bug: 222162908 Test: m metalava with /tmp/build.txt present Change-Id: I5faced4a2e94561ce3aa37bfaacf5bd7d988a4f0
2021-09-20Enable compose kotlinc plugin when depending on the compose runtime Colin Cross
When a module depends on the compose runtime add a -Xplugin argument to the kotlinc flags that enables the compose compiler plugin. Bug: 196351110 Test: TestKotlinCompose Change-Id: I423a3c4d12df42804a24b672a40a165bc8dd165f
2021-03-31Silence kotlinc JDK9 warnings Colin Cross
Silence the "Illegal reflective access" warning from kotlinc tracked by https://youtrack.jetbrains.com/issue/KT-43704 Test: m SystemUI Change-Id: I98eaf530c69cc4d3cefe09f5feab54c764352912
2021-03-16Add explicit rspfile argument to RuleBuilderCommand.FlagWithRspFileInputList Colin Cross
Using $out.rsp as the rsp file adds extra complexity around keeping the $ unescaped. Make callers to FlagWithRspFileInputList provide an explicit path for the rsp file instead. Bug: 182612695 Test: rule_builder_test.go Change-Id: I3f531d80c1efa8a9d09aac0a63790c5b11a9f0c6
2020-12-01Pass pctx and ctx to NewRuleBuilder Colin Cross
Enable the RuleBuilder and RuleBuilderCommand methods to access the BuilderContext by passing it to NewRuleBuilder instead of RuleBuilder.Build. Test: genrule_test.go Test: rule_builder_test.go Test: m checkbuild Change-Id: I63e6597e19167393876dc2259d6f521363b7dabc
2020-07-06Support kotlin multiplatform sources Colin Cross
Add a common_srcs property and propagate it to the module.xml file passed to kotlinc. Test: m checkbuild Change-Id: Ief768bafb943513c9ffbc01e829abc078f0a72bc
2020-06-26Move gen-kotlin-build-file.sh to python Colin Cross
Kotlin common multiplatform sources support will require more complexity in gen-kotlin-build-file.sh, move it to python instead. Test: m checkbuild Change-Id: I02312160ad781877f1fec971168331c0dcecf136
2020-06-18Fix annotation processors in kotlin modules that generate resources Colin Cross
The kapt rule was only keeping the generated sources, and not the generated classes directory. The generated classes directory will contain resources generated by the annotation processor and needs to be added to the final jar. Test: m ApiFinder Bug: 153485543 Change-Id: I89197d0afcb1eee011c01aa400f9977e66f43768
2020-04-22Repeat kapt processor argument for multiple processors Colin Cross
kapt claims to support a comma separated list of annotation processors, but it errors if multiple annotation processors are given. Surrounding the the list with {} does not error, but it also doesn't even warn if the second element in the list is garbage, so it may not be running the second processor. Repeat the processor argument for each annotation processor class instead. Bug: 154736649 Test: TestKapt Test: m checkbuild Change-Id: I4c7c161dbf867d7fba1aaf16fd5e502647e3f682
2020-01-28Add support for experimentally enabling RBE support on specific rules. Ramy Medhat
This CL adds RBE support to javac, r8, and d8 rules which is only enabled if respective environment variables are set. Test: an aosp_crosshatch build with and without the new variables. Change-Id: Ic82f3627944f6a5ee7b9f3228170c2709b1bfcb8
2019-11-07Fix turbine classpath arguments Colin Cross
We were passing "--classpath foo.jar --classpath bar.jar" to turbine, it now wants (and may always have expected?) "--classpath foo.jar bar.jar". Test: m checkbuild Change-Id: Ib7e0ca64a34e236110f7b785d6a0fb51ed75567e
2019-11-05Run non-RBE supported actions in the local pool when USE_RBE is set. Ramy Medhat
Bug: 143938974 Test: ran CTS build at -j500 successfully. Change-Id: I55074bd67308cd716972e24fb56a20bc393d5d9d
2019-10-28Make javaVersion an enum Colin Cross
Remove the hardcoded checks against "1.9" by making javaVersion an enum and implementing javaVersion.usesJavaModules(). Test: TestClasspath Change-Id: I559eeb1f45880bb8177269c6d977ee4dfbadce57
2019-06-13Add another jar used by kotlinc Dan Willemsen
Bug: 130111713 Test: treehugger Change-Id: If25be6047625cec4ed9802142876cfd8e9ccd3eb
2019-05-08Don't hide *.kotlin_module in turbine dependencies Colin Cross
The jars containing the merged header classes from transitive static dependencies were stripping all of META-INF/. Kotlin puts metadata in META-INF that is used to map the package to the static class that contains the package-level functions. This also exposed that the metadata in META-INF is always called "name.kotlin_module", so a library that contains kotlin files with a dependency that also contains kotlin files would shade the metadata file. Use a unique name instead. Fixes: 131709692 Test: m checkbuild Change-Id: I5cd276e563206e37c4c0d90fe9f346e9396f88c0
2019-04-11Zip boot image Colin Cross
Create a zip file containing the zipped boot image files. Test: m out/soong/sailfish/dex_bootjars/boot.zip Change-Id: I1b08c9aca962a5999585cbe9e665693ef4558524
2019-04-09Add extra used dependencies Dan Willemsen
Found while executing the build actions remotely. Bug: 130111713 Test: treehugger Test: run actions remotely with given dependencies, they pass. Change-Id: I2bff8fb8ccf50fde446d6bcef0f1dca9b2974b4b
2019-01-25Clean up srcjar directories after each rule Colin Cross
The srcjar directories just confuse people looking for generated files, clean them up after each rule. Test: m checkbuild Change-Id: If712ce7d4922619fd8420ae8f89830fe7824114d
2019-01-23Fix kotlin annotation processing after java_plugin Colin Cross
I37c1e80eba71ae2d6a06199fb102194a51994989 broke kotlin annotation processing with a typo in the processors flag to kapt and by passing -processor to javac with an empty processorpath. Bug: 77284273 Bug: 122251693 Test: kotlin_test.go Test: m checkbuild Change-Id: I17c45d5b3f9df089231af5d2930646ad0e6bf9be
2019-01-23Replace annotation_processors with plugins Colin Cross
Follow bazel's modules for annotation processors by introducing a java_plugin module type that can contain extra metadata about the annotation processor, the processor class and a flag to specify if the annotation processor is compatible with the turbine optimization. Deprecate the annotation_processors property, which took a list of java_library_host modules, in favor of the plugins property, which takes a list of java_plugin modules. The annotation_processors property will be removed once all uses have been replaced with plugins. Bug: 77284273 Test: plugin_test.go Test: m caliper Change-Id: I37c1e80eba71ae2d6a06199fb102194a51994989
2019-01-22Pass annotation processors to kotlinc Colin Cross
Enable the kotlin-annotation-processing plugin and pass annotation processors to it. Bug: 122251693 Test: m checkbuild Test: TestKapt in kotlin_test.go Change-Id: I841df454beaaa7edd263eea714ca0d958a03c9de
2019-01-22Move kotlin to it's own file Colin Cross
kapt is going to make kotlin a little more complicated, move the rules and tests to their own files. Bug: 122251693 Test: m checkbuild Change-Id: Ieed78b97995ced210b710bd50c357514cc8e3bc6