Setting `forkMode` to `ForkMode.NEVER` switches
`isolationMode` to `IsolationMode.CLASSLOADER`.
Classloader isolation mode prevented passing task's
logger to the unit of work.
Also it might resulted in multiple daemon instances starting
in parallel.
This change removes setting `forMode` (it was unnecessary).
Also a logger is used for the fallback message instead of printing it
to stderr. An assertion is added to tests, ensuring that
the fallback does not happen.
#KT-29394 Fixed
#KT-12295 Fixed
Gradle forces non-incremetnal builds,
when a task failed, but its outputs were changed.
This is an issue for Kotlin incremental compilation,
because it also forces all dependent modules to be rebuilt.
This change fixes the issue by reading all output and
restoring it on a compile error/exception.
This change does not affect non-incremental builds.
On windows using a project's root
as a working directory for the daemon
seems to prevent removing the directory
when the daemon runs.
Different projects may share an instance of the daemon,
so the issue will be present only in a project
which started the daemon.
1. There is no need to specify repositories.
2. We don't use 'org.jetbrains.kotlin:gradle-api:1.6' anymore.
3. kotlin-serialization-unshaded does not need dependencies,
because it does not contain source code (it simply packages jar).
AGP 3.0.x requires explicit 'kapt' dependency on databinding compiler.
Also databinding v2 (enabled by default in AGP 3.2.0) generates different
java classes.
There are a few isolation modes for Gradle workers. KAPT uses 2 of them.
IsolationMode.NONE is the default. It runs workers in Gradle daemon and
is more memory efficient.
IsolationMode.PROCESS forks workers into individual processes. This
keeps some resource leaking annotation processors from affecting the
rest of compilation.
Users can specify kapt.workers.isolation=process, if they need to use
some annotation processor that are known to be resource leaking.
* Move source artifacts to KotlinVariant classes (since joint Android
variants may have multiple source artifacts, make it a set)
* Change lowerSpinalCaseName to dashSeparatedName (doesn't transform
the strings to lower case inside)
* Don't transform the project name to lower case (in the future, it may
be reasonable to stop transforming the target and component names, too)
Still transform the target names and the component names.
Currently, this is the way we don't break existing publications and may
still reconsider this in the future.
* Add a workaround for a list of GString's assigned to
publishLibraryVariants
* Check for Android library variants existence in a more strict way,
report existing variants that are not library variants.
A dependency on a multiplatform module with a jvmWithJava target failed
to resolve because the 'apiElements' and 'runtimeElements'
configurations didn't have the attribute 'localToProject' set to
'public'.
Those configurations need to have have the attribute set as per the
fix of KT-28795, but it doesn't happen.
Issue #KT-29035 Fixed
As KotlinCompilation only contains the directly added source sets in its
`kotlinSourceSets` property, we need to provide a convenient way to
collect the whole source sets hierarchy for a compilation.
We added internal `allKotlinSourceSets` some time ago, and it seems
reasonable to expose it as public API.
Issue #KT-28749 Fixed
As we introduced the 'api' configurations for Kotlin source sets, the
Java plugin did not link these configurations to its 'apiElements', and
those dependencies would only get published with the 'runtime' scope
through the 'implementation' configuration.
To fix this, manually specify that 'apiElements' extendsFrom 'api'.
Issue #KT-28355 Fixed
In Gradle 5.0, the 'prefer' function semantics has changed, and now a
transitive dependency version wins over the 'preferred' one. Instead,
'require' has been introduced in 5.0 with the old semantics.
Our users expect that the default Kotlin dependency version will be
at least as new as the plugin version, so we now need to use 'require'
with Gradle 5.0+
Issue KT-28820 Fixed
As non-Gradle consumers and Gradle consumers with metadata disabled
cannot read Gradle metadata, in POMs (the only source of dependencies
for the consumers mentioned above), we should publish the dependencies
on modules with metadata as the target artifact IDs rather than the root
MPP module ID (e.g. 'foo-jvm' rather than 'foo').
To do that, we rewrite the POMs of the publications even when Gradle
metadata is enabled. Note: in the POMs, a project dependency is already
written in the form of the artifact ID of the root Kotlin software
component, so it complicates the dependencies rewriting a little.
To rewrite third-party dependencies, we detect dependencies that
resolved to no artifact and have a single child in the Gradle
dependencies graph of the resolved configuration – this is what a
dependency looks like which was redirected to another module via
'available-at'.
Issue #KT-28482 Fixed
To configure a compilation's sources, we run an action in
`whenEvaluated { ... }`, expecting that the compilation's task already
exists. This was not true with compilations created from a user build
script or a 3rd-party plugin in `afterEvaluate { ... }`.
Fix this by expecting that a task may possibly not exist at that point,
and also using `whenEvaluated { ... }` instead of
`afterEvaluate { ... }` in several places that are executed for each new
compilation as a workaround for
https://github.com/gradle/gradle/issues/1135.
Issue #KT-28896 Fixed
Also update the code for rewriting the dependencies, as Android variants
have their dependencies configurations formed a bit differently, and
also introduce the logic for choosing the right component by the
configuration name the dependency resolves to.
Issue #KT-27535 Fixed
Move the logic of attaching a source JAR to a publication to the
components management part, as building a source JAR will be done
differently for Android.
Instead of exposing a single `component` in a target, allow it to have a
set of `components`, then create a Maven publication for each of the
components.
Move `createUsageContexts` to private API since a target that has
multiple publications may need to create the usage contexts for those
publications differently.
Move some of the components technical stuff to interfaces
`DelegatedToPublication` and
`ComponentWithCoordinatesDelegatedToPublication` in order to reuse it
later for Android's components.