Commit Graph

66 Commits

Author SHA1 Message Date
Vyacheslav Gerasimov f58acbeef5 Build: implement useBootstrapStdlib flag
Excludes stdlib projects from build and uses bootstrap stdlib artifacts

 #KT-29205
2019-01-21 21:09:40 +03:00
Alexey Tsvetkov b51461b5c5 Drop support for Gradle 3.x
#KT-27885 Fixed
2019-01-16 15:57:32 +03:00
Sergey Igushkin 8bc7ac32f3 Fixes for review KOTLIN-CR-2599
* 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.
2019-01-11 20:32:38 +03:00
Sergey Igushkin 0abd044800 Expose 'allKotlinSourceSets' in KotlinCompilation (KT-28749)
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
2019-01-11 20:32:37 +03:00
Sergey Igushkin d211bd53c9 Allow a target to have multiple publications, restructure the code
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.
2019-01-11 20:32:36 +03:00
Ilya Chernikov c4b3580c31 Implement script filename extensions discovery via artifact transforms
to avoid using never-up-to-date task and make discovery cacheable and
checkable for up-to-dateness
#KT-28469 fixed
2018-12-21 15:44:48 +01:00
Sergey Igushkin 67e82a54e5 Fix Gradle 5.0 deprecation warnings:
* DefaultSourceDirectorySet constructor is deprecated -> objects()
* IvyRepository.layout('pattern') { } is deprecated -> patternLayout { }

Issue #KT-26808 Fixed
2018-12-17 16:09:57 +03:00
Sergey Igushkin 0f670f806f Fix Android Extensions early dependency resolution
Make compiler plugin options evaluate lazily, with Lazy<String> and
FileCollection as replacements for the eagerly-evaluated data.

Adjust compiler plugin option usages so that their evaluation is not
triggered when not necessary.

Issue #KT-26065 Fixed
2018-11-30 15:34:21 +03:00
Sergey Igushkin 202c86aafe Add a function attributes { } to KotlinTarget and KotlinCompilation
Gradle has a function `attributes { ... }` for `Configuration`, so we
can introduce one, too, for uniformity of the DSLs. This will configure
the `val attributes: AttributeContainer` of the `KotlinTarget` and
`KotlinCompilation`.

Issue #KT-27682 Fixed
2018-11-27 19:47:48 +03:00
Sergey Igushkin 4dd95e331f Add missing DSL features to the MPP dependencies DSL
* Add DSL for project(...) with path and configuration
* Add DSL for e.g. api(someDependency) { /* ... */ }
* Add DSL for e.g. api(kotlin("stdlib"))

Issue #KT-26663 Fixed
2018-11-27 19:47:45 +03:00
Sergey Igushkin cee52c095f Add and generate Groovy-friendly DSL members
As Gradle Groovy DSL does out-of-the box not allow working with
SAM-receiving functions in the same way as those accepting a Closure,
and, moreover, does not work with Kotlin default parameters, we need
to provide Groovy-friendly DSL functions along with Kotlin DSL functions

This commit adds those additional members for all of the newly
introduced MPP DSL members.
2018-11-27 19:47:44 +03:00
Sergey Igushkin fe64d33ae4 Add defaultSourceSet to KotlinCompilation
Previously, the connection between a `KotlinCompilation` and its
default `KotlinSourceSet` (the one automatically created and added into
the compilation) was not expressed in the MPP model in any reasonable
way that can be used in the build scripts.

However, this connection seems to have settled in the build logic, and
it may be useful to be able to get the default source set from a
compilation, for example, to be able to configure dependencies across
several targets in a uniform way.

The metadata compilations don't have their dedicated source sets, but
we can think of commonMain as a default source set for the project's
metadata, is it is currently in fact only contains the declarations from
commonMain.

Issue #KT-27685 Fixed
2018-11-27 19:47:39 +03:00
Sergey Igushkin 581b161611 Expose statically-typed kotlinOptions and compileKotlinTask in DSL
To simplify configuring a `KotlinCompilation` with Gradle Kotlin DSL, it
is essential to expose statically-known types where possible.

This commit parametrizes `KotlinCompilation` with its Kotlin options
type (a subtype of `KotlinCommonOptions`) and adds `kotlinOptions` and
`compileKotlinTask` to `KotlinCompilation`.

(minor) Also reduce the visibility of `attachClassesDir` and
`setupPlugins` to internal, since this API is not for external use.
2018-11-27 19:47:38 +03:00
Sergey Igushkin ae5d59caf0 Add a new root of <...>.dsl.KotlinCompile hierarchy in API
This new interface uses a more general type for its kotlinOptions,
KotlinCommonToolOptions rather than KotlinCommonOptions. This is
needed for the Kotlin/Native task to implement a common interface
with the other Kotlin compilation tasks.
2018-11-27 19:37:50 +03:00
Sergey Igushkin ecd54d9b21 (minor) Move KotlinCommonToolOptions to kotlin-gradle-plugin-api
This change is needed to expose `kotlinOptions { ... }` in the
API interfaces.
2018-11-27 19:37:50 +03:00
Sergey Igushkin 635d436f02 Provide preset-like factory functions for creating targets in new MPP
* Pull the `targets` and `presets` properties of the `kotlin` extension
  up to an interface in `kotlin-gradle-plugin-api`

* Generate the code: we need type-safe statically-typed functions for
  different target type, which seems to be only possible to achieve by
  providing a function per preset.

* Place these functions in the top-level `kotlin` Gradle extension,
  rather than extension functions for `kotlin.targets`:

  - `kotlin.jvm { ... }` will work, while `kotlin.targets.jvm { ... }`
    won't, the extension function needs to be somehow brought into scope

  - reducing the nesting level by one seems to be a good move here

Issue #KT-26389 Fixed
2018-11-27 19:37:49 +03:00
Alexey Tsvetkov e0e3d90774 Convert kotlin-gradle-plugin-api build script: step 2 2018-11-01 00:59:07 +03:00
Alexey Tsvetkov 0ab326e4ba Convert kotlin-gradle-plugin-api build script: step 1 2018-11-01 00:59:07 +03:00
Sergey Igushkin c25cdb4264 Fix resourcesDir that cannot be imported due to not being a File 2018-10-16 14:30:25 +03:00
Sergey Igushkin 5db23f1a81 Support -Xuse-experimental in the new MPP languageSettings { ... } DSL
Add the corresponding Gradle plugin DSL, consistency checks, and logic
for propagating these settings to the compiler during build.

Issue #KT-26840 In Progress
2018-10-16 14:30:24 +03:00
Sergey Igushkin a0f4d5a637 Get rid of FileCollectionInternal usage that breaks with Gradle 5.0+
Remove the implementation of the `FileCollectionInternal` interface in
`KotlinCompilationOutput`. This interface may change unexpectedly (and
does between Gradle 4.10 and 5.0) so we need to get rid of its
implementation.

On the other hand, we can't just implement `FileCollection` instead
because Gradle internally assumes that all `FileCollection` instances
are also `FileCollectionInternal`. So the way to fix this is to remove
`SourceSetOutput` from superinterfaces of `KotlinCompilationOutput`
altogether.

Instead, to work with `SourceSetOutput` and `KotlinCompilationOutput`
in a uniform way, provide a wrapper for `SourceSetOutput`:
`KotlinWithJavaCompilationOutput` that is basically a proxy
class.
2018-10-11 19:01:52 +03:00
Sergey Igushkin 44f87e4951 Revert "(minor) Transform KotlinPlatformType attribute to String, rename entries"
This reverts commit 3f24f8bd
2018-09-26 15:58:14 +03:00
Sergey Igushkin 3f24f8bd8d (minor) Transform KotlinPlatformType attribute to String, rename entries
* To avoid unexpected effects from the Gradle instantiation mechanisms
  for attribute values, use a safer String attribute type for the
  KotlinPlatformType attribute

* Rename its entries to keep enum entries naming consistent
2018-09-26 13:02:32 +03:00
Sergey Igushkin 76b51b1058 Allow the common platform type consumers to consume platform artifacts
When a Kotlin metadata input configuration tries to resolve a module
with no Kotlin metadata (such as: plain old Maven module, a non-MPP
Kotlin project with a single platform), it should be able to resolve
successfully.

Given that the input metadata configurations extend from source set
dependencies configurations, where platform-specific dependencies may
occur, allowing the metadata configuration to resolve such dependencies
into platform artifacts seems to achieve successful dependency
resolution.

Issue #KT-26834 Fixed
2018-09-26 13:02:31 +03:00
Alexey Tsvetkov de261df6f5 Use separate configuration for resolving native compiler plugin artifacts
Kotlin/JVM and Kotlin/JS use shaded compiler, but
Kotlin/Native uses non-shaded one.
Serialization plugin was configured to use either shaded or non-shaded
plugin version, because we used one configuration for resolving
compiler plugins.
This change introduces 'kotlinNativeCompilerPluginClasspath' configuration
for resolving Kotlin/Native compiler plugins.
2018-09-25 11:08:39 +03:00
Ilya Matveev ea1abb0680 Provide a DSL for publication settings (#1869)
* Provide a DSL for publication settings
* Rename DSL method publication -> mavenPublication
* Fix gradle task input/output validation

 #KT-26771 fixed.
2018-09-17 11:04:55 +03:00
Ilya Chernikov a03bfb3561 Implement support for non-kts scripts in gradle
#KT-26784 fixed
2018-09-13 20:47:21 +02:00
Ilya Matveev 29048ce5ae Add generated interop libraries in compile dependency configuration (#1864) 2018-09-11 16:07:33 +03:00
Ilya Matveev 3269c0e51b Support cinterop in the native part of kotlin-multiplatform 2018-09-10 20:43:00 +03:00
Dmitriy Dolovov 337100edc3 Rename "konan" modules to "kotlin-native" modules 2018-09-08 12:16:20 +03:00
Sergey Igushkin 67bd659390 Fallback to publishing with coordinates inferred from publication
In Gradle < 4.7, there's no `ComponentWithCoordinates` interface, and we
need to make sure that none of our classes implementing this interface
are loaded with older Gradle versions.

Instead of that interface, we can rely on Gradle's metadata generation
heuristic that takes Maven coordinates for the variants from the
corresponding publications.
2018-09-06 22:59:27 +07:00
Ilya Matveev c23296a0d8 Publish different targets as different software components 2018-09-06 22:59:27 +07:00
Sergey Igushkin 96901c5487 Move KotlinSourceSet back to org.jetbrains.kotlin.gradle.plugin.*
After all MPP related changes, the `KotlinSourceSet` interface turns out
compatible with the old `KotlinSourceSet`, and, since there are external
usages of `KotlinSourceSet`, it is reasonable to expose the new
interface under the old FQ-name to fix those external usages.

Issue #KT-26498 Fixed
2018-09-06 12:35:59 +03:00
Ilya Gorbunov 8102e512d3 For bootstrapping on 1.3-M1: compile parts that can be used in .gradle.kts scripts with 1.2 language version 2018-08-30 14:50:23 +03:00
ilmat192 2251440f04 Basic native support in kotlin-multiplatform (#1811)
* Add dependency on KN shared in gradle-plugin

* Basic support for Kotlin/Native:
     * Target presets
     * Compilation into a klib
     * Compilation into native binraies: framework and executable
     * Basic dependencies between projects
     * No jars in native publications
     * Replace '-' with '_' in framework names
    * Escape quotes in native command lines on Windows
* Move targets from Kotlin/Native repo
* Download KN compiler using Gradle's mechanisms
* Support source set dependencies in native
2018-08-19 20:45:31 +07:00
Sergey Igushkin 1a3dd67176 Enable metadata publishing for new MPP and consumption from source sets
* Add configurations for consuming source sets metadata (extending the
  source set's dependency configurations). These configurations will be
  used by the IDE to pick up the dependencies metadata.

* Remove the universal preset from the default presets, create a
  metadata target by default for compiling and publishing the metadata
  of `commonMain` (in the future, we will publish and consume the
  metadata of the other source sets as well).

* Make the classpath configurations of common modules consume the
  metadata and thus ensure compatibility of 1.2.x MPP with the new MPP
  model.
2018-08-17 15:12:44 +03:00
Sergey Igushkin 5815d6a70c Implement language settings API for Kotlin source sets 2018-08-11 23:16:03 +03:00
Sergey Igushkin caec846330 Improve Android libraries support: allow project dependency on a lib
* Add a platform type androidJvm that is one-way compatible (can
  consume but cannot be consumed) with jvm, register the matching
  strategy

* Write our attributes to Android's output configurations (this uses
  a naming convention that Android inherits from Java, but there's no
  public API at the moment for that)
2018-08-07 15:55:46 +03:00
Sergey Igushkin 3ff61f59a7 Implement dependsOn relation for Kotlin source sets
* Setup configurations' extendsFrom and inherit sources of source sets.
  This make it unnecessary to restore transitive dependencies of a
  source set at its use sites, since their sources and dependencies are
  already included.

* Use dependsOn during default configuration instead of compilation.source()
2018-08-07 15:55:45 +03:00
Sergey Igushkin dc7d488deb Update existing plugin implementations to use KotlinCompilation
Add default implementations for KotlinTarget and KotlinCompilation
(some of them are used in code added by further commits).

Refactor AbstractKotlinPlugin so that parts of its logic can be easily
applied outside the plugin (needed for MPP plugin later).

The single platform Kotlin plugins having Kotlin compiled along with
Java will now create a KotlinCompilation and a KotlinSourceSet per Java
source set or per Android variant.
The build configuration logic will use KotlinCompilation
objects rather than Java or Android plugin entities.

Subplugins API and implementations are updated to use KotlinCompilation.
2018-08-07 15:55:44 +03:00
Sergey Igushkin 3828c26fa9 Introduce new API
These interfaces are needed for both new MPP design and getting rid of
the Java plugin source sets in favor of Kotlin source sets
2018-08-07 15:55:43 +03:00
Sergey Igushkin dbd72ae53b Fix Android ap option providers as Kapt task nested inputs
1) Exclude the providers arguments from the kapt inputs, as the values
may contain absolute paths, may be output properties etc. The providers
should correctly annotate their inputs.

2) Fix the options passed to kapt as 'value=option' (leading to all the
options collapse into one with the null key), use 'key=option' instead
to make Kapt pass them as '-Aoption'.

Issue #KT-23866 Fixed
Issue #KT-25027 Fixed
2018-06-25 15:03:52 +03:00
Leonid Startsev bef97d85af Respect version string in SubpluginArtifact to load compiler plugins
with versions different from compiler one
2018-06-22 21:13:34 +03:00
Alexey Tsvetkov 873de17056 Resolve compiler plugin classpath using 'kotlinCompilerPluginClasspath' configuration
#KT-24653 fixed
        #KT-24676 fixed
2018-06-01 23:13:36 +03:00
Yan Zhulanow ba5836d666 Pill: Introduce pill{} extension to set extended Pill configuration
Also introduce the flavor concept which allows to specify what part of Kotlin project should be imported.
2018-05-15 16:29:45 +03:00
Sergey Igushkin 0c78a2c026 Remove some of the remaining mentions of repository.jetbrains.com 2018-01-23 23:35:50 +03:00
Sergey Igushkin 5deb20543f Get rid of gradle-api artifacts uploaded to and used from JB repo
Remove redundant Maven dependency to `gradle-api` scoped as provided
2018-01-17 18:45:26 +03:00
Sergey Igushkin 1be9e04797 Move conditional task caching setup into the task constructors;
Add 'kotlin.caching.enabled' flag to switch the caching for all tasks;
Rename and change semantics of cache support checks: make two instead
    of one, `isBuildCacheSupported` and `isBuildCacheEnabledForKotlin`;
Remove FileOptionKind entries that are redundant at the moment;
Improvements in BuildCacheIT.kt and other refactoring  suggestions from
    the review
    https://upsource.jetbrains.com/kotlin/review/KOTLIN-CR-1647
2018-01-03 22:14:22 +03:00
Sergey Igushkin c852d0b6cb Subplugin options refactoring & Gradle input improvements
Introduce FilesSubpluginOption Special kind of SubpluginOption that
holds a list of files together with the kind of these files with respect
to the task.

Add a logic for handling such options and converting them into
task inputs.

Refactor CompilerPluginOptions: make it store subplugin options to be
able to add options from KotlinCompile to the kapt tasks.

Introduce WrapperSubpluginOption for encoded and complex options.

Remove pluginOptions from the Gradle inputs built from the
compiler args.

Do not cache Kotlin compilation with kapt1 enabled: since we are going
to drop kapt1 it anyway, there's no point in implementing
proper cache for it, so just disable the caching of the task in case
kapt1 is used.
2018-01-03 22:14:22 +03:00
Ilya Chernikov df04efcf14 Rename artifacts, fix dependencies and artifact contents 2017-09-20 11:52:00 +02:00