Commit Graph

168 Commits

Author SHA1 Message Date
Alexander Likhachev e9c8135dfa [Gradle] Add Gradle & task property to set compiler execution strategy
#KT-49299 Fixed
2021-10-22 09:57:54 +00:00
Sergey Igushkin a474e8a00b KT-49189: fix project(...) dependencies on MPP from pure-Java consumers
* Don't set the localToProject attribute anymore, as it prevents proper
  disambiguation if not set properly on all configurations, while all
  the intentionally-public configurations
  should already have the same value.

* Disambiguate o.j.k.platform.type Android vs JVM preferring JVM, as
  Android should have other attributes which make pure-Android consumers
  match the Android MPP variants.

* With Gradle 7.0+, set the attribute
  `org.gradle.api.attributes.java.TargetJvmEnvironment` on the JVM &
  Android elements configurations, which helps pure-Android consumers
  to match the Android, not JVM variants. This fixes KT-30961 for
  Gradle 7.0+ and AGP 7.0+

Issues: KT-49189, KT-30961
2021-10-21 10:17:52 +00:00
Yan Zhulanow 46b94a4757 Pill: Include certain modules into the BASE variant 2021-10-19 19:55:06 +03:00
Dmitry Savvinov 50050154d3 [gradle, mpp] Change how outputs of associated compilations are handled 2021-10-06 17:10:17 +03:00
Ilya Gorbunov ec5c06238d Split language and api version lifetimes, restore apiVersion 1.3 support
KT-49007
2021-09-29 21:46:53 +03:00
Yahor Berdnikau 60cbfbf107 Change KotlinGradleSubplugin deprecation level to ERROR.
^KT-48830 Fixed
2021-09-29 12:13:02 +00:00
Svyatoslav Kuzmich 841f5a583e [Wasm] Support wasm target in multiplatform plugin 2021-09-28 18:26:07 +03:00
Vyacheslav Gerasimov 8b5db6473b Fix deprecated ConfigureUtil usages in KGP
Required for Gradle 7+ #KTI-559
2021-09-26 23:36:40 +03:00
Dmitriy Novozhilov d46e2dd749 Fix OVERRIDE_DEPRECATION warnings in project code 2021-09-02 15:04:07 +03:00
Svyatoslav Scherbina 71af22dba0 [Gradle] Support Native embeddable compiler jar in subplugins
Apply generic (backend-agnostic) compiler plugin artifact instead of
Native-specific one when Native embeddable compiler jar is used
(with `kotlin.native.useEmbeddableCompilerJar=true` project property).
2021-09-01 13:43:28 +00:00
Svyatoslav Scherbina 0fd4884149 [Gradle] Partially revert "enable to work with embedded k/n compiler"
This partially reverts commit 2baf344f5f,
removing support for K/N embeddable compiler jar from subplugins.
More migration-friendly implementation is to be added instead.
2021-09-01 13:43:26 +00:00
Alexander Udalov 473ed2e410 Fix JVM target and language version info in CLI and Gradle 2021-09-01 14:32:53 +02:00
Alexander Udalov ca7334acb9 Fix some warnings in Gradle plugin and related modules 2021-08-06 22:36:58 +02:00
Vasily Levchenko 2baf344f5f [kotlin gradle plugin] enable to work with embedded k/n compiler. 2021-07-27 19:44:31 +00:00
Alexander Udalov cbdd0f579a Regenerate Gradle options 2021-07-26 19:36:53 +02:00
Alexander Likhachev b93bd1fe09 [Gradle] Simplify optInAnnotation function name to optIn in DSL
#KT-38111
2021-07-19 19:57:00 +03:00
Alexander Likhachev fa68dbc736 [Gradle] Rename experimental annotations to opt-in annotations in DSL
Methods and accessors with old names are preserved in public API and marked as deprecated now
#KT-38111 In Progress
2021-07-16 11:01:12 +03:00
Yahor Berdnikau da1d49e622 Add new ways to set Kotlin daemon JVM arguments.
Additionally to inheriting Gradle daemon arguments or configuring via
 Gradle daemon arguments system property, it is also possible now
 to configure arguments either using "kotlin.daemon.jvmargs" property
 or extension DSL.

Extension DSL overrides special gradle property arguments, which
overrides Gradle daemon arguments.

^KT-45747 Fixed
2021-07-15 17:27:38 +00:00
Yahor Berdnikau 1a6bb5cd08 Allow to pass any object for 'jdkVersion'.
This object should be accepted by 'JavaVersion.toVersion' method.

^KT-45611 In Progress
2021-06-18 10:50:23 +00:00
Sergey Igushkin 14a7e90c69 KT-38954: Filter Android attributes during publishing
* Always filter out the variant name attribute: it is never requested
  by consumers, while its presence makes Gradle count it as an
  unmatched attribute, sometimes leading to ambiguity;

* Filter out the build type attribute: if all variants have the same
  build type, then remove the build type attribute from all variants;
  Otherwise, remove the build type attribute from the release variants
  in order to make them compatible with all other consumer's build 
  types.

  * Add an opt-out flat for always keeping the attribute:
    "kotlin.android.buildTypeAttribute.keep" Gradle property

Issue #KT-38954 Fixed
2021-06-09 10:18:15 +00:00
Anton Lakotka 5a58c1c437 [Kotlin Project Model] Add compiler plugin support 2021-06-08 15:48:58 +00:00
Yahor Berdnikau c5e6215d27 Set UsesKotlinJavaToolchain interface to extend Task interface.
Limit use-case of UsesKotlinJavaToolchain interface to only Gradle tasks
and allow to query all tasks using
 'taskContainer.withType(UsesKotlinJavaToolchain.class)'.

^KT-43095 In Progress
2021-05-31 10:22:50 +00:00
Yahor Berdnikau 4c943e7cd1 Allow to configure non-default JDK using toolchain via extension.
Add method into "kotlin" extension to set toolchain for all tasks.
This will also set toolchain for java compile tasks. Also user may
set toolchain via "java" extension and it will be applied to Kotlin
tasks as well.

^KT-43092 In Progress
2021-05-31 10:22:49 +00:00
Yahor Berdnikau 8e1c420c9f Allow to set non-default JDK for tasks via java toolchain.
Has to split jdk/toolchain setters, because, when toolchain setter is
in the 'UsesKotlinJavaToolchain', Groovy fails to create meta class
on <Gradle 6.7 with ClassNotFoundException.

^KT-43092 In Progress
2021-05-31 10:22:48 +00:00
Anton Lakotka 8481f4a9d2 Set kotlin-project-model as api dependency for kotlin-gradle-plugin-api
LanguageSettingsBuilder depends on LanguageSetting interface from KPM
which forces api dependency scope

^KT-46517 Fixed
2021-05-26 18:11:39 +00:00
Yahor Berdnikau 13fd2a24ea Fix exposing provided by Gradle Kotlin dependencies.
Ensure that Gradle plugin dependencies do not include kotlin-stdlib,
kotlin-reflect and other dependencies that are provided by Gradle
runtime.

^KT-41142 Fixed
2021-05-12 23:28:37 +03:00
Ivan Gavrilovic 4994cb3774 [Gradle] Create kotlinOptions during task init and keep outputFile for js
This is so that existing build scripts using
withType() do not break. Also, fix the failing
test.

It was necessary to keep outputFile for the js compile task
as it was accessed from the build scripts. Instead, a new
property is introduced which uses Gradle lazy properties.
2021-05-06 13:54:18 +03:00
Yahor Berdnikau 816e955c61 Introduce KotlinJavaToolchain compile tasks input.
This task input provides a way to set different from current Gradle
JDK and use it for Kotlin files compilation. By default it provides
current Gradle JDK.

Provided JDK major version is used as task input, so on providing
different JDK user will see cache miss.

All required interfaces are located inside api module.

^KT-45611 In Progress
2021-04-29 20:43:58 +03:00
Alexander Udalov 37ccd82b6c Fix some warnings in kotlin-gradle-plugin 2021-04-26 22:02:26 +03:00
Sergey Igushkin a94597d85a Experimental sources publication in the PM2.0 prototype 2021-04-23 00:43:10 +03:00
Anton Lakotka de4221afd8 Add immutable LanguageSettings interface and apply it to compilation
LanguageSettingsBuilder extends LanguageSettings
2021-04-23 00:43:06 +03:00
Sergey Igushkin c1fe0d7158 Add publishing configurator, call it from the variant factories 2021-04-23 00:43:05 +03:00
Sergey Igushkin f029179fe0 Add basic support for Kotlin/Native variants to the PM20 Gradle plugin 2021-04-23 00:43:00 +03:00
Sergey Igushkin ea458e6848 Add some API interfaces for Gradle PM20 entities in the API module 2021-04-23 00:42:37 +03:00
Yahor Berdnikau 9100be4566 Set Android Gradle Plugin dependency version to 3.4.0.
This is required to get method deprecations and new proposed methods.
2021-04-12 18:20:41 +03:00
sebastian.sellmair 2aeb08e245 [Gradle] Implement internal intransitiveMetadataConfiguration
- Implemented additional intransitiveMetadataConfiguration to support
dependencies that shall not be added transitively to dependsOn edges
2021-04-09 23:36:00 +02:00
Ilya Chernikov a11f6d2e50 Add support for gradle option useFir and appropriate property...
`kotlin.useFir`
2021-03-24 21:24:20 +01:00
Yaroslav Chernyshev 7d766add4b Add lambda configurable languageSettings function in KotlinSourceSet
Function with Groovy Closure is already exists, it provides DSL parity
#KT-44834 Fixed
2021-03-02 16:32:06 +03:00
Alexander Udalov 1d6b198915 Build: suppress version and JVM target warnings
To further reduce the output on each build.
2021-02-18 12:17:17 +01:00
Alexander Likhachev cbeb031099 [Gradle, K/N] Move NativeBinaryTypes from kotlin-gradle-plugin to kotlin-gradle-plugin-api 2021-02-15 09:21:44 +03:00
Alexander Likhachev 0e29a9df6c [Gradle, JS] Use target disambiguation classifier for compilation name 2021-02-15 09:21:40 +03:00
Dmitriy Novozhilov 4f8b12c96f [Test] Fix various tests according to switching to kotlin 1.5 2021-01-28 13:19:30 +03:00
Alexander Udalov 22d0e5eb65 Rename -Xno-use-ir -> -Xuse-old-backend, add Gradle option
As soon as JVM IR is enabled by default (in language version 1.5), use
the CLI argument `-Xuse-old-backend` or Gradle option `useOldBackend` to
switch to the old JVM backend.
2021-01-11 12:47:54 +01:00
Victor Petukhov 48d9812d9e Review fixes around type enhancement and loading type use annotations 2020-12-18 19:32:05 +03:00
Alexander Udalov f273edeb8e Build: upgrade language to 1.3 in cli, compiler plugins and Gradle plugin
The language/API version restriction here is to make sure the code works
with Gradle of earlier versions, but all versions of Gradle that we
support already depend on Kotlin 1.3+.
2020-09-22 19:10:58 +02:00
Sergey Igushkin aebca19fd7 Fix resolving an MPP dependency in custom configurations (KT-32239)
In the `KotlinPlatformType` disambiguation rule, don't prefer `common`
when there's a `jvm` or an `androidJvm` variant, as this would conflict
with disambiguation rules created by the other plugins, such as Gradle's
`java` which will choose `org.gradle.usage=java-api` and lead to
ambiguity.

Issue #KT-32239 Fixed
2020-07-14 13:09:22 +04:00
Sergey Igushkin 1f5fa5eb7c Add back empty stub implementations of KotlinGradleSubplugin (KT-39809)
* If a KotlinGradleSubplugin implements
 KotlinCompilerPluginSupportPlugin, don't apply it as a legacy plugin

* Add the legacy KotlinGradleSubplugin implementations back so that
 when there's JAR hell with META-INF/services in the old artifacts
 pointing to the classes, loading the plugins with ServiceLoader (legacy
 implementation) from the new artifacts would not fail.

* There's a corner case for plugins not in kotlin-gradle-plugin
 If a newer and older version of such a subplugin is used with an older
 version of the Kotlin Gradle plugin, the latter will find the META-INF
 entries and will try to load the subplugins from the new version. With
 the original fix for KT-39809, this would result in silently ignored
 empty stub implementations.

 Given that the Kotlin Gradle plugin can now check if a subplugin
 supports the new API, it's OK to keep the old entries and make the
 stub implementations throw a build error when called, so that improper
 plugin versions are not ignored and are clearly reported.

 Note that this is only necessary for the subplugins not bundled in the
 kotlin-gradle-plugin module, as those will always be in sync with the
 Kotlin version.

Issue #KT-39809 Fixed
2020-06-30 12:51:51 +03:00
Sergey Igushkin f7b660b573 (minor) Fixes for review KT-MR-1290 2020-06-19 17:31:51 +03:00
Sergey Igushkin 96ed30a449 Introduce new API for Kotlin compiler support Gradle plugins
The old API was too specific for the Kotlin internal use cases and
leaked some abstractions due to the missing target-compilation project
model. One of such leaking abstractions was the Gradle tasks being
exposed to the subplugin, which required the tasks to instantiate
in order for the subplugin to apply. This violated task configuration
avoidance, so the old API could never work in compliance with TCA.

Introduce the new KotlinCompilerPluginSupportPlugin API that uses the
compilations instead of the tasks and is TCA-compliant.
2020-06-19 17:30:05 +03:00
Sergey Igushkin f4e4baa253 Add TaskProvider property for Kotlin compile tasks in compilations 2020-06-19 17:28:37 +03:00