Sometimes we need to report warnings during the configuration phase.
For example, when Androidx Compose Compiler is used with
non-JVM targets (e.g. iOS/js), we want to warn users
that using non-JB compiler with non-JVM targets is not supported.
The default way of reporting warnings in Gradle is using a logger.
For example we could write something like:
```
abstract class ComposePlugin : Plugin<Project> {
override fun apply(project: Project) {
if (project.hasNonJvmTargets() && project.usesNonJBComposeCompiler()) {
project.logger.warn("...")
}
}
}
```
This approach has a few issues:
1. When the Configuration Cache is enabled, project's configuration might
get skipped altogether, and the warning won't be printed.
2. If a project contains multiple Gradle modules (subprojects),
the warning might be printed multiple times. That might be OK
for some warnings. But repeating exactly the same warning
10s or 100s is unnecessary.
The only way to share the state between Gradle modules,
while preserving compatibility with the Configuration Cache,
is to define Gradle Build Service.
In 1.5.0 we used Gradle Build Service mechanism for both warnings.
However, I did not know that:
* only the service's parameters are persisted in the Configuration Cache.
The service itself is not persisted.
* if a service instance is materialized during the configuration
phase, then all changes made to its parameters will not be
visible to that particular instance (but they will be visible to the
next instance).
So the only way to report diagnostics with configuration cache without
repetition is to define a service that is not materialized
during the configuration phase (i.e. serviceProvider.get() is not called),
add to add warnings to a set property of the service.
This change implements that.
Resolves#3595
The new android multiplatform plugin will have type `jvm` but doesn't
inherit from the KotlinJvmTarget type, which makes the compose
multiplatform gradle plugin not useable with the new android gradle
plugin for multiplatforms builds.
* Fix cache kind management with nested subprojects
Previously, cache kind property management
worked incorrectly when Compose Gradle plugin
was applied to both parent and child subprojects,
e.g. :compose-subproject-1:compose-subproject-2.
With this example the plugin would successfully
set the property for compose-subproject-1,
but then for compose-subproject-2 the following snippet
would fail:
```
if (project.hasProperty(targetCacheKindPropertyName)) {
project.setProperty(targetCacheKindPropertyName, NONE_VALUE)
}
```
because project.hasProperty would have return true
(because it checks parent subproject properties too),
but project.setProperty would fail, because
parent project's properties are read only.
Warnings were also handled incorrectly in this case,
because during the configuration of compose-subproject-1 we might set
`kotlin.native.cacheKind.ios*=none`,
which would then cause a warning during the configuration of compose-subproject-2.
To avoid incorrect warnings, we now
record the snapshot of relevant properties
during Compose Multiplatform build service initialization
Resolves#3515
* Fix issues from code review
For iOS/Web it will be stabilized with stabilizing these targets themselves. Also, we should expose uiTest for them, not uiTestJUnit4
JUnit5 support will be provided in the future in [this issue](https://github.com/JetBrains/compose-multiplatform/issues/2371)
## API Changes
- Testing framework is stabilized for Desktop
- `compose.uiTestJUnit4` is renamed to `compose.desktop.uiTestJUnit4`
We tried to enable the compiler cache, when
Kotlin/Native 1.9.0 is used.
Prior to Kotlin 1.9.0, the caching could not
be used with Compose, because code generation would fail.
With Kotlin 1.9.0, code generation succeeds, but generated debug symbols cause issues with dsymutil during xcode build.
For more details, see https://youtrack.jetbrains.com/issue/KT-61270
This change partially reverts https://github.com/JetBrains/compose-multiplatform/pull/3477 and https://github.com/JetBrains/compose-multiplatform/pull/3496
Now, we always set `kotlin.native.cacheKind=none` in
Compose Multiplatform Gradle plugin for all
versions of Kotlin until KT-61270 is fixed.
Also, explicit cache kind error becomes a warning again.
It updates the default version of compose compiler plugin for kotlin 1.9.0
For now it's 1.5.1-rc01 version. For a stable release, we'll build a stable 1.5.1 compose compiler plugin.
* Handle ClassCastException for ComposeMultiplatformBuildService in Compose Gradle plugin
ClassCastException might occur when our gradle plugin was loaded more than once. See https://github.com/JetBrains/compose-multiplatform/issues/3459
We throw another exception with a bit more clear message.
* Update gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt
Compose compiler plugin produces symbols with identical signatures. k/jvm and k/native do not check for clashes, while k/js does. We disable the checker in our gradle plugin, so our users do not need to add extra workaround on their side.
* Simplify resource management for iOS
Introduces new a new task 'sync<FRAMEWORK_CLASSIFIER>ComposeIosResources',
which collects resources from all source sets, included in iOS targets.
With this change:
* CocoaPods integration does not require any configuration or calling 'pod install' after changing resources.
* Important: existing projects need to remove 'extraSpecAttributes["resources"] = ...' from build scripts, and rerun `./gradlew podInstall` once!
* Without CocoaPods, the resource directory should be added to XCode build phases once.
Resolves#3073Resolves#3113Resolves#3066
* Add a warning for a user who sets `compose.kotlinCompilerPlugin` to `android.compose.compiler.compiler`
The warning will show up only when a multiplatform project contains at least one of the non-jvm targets: k/js, k/native or k/wasm
* fix typo
* PR review
* Refactor to BuildService
* fix typo
* Improve error messages when checking tasks
Previously some errors in checkRuntime task
were reported as a nested exception.
By default, Gradle shows only top-level
error message of an exception, which
made some errors confusing.
For example, when javac was missing from JDK,
Gradle only showed "Could not infer Java runtime version for Java home directory".
The part that said javac was missing was only shown,
when Gradle was run with --stacktrace argument.
This is suboptimal UX, so this commit refactors
checkRuntime to make error messages more descriptive.
#3133
* Handle JDK 1.8 correctly
* Prebuild jdk version probe
* Fix signing bundle with Gradle 8.1 with configuration cache
Compose Gradle plugin was launching
`/usr/bin/security --find-identity` in a lazy property of
AbstractJPackageTask. Without the configuration cache
the computation was delayed to the execution phase.
However, configuration cache serializes all properties of
all configured tasks, so launching of `/usr/bin/security`
shifted to the configuration phase.
Gradle 8.1 started to throw an exception if an external process is
launched during configuration time.
This change explicitly moves the call to
`/usr/bin/security` to the execution phase.
Resolves#3060
* Turn off Gradle configuration cache for one test
* Improve a message about incompatible kotlin version
Add Compose Multiplatform to the message
* Update gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatibility.kt
Co-authored-by: Igor Demin <igordmn@users.noreply.github.com>
---------
Co-authored-by: Igor Demin <igordmn@users.noreply.github.com>
In 991b7ff6a7 'nativeExecutables' was
renamed to 'nativeDistributions', however a later commit added error
messages that still reference the old DSL names.
Previously Compose Multiplatform Gradle plugin required
JDK 15+ for distribution packaging. However, fixing #2867 required
always passing --mac-entitlements to jpackage, which is
only available with JDK 17+.
1. Rename "compose.web" to "compose.html" in Gradle DSL
2. Rename maven artifacts (with backward compatible "relocation" artifact)
3. Rename "web" folder to "html"
Will do in support/1.4.0 branch
1. Move examples/web-* to examples/html/*
2. Rename Tutorials/Web to Tutorials/HTML
3. Rename "Compose for Web" to "Compose HTML Library" in the tutorials
Normally macOS Gatekeeper does not allow unsigned apps to run.
However, apps created on the same machine were allowed to run.
This allows developers to test package apps on their machines
without configuring Apple Developer ID.
Previously, the Compose Multiplatform Gradle plugin
simply did not do anything, when the signing was not configured.
However, in macOS Ventura the Gatekeeper checks
became stricker, so "unsigned" packaged apps started to
be shown as "damaged".
This seems to happen, because parts of a final app image
were signed. Also they were signed by different certificates
(a runtime image could be signed by a runtime vendor,
while Skiko binary is signed by JetBrains).
This change removes all signatures if signing is not configured.
See also https://bugs.openjdk.org/browse/JDK-8276150Fixes#2476
The `jsProcessResources` task needs to depend on the
`unpackSkikoWasmRuntimeJs` task since it explicitly consumes one of its
outputs. Otherwise, a Gradle warning occurs during compilation that task
execution optimizations have been disabled.
* Compose 1.2.1-rc01
* Fix Web build for Kotlin 1.7.20
* Use 1.3.2.1-rc02 in Gradle plugin
* Fix Gradle Plugin tests
* Fix Gradle Plugin tests
* Compose 1.2.1-rc03
* Update CHANGELOG.md
* Update CHANGELOG.md
* Compose Compiler 1.3.2.1
* Compose 1.2.1
* Update VERSIONING.md
* Update gradle.properties
* Fix custom JDK tests on Linux
* Remove JVM target version override (#2515)
Previously, we were setting kotlin.jvmTarget version
to 1.8 if it was null or < 1.8.
As an unintended consequence we were also overriding
a version set by the jvmToolchain property.
So while users expected the jvmToolchain property
to set both jdk home & jdk target, we were quietly
overriding jdk target.
At the same time, Kotlin 1.7 sets the minimum
target version to 1.8 anyway, so our override
does not make sense with Kotlin 1.7+.
This commit removes overriding altogether.
Fixes#2511
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update Compose
* Update default ProGuard rules with changes from main branch
* Test Gradle plugin on relevant PRs (#2509)
* Update Gradle used in tooling subprojects
* Update Kotlin in Compose Gradle plugin
* Decrease verbosity of Gradle plugin tests
* Disable mac sign test
* Add workflow to test Gradle plugin
* Fix custom jdk tests on Linux
* Make Compose Gradle plugin build compatible with Configuration cache
* Print tests summary
* Remove unused code
* Refactor tests configuration
* Turn off parallel execution
* Try adding windows runner
* Turn off fail fast
* Fix Windows test issues
#2368
* Adjust default proguard rules
The following rule is needed to fix tests on Windows:
```
-dontwarn org.graalvm.compiler.core.aarch64.AArch64NodeMatchRules_MatchStatementSet*
```
Other rules are just to make builds less noisy.
Kotlin's `*.internal` packages often contain
bytecode, which triggers ProGuard's notes.
However, these notes are not actionable for
most users, so we can ignore notes by default.
#2393
# Conflicts:
# gradle-plugins/gradle/wrapper/gradle-wrapper.properties
* Improve DSL for setting a custom Compose Plugin (#2527)
* Improve DSL for setting a custom Compose Plugin
Fixes https://github.com/JetBrains/compose-jb/issues/2459
Readme: https://github.com/JetBrains/compose-jb/pull/2526
1. Add `dependencies: Dependencies` extension that is accessible in `compose { }` block
2. Add `Dependencies.compiler` property that can return versions of Compose compiler used by the plugin:
```
compose {
kotlinCompilerPlugin.set(dependencies.compiler.forKotlin("1.7.20"))
//kotlinCompilerPlugin.set(dependencies.compiler.auto) // determined by applied version of Kotlin. It is a default.
}
```
3. Add ability to set arguments for Compose Compiler. Now we can write:
```
compose {
kotlinCompilerPlugin.set(dependencies.compiler.forKotlin("1.7.20"))
kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.7.21")
}
```
4. Remove checks for different targets
We had a separate check for JS, when we released 1.2.0. It doesn't support Kotlin 1.7.20 at that moment.
It is hard to refactor this feature in the new code, so I removed it. It is not needed now and it had an ugly code. When we will need it again, we'll write it again.
5. Remove the `compose.tests.androidx.compiler.version` property from gradle.properties and remove `defaultAndroidxCompilerEnvironment`
Because they are used only in one test, and it seems there is no reason to use it in another place in the future
* Discussions
* Update ComposeCompilerCompatability.kt (#2557)
* Update CHANGELOG.md
* 1.2.2-rc01
* Update Compose
* Update CHANGELOG.md
* Compose 1.2.2
* Remove shared.podspec
* Remove usages of deprecated Intellij APIs
Co-authored-by: Alexey Tsvetkov <alexey.tsvetkov@jetbrains.com>
Co-authored-by: Alexey Tsvetkov <654232+AlexeyTsvetkov@users.noreply.github.com>