Add fat jars for gradle plugin (#2149)
* [gradle-plugin] Bundle big Kotlin plugin into the native plugin jar * Use big Kotlin's version in the Gradle plugin * [gradle-plugin] Exclude big Kotlin plugins from final jar * Use composite build again * Remove MULTIPLATFORM.md * [gradle-plugin] Fix adding common sources * [gradle-plugin] Fix test running
This commit is contained in:
committed by
Nikolay Igotti
parent
892e90cee5
commit
da054ffe99
@@ -1,442 +0,0 @@
|
||||
# Kotlin/Native in multiplatform projects
|
||||
|
||||
While Kotlin/Native can be used as the only Kotlin compiler in a project, it is pretty common to combine
|
||||
Kotlin/Native with other Kotlin backends, such as Kotlin/JVM (for JVM or Android targets) or Kotlin/JS
|
||||
(for web and Node.js applications). This document describes the recommended approaches and best practices for such scenarios.
|
||||
|
||||
Kotlin as a language provides a notion of expect/actual declarations, and Gradle in turn
|
||||
augments it with the notion of multiplatform projects (aka MPP). These two, combined together, provide a flexible
|
||||
standardized [mechanism of multiplatform development](https://kotlinlang.org/docs/reference/multiplatform.html)
|
||||
across various Kotlin flavors.
|
||||
|
||||
Code, common amongst multiple platforms can be placed in common modules, while platform-specific code can be placed
|
||||
into platform-specific modules, and expect/actual declarations can bind them together in a developer-friendly way.
|
||||
|
||||
Below you will find a step-by-step tutorial for creating a Kotlin multiplatform application for Android and iOS.
|
||||
|
||||
## Creating multiplatform Android/iOS application with Kotlin
|
||||
|
||||
To create an MPP application you have to start with clear understanding of which parts of an application are common for different
|
||||
targets, and which are specific, and then organize the module structure accordingly. For shared Kotlin code the common
|
||||
ground consists of Kotlin's standard library, which does include basic data structures and computational primitives,
|
||||
along with some expected classes with platform-specific implementation. Most frequently, such code consists of a GUI,
|
||||
input-output, cryptography, and other APIs, available on the particular platform.
|
||||
|
||||
In this tutorial, the multiplatform application will include three parts:
|
||||
|
||||
* An **Android application** represented by a separate Android Studio project written in Kotlin.
|
||||
* An **iOS application** represented by a separate Xcode project, written in Swift.
|
||||
* A **multiplatform library** containing the business logic of the application and used by both Android and iOS applications.
|
||||
This library can contain both platform-dependent and platform-independent code and is compiled into a `jar`-library
|
||||
for Android and in a `Framework` for iOS by Gradle.
|
||||
|
||||
So, the multiplatform library will include three subprojects:
|
||||
|
||||
* `common` - contains common logic for both applications
|
||||
* `ios` - contains iOS-specific code
|
||||
* `android` - contains Android-specific code
|
||||
|
||||
### 1. Preparing a workspace
|
||||
|
||||
Let's represent the structure described above as a directory tree. Assume that our multiplatform library is intended to
|
||||
generate different greetings on different platforms. Create the following directory structure:
|
||||
|
||||
application/
|
||||
├── androidApp/
|
||||
├── iosApp/
|
||||
└── greeting/
|
||||
├── common/
|
||||
├── android/
|
||||
└── ios/
|
||||
|
||||
As said above, [Gradle](https://gradle.org/) is the main build system for Kotlin so our project will use it.
|
||||
|
||||
To install Gradle refer to [these instructions](https://gradle.org/install/). Despite being able to use the local
|
||||
Gradle installation for building a project, it's recommended to use the
|
||||
[Gradle wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html) instead. To create the wrapper, install
|
||||
Gradle as described above, and execute `gradle wrapper` in the root directory of the project. After that you can
|
||||
use `./gradlew` to run the build instead of using your local Gradle installation.
|
||||
|
||||
Once the wrapper is created we need to describe the project structure in Gradle terms. To do this, create
|
||||
a `settings.gradle` file in the root directory of the project and put the following snippet into it:
|
||||
|
||||
<div class="sample" markdown="1" theme="idea" mode="groovy">
|
||||
|
||||
```groovy
|
||||
include ':greeting'
|
||||
include ':greeting:common'
|
||||
include ':greeting:android'
|
||||
include ':greeting:ios'
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
Here we declare all subprojects for our `greeting` multiplatform library. All other multiplatform libraries included
|
||||
in the project also must be declared here.
|
||||
|
||||
Note that both iOS and Android applications are not included in the root Gradle build. They are represented by
|
||||
independent builds which are managed by specific IDEs (Android Studio and Xcode). Such an approach makes working with
|
||||
these builds easier from the IDEs.
|
||||
|
||||
As for an IDE for other parts of the project, [IntelliJ IDEA](https://www.jetbrains.com/idea/) is recommended.
|
||||
|
||||
> Note: Kotlin/Native is not supported by IntelliJ IDEA so the only IDE to develop Kotlin/Native sub-projects is
|
||||
[CLion](https://www.jetbrains.com/clion/). But at the moment CLion has no Gradle integration. As a workaround you can
|
||||
create a CLion Cmake project from a Kotlin/Native Gradle one. Just run `./gradlew generateCMake` for this project. It
|
||||
will generate all the necessary files which are required. See
|
||||
[this](https://blog.jetbrains.com/kotlin/2017/11/kotlinnative-ide-support-preview/) blog post to learn more about
|
||||
Kotlin/Native support in CLion.
|
||||
|
||||
For the final step create the empty `build.gradle` files in the root directory of the project and in all subprojects which are
|
||||
included in `settings.gradle`. After performing all these actions the project structure will be the following (files
|
||||
generated by the Gradle wrapper are not shown):
|
||||
|
||||
application/
|
||||
├── androidApp/
|
||||
├── iosApp/
|
||||
├── greeting/
|
||||
│ ├── android/
|
||||
│ │ └── build.gradle
|
||||
│ ├── common/
|
||||
│ │ └── build.gradle
|
||||
│ ├── ios/
|
||||
│ | └── build.gradle
|
||||
| └── build.gradle
|
||||
├── build.gradle
|
||||
└── settings.gradle
|
||||
|
||||
Now we have the basic structure of the project and can proceed to implement the multiplatform library.
|
||||
|
||||
### 2. Multiplatform library
|
||||
|
||||
We need to add buildscript dependencies to be able to use the Kotlin plugins for Gradle in our build. Open
|
||||
the `build.gradle` in the `greeting` directory and put the following snippet into it:
|
||||
|
||||
<div class="sample" markdown="1" theme="idea" mode="groovy">
|
||||
|
||||
```groovy
|
||||
// Set up a buildscript dependency on the Kotlin plugin.
|
||||
buildscript {
|
||||
// Specify a Kotlin version you need.
|
||||
ext.kotlin_version = '1.2.41'
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
|
||||
}
|
||||
|
||||
// Specify all the plugins used as dependencies
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.7"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Set up compilation dependency repositories for all projects.
|
||||
subprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
Now all subprojects of the library can use Kotlin plugins.
|
||||
|
||||
#### 2.1 Common subproject
|
||||
|
||||
The `common` subproject contains platform-independent code. To build it, add the following snippet in `common/build.gradle`:
|
||||
|
||||
<div class="sample" markdown="1" theme="idea" mode="groovy">
|
||||
|
||||
```groovy
|
||||
apply plugin: 'kotlin-platform-common'
|
||||
|
||||
// Specify a group and a version of the library to access it in Android Studio.
|
||||
// By default the project directory name is used as an artifact name thus the full dependency
|
||||
// description will be 'org.greeting:common:1.0'
|
||||
group = 'org.greeting'
|
||||
version = 1.0
|
||||
|
||||
dependencies {
|
||||
// Set up a compilation dependency on common Kotlin stdlib
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
Now we can write some logic available for all platforms. Create `common/src/main/kotlin/common.kt` and add some
|
||||
functionality into it:
|
||||
|
||||
<div class="sample" markdown="1" theme="idea" data-highlight-only>
|
||||
|
||||
```kotlin
|
||||
// greeting/common/src/main/kotlin/common.kt
|
||||
package org.greeting
|
||||
|
||||
expect class Platform() {
|
||||
val platform: String
|
||||
}
|
||||
|
||||
class Greeting {
|
||||
fun greeting(): String = "Hello, ${Platform().platform}"
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
Here we create a simple class using the `expect`/`actual` paradigm. Find details about platform-specific declarations
|
||||
[here](https://kotlinlang.org/docs/reference/multiplatform.html#platform-specific-declarations).
|
||||
|
||||
#### 2.2 Android subproject
|
||||
|
||||
The `android` subproject contains platform-dependent implementations of the `expect`-declarations we've created in the
|
||||
`common` project. We compile it into a Java library which an Android Studio project can depend on. The content
|
||||
of the `android/build.gradle` will be the following:
|
||||
|
||||
<div class="sample" markdown="1" theme="idea" mode="groovy">
|
||||
|
||||
```groovy
|
||||
apply plugin: 'kotlin-platform-jvm'
|
||||
|
||||
// Specify a group and a version of the library to access it in Android Studio.
|
||||
// By default the project directory name is used as an artifact name thus the full dependency
|
||||
// description will be 'org.greeting:android:1.0'
|
||||
group = 'org.greeting'
|
||||
version = 1.0
|
||||
|
||||
dependencies {
|
||||
// Specify Kotlin/JVM stdlib dependency.
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
|
||||
|
||||
// Specify dependency on a common project for Kotlin multiplatform build.
|
||||
expectedBy project(':greeting:common')
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
As mentioned above this subproject should include actual implementations of the common project's `expect`-declarations.
|
||||
Let's write an Android-specific method:
|
||||
|
||||
<div class="sample" markdown="1" theme="idea" data-highlight-only>
|
||||
|
||||
```kotlin
|
||||
// greeting/android/src/main/kotlin/android.kt
|
||||
package org.greeting
|
||||
|
||||
actual class Platform actual constructor() {
|
||||
actual val platform: String = "Android"
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
#### 2.3 iOS subproject
|
||||
|
||||
This project is compiled into an Objective-C framework using the Kotlin/Native compiler. To do this, declare a framework in
|
||||
`ios/build.gradle` and add an `expectedBy` dependency in the same manner as was done in the Android project:
|
||||
|
||||
<div class="sample" markdown="1" theme="idea" mode="groovy">
|
||||
|
||||
```groovy
|
||||
apply plugin: 'konan'
|
||||
|
||||
// Specify targets to build the framework: iOS and iOS simulator
|
||||
konan.targets = ['ios_arm64', 'ios_x64']
|
||||
|
||||
konanArtifacts {
|
||||
// Declare building into a framework.
|
||||
framework('Greeting') {
|
||||
// The multiplatform support is disabled by default.
|
||||
enableMultiplatform true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Specify dependency on a common project for Kotlin multiplatform build
|
||||
expectedBy project(':greeting:common')
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
As well as `android`, this project contains platform-dependent implementations of `expect`-declarations:
|
||||
|
||||
<div class="sample" markdown="1" theme="idea" data-highlight-only>
|
||||
|
||||
```kotlin
|
||||
// greeting/ios/src/main/kotlin/ios.kt
|
||||
package org.greeting
|
||||
|
||||
actual class Platform actual constructor() {
|
||||
actual val platform: String = "iOS"
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### 3. Android application
|
||||
|
||||
Now we can create an Android application which will use the library we implemented in the previous step. Open Android
|
||||
Studio and create a new project in the `androidApp` directory. Android Studio will generate all the necessary files and
|
||||
directories.
|
||||
|
||||
Kotlin/Native requires Gradle 4.7 or higher so you need to make sure that the AS project uses the correct
|
||||
Gradle version. To do this, open `androidApp/gradle/gradle-wrapper.properties` and check the `distributionUrl`
|
||||
property. Upgrade the wrapper if necessary
|
||||
(see [Gradle documentation](https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:upgrading_wrapper)).
|
||||
|
||||
Now we only need to add a dependency on our library. There are 2 actions we need to take:
|
||||
|
||||
1. Add dependency on the library. To do this just open `androidApp/app/build.gradle` and add the following snippet in
|
||||
the `dependencies` script block:
|
||||
|
||||
```
|
||||
implementation 'org.greeting:android:1.0'
|
||||
```
|
||||
2. Include `greeting` build in the Android Studio project as a part of
|
||||
[composite build](https://docs.gradle.org/current/userguide/composite_builds.html). To do this, add the
|
||||
following line in `androidApp/settings.gradle`:
|
||||
|
||||
```
|
||||
includeBuild '../'
|
||||
```
|
||||
Now dependencies of the application can be resolved in artifacts built by `greeting`. You also may publish the
|
||||
Android part of `greeting` into some Maven repo and get it from there. In this case you don't need to set up
|
||||
the composite build.
|
||||
|
||||
> Note: Android Studio may fail to resolve declarations from the library added unless it's built. If you face such a
|
||||
> problem, build the library by executing `./gradlew greeting:android:jar` in the root directory of the project.
|
||||
|
||||
> Alternatively you can add the multiplatform library subprojects right into the Android Studio one instead of
|
||||
> creating a composite build. To do this you need to declare them along with their directories in
|
||||
> `androidApp/settings.gradle`:
|
||||
>
|
||||
><div class="sample" markdown="1" theme="idea" mode="groovy">
|
||||
>
|
||||
>```groovy
|
||||
>include ':greeting'
|
||||
>include ':greeting:common'
|
||||
>include ':greeting:android'
|
||||
>
|
||||
>project(':greeting').projectDir = file('../greeting')
|
||||
>project(':greeting:common').projectDir = file('../greeting/common')
|
||||
>project(':greeting:android').projectDir = file('../greeting/android')
|
||||
>```
|
||||
>
|
||||
></div>
|
||||
>
|
||||
> Now you can declare dependencies directly on projects instead of using maven-like coordinates:
|
||||
>
|
||||
><div class="sample" markdown="1" theme="idea" mode="groovy">
|
||||
>
|
||||
>```groovy
|
||||
>implementation project(':greeting:android')
|
||||
>```
|
||||
>
|
||||
></div>
|
||||
|
||||
After these steps we can access our library as we would with any other Kotlin code:
|
||||
|
||||
<div class="sample" markdown="1" theme="idea" data-highlight-only>
|
||||
|
||||
```kotlin
|
||||
import org.greeting.*
|
||||
|
||||
/* ... */
|
||||
|
||||
fun foo() {
|
||||
println(Greeting().greeting())
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### 4. iOS application
|
||||
|
||||
As already mentioned above the multiplatform library can also be used in iOS applications. The general approach here is the same as
|
||||
in the case of the Android application: we create a separate Xcode project and add the library as a framework. But we need
|
||||
to make some additional steps here.
|
||||
|
||||
Unlike Android Studio Xcode doesn't use Gradle, so we cannot just add the library as a dependency. Instead we need to
|
||||
create a new framework in the Xcode project and then replace its default build phases with a custom one which delegates
|
||||
building the framework to Gradle.
|
||||
|
||||
To do this, perform the following steps:
|
||||
|
||||
1. Create a new Xcode project in the root directory of your project (the `application` directory in the
|
||||
[section 1](#1-preparing-a-workspace)). Name it `iosApp` so Xcode will create the project in the directory we created
|
||||
in the section 1.
|
||||
2. Add a new framework in the project. Go to `File` -> `New` -> `Target` -> `Cocoa Touch Framework`. Specify the same
|
||||
framework name as is in `greeting/ios/build.gradle`: `Greeting`.
|
||||
3. Choose the new framework in the `Project Navigator` and open the `Build Settings` tab. Here we need to add a new build
|
||||
setting specifying what Gradle task will be executed to build the framework for one or another platform. Fortunately,
|
||||
Xcode allows us to set different values for the same build setting depending on the platform. Create a new build
|
||||
setting in the `User-defined` section and name it `KONAN_TASK`. Then specify the following values for it for different
|
||||
platforms (for both `Debug` and `Release` modes):
|
||||
|
||||
|Platform |Value |
|
||||
|-----------------------|---------------------------------------|
|
||||
|`Any iOS simulator SDK`|`compileKonan<framework name>Ios_x64` |
|
||||
|`Any iOS SDK` |`compileKonan<framework name>Ios_arm64`|
|
||||
|
||||
Replace `<framework name>` with the name you specified in the library's `ios/build.gradle`. Use camel case, e.g.
|
||||
for our `greeting` library these tasks will be named `compileKonanGreetingIos_x64` and
|
||||
`compileKonanGreetingIos_arm64`.
|
||||
4. Add one more build setting for the framework to manage optimizations performed by the Kotlin/Native compiler. Name
|
||||
it `KONAN_ENABLE_OPTIMIZATIONS ` and set its value to `YES` for the `Release` mode and to `NO` for the `Debug` mode.
|
||||
5. Ensure that the framework is still selected in the `Project Navigator` and open the `Build phases` tab. Remove all
|
||||
the default phases except `Target Dependencies`.
|
||||
6. Add a new `Run Script` build phase and put the following code into the script field:
|
||||
|
||||
```
|
||||
"$SRCROOT/../gradlew" -p "$SRCROOT/../greeting/ios" "$KONAN_TASK" \
|
||||
-Pkonan.configuration.build.dir="$CONFIGURATION_BUILD_DIR" \
|
||||
-Pkonan.debugging.symbols="$DEBUGGING_SYMBOLS" \
|
||||
-Pkonan.optimizations.enable="$KONAN_ENABLE_OPTIMIZATIONS"
|
||||
```
|
||||
|
||||
This script executes the Gradle build to compile the multiplatform library into a framework. Let's examine this
|
||||
command in more detail.
|
||||
* `"$SRCROOT/../gradlew"` - here we invoke the Gradle wrapper located in the root directory of the project. If you
|
||||
use a local Gradle installation you need to invoke it instead of the wrapper.
|
||||
* `-p "$SRCROOT/../greeting/ios"` - specify a path to the Gradle subproject containing the framework.
|
||||
* `"$KONAN_TASK"` - specify a Gradle task to execute. The build setting created above is used here.
|
||||
* `-Pkonan.configuration.build.dir="$CONFIGURATION_BUILD_DIR"` - specify a directory provided by Xcode as an output one.
|
||||
* `-Pkonan.debugging.symbols="$DEBUGGING_SYMBOLS"` - allow Xcode to enable debugging symbols generation.
|
||||
* `-Pkonan.optimizations.enable="$KONAN_ENABLE_OPTIMIZATIONS"` - disable/enable optimizations. The build setting
|
||||
created above is used here.
|
||||
|
||||
7. Add Kotlin sources into the framework: run `File` -> `Add files to "iosApp"...` and choose a directory with
|
||||
Kotlin sources (`greeting/ios/src` in this sample). Choose the framework created as a target to add these sources to.
|
||||
Do this for the common code of the library too.
|
||||
|
||||
Now the framework is added and all the Kotlin API are available from Swift code (note that you need to build the
|
||||
framework in order to get code completion). Let's print our greeting:
|
||||
|
||||
<div class="sample" markdown="1" theme="idea" mode="swift">
|
||||
|
||||
```swift
|
||||
import Greeting
|
||||
|
||||
/* ... */
|
||||
|
||||
func foo() {
|
||||
print(GreetingGreeting().greeting())
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
### Sample
|
||||
|
||||
A sample implementation which follows this documentation can be found [here](https://github.com/JetBrains/kotlin-mpp-example).
|
||||
You may also look at the [calculator sample](https://github.com/JetBrains/kotlin-native/tree/master/samples/calculator). It has a simpler structure (particularly both Android app
|
||||
and Kotlin/Native library are combined in a single Gradle build) but also uses the multiplatform support provided by Kotlin.
|
||||
@@ -14,10 +14,6 @@
|
||||
url: platform_libs.html
|
||||
title: "Platform Libraries"
|
||||
|
||||
- md: MULTIPLATFORM.md
|
||||
url: multiplatform.html
|
||||
title: "Multiplatform Projects"
|
||||
|
||||
- md: INTEROP.md
|
||||
url: c_interop.html
|
||||
title: "C Interop"
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ task gradlePluginJar {
|
||||
dependsOn gradle.includedBuild('kotlin-native-gradle-plugin').task(':shadowJar')
|
||||
}
|
||||
|
||||
task gradlePluginCheck() {
|
||||
task gradlePluginCheck {
|
||||
dependsOn gradle.includedBuild('kotlin-native-gradle-plugin').task(':check')
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
|
||||
import org.jetbrains.kotlin.konan.KonanVersion
|
||||
import org.jetbrains.kotlin.konan.MetaVersion
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
/**
|
||||
* One may use bintrayUser/bintrayKey project properties or BINTRAY_USER/BINTRAY_KEY environment variables to upload
|
||||
@@ -37,7 +39,7 @@ buildscript {
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
|
||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
|
||||
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
|
||||
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.0'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,13 +55,21 @@ apply plugin: 'com.jfrog.bintray'
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
|
||||
group = 'org.jetbrains.kotlin'
|
||||
version = KonanVersion.Companion.CURRENT.toString()
|
||||
|
||||
if (KonanVersion.Companion.CURRENT.meta == MetaVersion.RELEASE) {
|
||||
version = kotlinVersion
|
||||
} else {
|
||||
version = "$kotlinVersion-native-${KonanVersion.Companion.CURRENT.toString()}"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url buildKotlinCompilerRepo
|
||||
}
|
||||
maven {
|
||||
url kotlinCompilerRepo
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
@@ -74,33 +84,53 @@ configurations {
|
||||
|
||||
dependencies {
|
||||
shadow "org.jetbrains.kotlin:kotlin-stdlib:0.9.1-native"
|
||||
shadow "org.jetbrains.kotlin:kotlin-gradle-plugin:0.9.1-native"
|
||||
|
||||
// Bundle the serialization plugin into the final jar because we shade classes of the kotlin plugin
|
||||
// while the serialization one extends them.
|
||||
bundleDependencies "org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion"
|
||||
bundleDependencies "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
|
||||
bundleDependencies "org.jetbrains.kotlin:kotlin-gradle-plugin-api:$kotlinVersion"
|
||||
bundleDependencies "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test:1.3.0-rc-116"
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:1.3.0-rc-116"
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test:$buildKotlinVersion"
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$buildKotlinVersion"
|
||||
testImplementation "org.tools4j:tools4j-spockito:1.6"
|
||||
testImplementation('org.spockframework:spock-core:1.1-groovy-2.4') {
|
||||
exclude module: 'groovy-all'
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
appendix = "no-shared"
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
task jar(type: ShadowJar, overwrite: true) {
|
||||
from sourceSets.main.output
|
||||
configurations = [project.configurations.bundleDependencies]
|
||||
classifier = null
|
||||
relocate('org.jetbrains.kotlinx', 'shadow.org.jetbrains.kotlinx')
|
||||
relocate('org.jetbrains.kotlin.compilerRunner', 'shadow.org.jetbrains.kotlin.compilerRunner')
|
||||
relocate('org.jetbrains.kotlin.gradle', 'shadow.org.jetbrains.kotlin.gradle') {
|
||||
exclude('org.jetbrains.kotlin.gradle.plugin.experimental.**')
|
||||
exclude('org.jetbrains.kotlin.gradle.plugin.konan.**')
|
||||
exclude('org.jetbrains.kotlin.gradle.plugin.model.**')
|
||||
}
|
||||
|
||||
exclude {
|
||||
def path = it.relativePath.pathString
|
||||
if (path.startsWith("META-INF/gradle-plugins") && path.endsWith(".properties")) {
|
||||
def fileName = it.name
|
||||
def id = fileName.take(fileName.lastIndexOf('.'))
|
||||
return project.gradlePlugin.plugins.findByName(id) == null
|
||||
}
|
||||
return false
|
||||
}
|
||||
exclude('META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar')
|
||||
exclude('META-INF/services/org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin')
|
||||
}
|
||||
|
||||
assemble.dependsOn shadowJar
|
||||
|
||||
pluginUnderTestMetadata {
|
||||
dependsOn shadowJar
|
||||
pluginClasspath = files(shadowJar.archivePath) + configurations.shadow
|
||||
dependsOn jar
|
||||
pluginClasspath = files(jar.archivePath) + configurations.shadow
|
||||
}
|
||||
|
||||
test {
|
||||
@@ -164,7 +194,7 @@ gradlePlugin {
|
||||
plugins {
|
||||
create('konan') {
|
||||
id = 'konan'
|
||||
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.KonanPlugin'
|
||||
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin'
|
||||
}
|
||||
create('kotlin-native') {
|
||||
id = 'kotlin-native'
|
||||
@@ -174,10 +204,15 @@ gradlePlugin {
|
||||
id = 'kotlin-platform-native'
|
||||
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.experimental.plugins.KotlinPlatformNativePlugin'
|
||||
}
|
||||
// We bundle a shaded version of kotlinx-serialization plugin
|
||||
create('kotlinx-serialization-native') {
|
||||
id = 'kotlinx-serialization-native'
|
||||
implementationClass = 'shadow.org.jetbrains.kotlinx.serialization.gradle.SerializationGradleSubplugin'
|
||||
}
|
||||
|
||||
create('org.jetbrains.kotlin.konan') {
|
||||
id = 'org.jetbrains.kotlin.konan'
|
||||
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.KonanPlugin'
|
||||
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin'
|
||||
}
|
||||
create('org.jetbrains.kotlin.native') {
|
||||
id = 'org.jetbrains.kotlin.native'
|
||||
|
||||
-1
@@ -38,7 +38,6 @@ import org.jetbrains.kotlin.gradle.plugin.experimental.TargetSettings
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.sourcesets.KotlinNativeSourceSetImpl
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.assertedCast
|
||||
import javax.inject.Inject
|
||||
|
||||
class TargetSettingsImpl(val konanTarget: KonanTarget) : Named, TargetSettings {
|
||||
|
||||
-1
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.gradle.plugin.experimental.CInteropSettings
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.CInteropSettings.IncludeDirectories
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeBinary
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.internal.KotlinNativeBuildType
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.internal.KotlinNativeUsage
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.internal.getGradleOSFamily
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import java.io.File
|
||||
|
||||
+10
-3
@@ -20,7 +20,6 @@ import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.attributes.AttributeCompatibilityRule
|
||||
import org.gradle.api.attributes.Usage
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.internal.FeaturePreviews
|
||||
@@ -35,12 +34,20 @@ import org.gradle.language.plugins.NativeBasePlugin
|
||||
import org.gradle.nativeplatform.test.tasks.RunTestExecutable
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.PLUGIN_CLASSPATH_CONFIGURATION_NAME
|
||||
import org.jetbrains.kotlin.gradle.plugin.SubpluginEnvironment
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.CInteropSettings
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeComponent
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeLibrary
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.KotlinNativeTestComponent
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.internal.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.tasks.CInteropTask
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.tasks.KotlinNativeCompile
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.hasProperty
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.konanCompilerDownloadDir
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.setProperty
|
||||
import org.jetbrains.kotlin.gradle.plugin.loadKotlinVersionFromResource
|
||||
import org.jetbrains.kotlin.gradle.plugin.tasks.KonanCompilerDownloadTask
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
|
||||
+3
-3
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin.experimental.plugins
|
||||
|
||||
import org.gradle.api.Named
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.SourceSet
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformImplementationPluginBase
|
||||
|
||||
class KotlinPlatformNativePlugin : KotlinPlatformImplementationPluginBase("native") {
|
||||
@@ -29,9 +29,9 @@ class KotlinPlatformNativePlugin : KotlinPlatformImplementationPluginBase("nativ
|
||||
super.apply(project)
|
||||
}
|
||||
|
||||
override fun addCommonSourceSetToPlatformSourceSet(commonSourceSet: SourceSet, platformProject: Project) {
|
||||
override fun addCommonSourceSetToPlatformSourceSet(commonSourceSet: Named, platformProject: Project) {
|
||||
val platformSourceSet = platformProject.kotlinNativeSourceSets.findByName(commonSourceSet.name)
|
||||
val commonSources = commonSourceSet.kotlin
|
||||
val commonSources = getKotlinSourceDirectorySetSafe(commonSourceSet)
|
||||
if (platformSourceSet != null && commonSources != null) {
|
||||
platformSourceSet.commonSources.from(commonSources)
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -20,8 +20,8 @@ import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.tasks.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.internal.cinterop.CInteropSettingsImpl
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.*
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import java.io.File
|
||||
|
||||
+1
-1
@@ -26,8 +26,8 @@ import org.gradle.api.tasks.InputFiles
|
||||
import org.gradle.api.tasks.Optional
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.internal.AbstractKotlinNativeBinary
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.*
|
||||
import org.jetbrains.kotlin.gradle.tasks.CompilerPluginOptions
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind.*
|
||||
|
||||
+2
-2
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
package org.jetbrains.kotlin.gradle.plugin.konan
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.plugin.KonanPlugin.ProjectProperty
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin.ProjectProperty
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
package org.jetbrains.kotlin.gradle.plugin.konan
|
||||
|
||||
import groovy.lang.Closure
|
||||
import org.gradle.api.Action
|
||||
+2
-3
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
package org.jetbrains.kotlin.gradle.plugin.konan
|
||||
|
||||
import groovy.lang.Closure
|
||||
import org.gradle.api.Action
|
||||
@@ -28,7 +28,6 @@ import org.gradle.api.publish.maven.MavenPom
|
||||
import org.gradle.internal.reflect.Instantiator
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.gradle.plugin.tasks.KonanBuildingTask
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import java.io.File
|
||||
|
||||
@@ -109,7 +108,7 @@ abstract class KonanBuildingConfig<T: KonanBuildingTask>(private val name_: Stri
|
||||
protected fun determineOutputPlacement(target: KonanTarget): OutputPlacement {
|
||||
val configurationBuildDir = project.environmentVariables.configurationBuildDir
|
||||
return if (configurationBuildDir != null) {
|
||||
OutputPlacement(configurationBuildDir, name)
|
||||
OutputPlacement(configurationBuildDir, name)
|
||||
} else {
|
||||
OutputPlacement(defaultBaseDir.targetSubdir(target), name)
|
||||
}
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
package org.jetbrains.kotlin.gradle.plugin.konan
|
||||
|
||||
import groovy.lang.Closure
|
||||
import org.gradle.api.Task
|
||||
@@ -24,7 +24,7 @@ import org.gradle.internal.reflect.Instantiator
|
||||
import org.jetbrains.kotlin.gradle.plugin.tasks.*
|
||||
import org.jetbrains.kotlin.konan.target.Family
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget.WASM32
|
||||
import java.io.File
|
||||
|
||||
abstract class KonanCompileConfig<T: KonanCompileTask>(name: String,
|
||||
+2
-3
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
package org.jetbrains.kotlin.gradle.plugin.konan
|
||||
|
||||
import groovy.lang.Closure
|
||||
import org.gradle.api.Action
|
||||
@@ -23,9 +23,8 @@ import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.internal.project.ProjectInternal
|
||||
import org.gradle.internal.reflect.Instantiator
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.gradle.plugin.KonanInteropSpec.IncludeDirectoriesSpec
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanInteropSpec.IncludeDirectoriesSpec
|
||||
import org.jetbrains.kotlin.gradle.plugin.tasks.KonanInteropTask
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import java.io.File
|
||||
|
||||
open class KonanInteropLibrary(name: String,
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
package org.jetbrains.kotlin.gradle.plugin.konan
|
||||
|
||||
import org.gradle.api.InvalidUserDataException
|
||||
import org.gradle.api.Project
|
||||
+3
-3
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
package org.jetbrains.kotlin.gradle.plugin.konan
|
||||
|
||||
import org.gradle.api.*
|
||||
import org.gradle.api.component.ComponentWithVariants
|
||||
@@ -31,7 +31,7 @@ import org.gradle.api.publish.maven.internal.publication.MavenPublicationInterna
|
||||
import org.gradle.language.cpp.internal.NativeVariantIdentity
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.KonanPlugin.Companion.COMPILE_ALL_TASK_NAME
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin.Companion.COMPILE_ALL_TASK_NAME
|
||||
import org.jetbrains.kotlin.gradle.plugin.model.KonanToolingModelBuilder
|
||||
import org.jetbrains.kotlin.gradle.plugin.tasks.*
|
||||
import org.jetbrains.kotlin.konan.KonanVersion
|
||||
@@ -297,7 +297,7 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
||||
private fun checkGradleVersion() = GradleVersion.current().let { current ->
|
||||
check(current >= REQUIRED_GRADLE_VERSION) {
|
||||
"Kotlin/Native Gradle plugin is incompatible with this version of Gradle.\n" +
|
||||
"The minimal required version is ${REQUIRED_GRADLE_VERSION}\n" +
|
||||
"The minimal required version is $REQUIRED_GRADLE_VERSION\n" +
|
||||
"Current version is ${current}"
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -14,11 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
package org.jetbrains.kotlin.gradle.plugin.konan
|
||||
|
||||
import groovy.lang.Closure
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.FileCollection
|
||||
|
||||
interface KonanArtifactSpec {
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
package org.jetbrains.kotlin.gradle.plugin.konan
|
||||
|
||||
import org.gradle.api.Named
|
||||
import org.gradle.api.Project
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
package org.jetbrains.kotlin.gradle.plugin.konan
|
||||
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Named
|
||||
import org.gradle.api.NamedDomainObjectContainer
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformImplementationPluginBase
|
||||
import org.jetbrains.kotlin.gradle.plugin.tasks.KonanCompileTask
|
||||
import javax.inject.Inject
|
||||
|
||||
+2
-4
@@ -34,12 +34,10 @@ import org.gradle.api.tasks.*
|
||||
import org.gradle.language.cpp.CppBinary
|
||||
import org.gradle.language.cpp.internal.DefaultUsageContext
|
||||
import org.gradle.language.cpp.internal.NativeVariantIdentity
|
||||
import org.gradle.language.nativeplatform.internal.Names
|
||||
import org.gradle.nativeplatform.Linkage
|
||||
import org.gradle.nativeplatform.OperatingSystemFamily
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.konan.target.Family
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.*
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import java.io.File
|
||||
@@ -90,7 +88,7 @@ abstract class KonanArtifactTask: KonanTargetableTask(), KonanArtifactSpec {
|
||||
protected abstract val artifactPrefix: String
|
||||
@Internal get
|
||||
|
||||
internal open fun init(config:KonanBuildingConfig<*>, destinationDir: File, artifactName: String, target: KonanTarget) {
|
||||
internal open fun init(config: KonanBuildingConfig<*>, destinationDir: File, artifactName: String, target: KonanTarget) {
|
||||
super.init(target)
|
||||
this.destinationDir = destinationDir
|
||||
this.artifactName = artifactName
|
||||
+4
-2
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.gradle.plugin.tasks
|
||||
import org.gradle.api.tasks.Console
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.model.KonanModelArtifact
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import java.io.File
|
||||
@@ -49,7 +49,9 @@ abstract class KonanBuildingTask: KonanArtifactWithLibrariesTask(), KonanBuildin
|
||||
@TaskAction
|
||||
open fun run() {
|
||||
destinationDir.mkdirs()
|
||||
if (dumpParameters) { dumpProperties(this) }
|
||||
if (dumpParameters) {
|
||||
dumpProperties(this)
|
||||
}
|
||||
toolRunner.run(buildArgs())
|
||||
}
|
||||
|
||||
+4
-3
@@ -22,13 +22,13 @@ import org.gradle.api.file.ConfigurableFileTree
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.process.CommandLineArgumentProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.model.KonanModelArtifact
|
||||
import org.jetbrains.kotlin.gradle.plugin.model.KonanModelArtifactImpl
|
||||
import org.jetbrains.kotlin.konan.library.defaultResolver
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.Distribution
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,8 @@ import java.io.File
|
||||
*/
|
||||
abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
||||
|
||||
@Internal override val toolRunner = KonanCompilerRunner(project, project.konanExtension.jvmArgs)
|
||||
@Internal override val toolRunner =
|
||||
KonanCompilerRunner(project, project.konanExtension.jvmArgs)
|
||||
|
||||
abstract val produce: CompilerOutputKind
|
||||
@Internal get
|
||||
+1
-3
@@ -20,13 +20,11 @@ import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.GradleScriptException
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.*
|
||||
import org.jetbrains.kotlin.konan.KonanVersion
|
||||
import org.jetbrains.kotlin.konan.MetaVersion
|
||||
import org.jetbrains.kotlin.konan.util.DependencyProcessor
|
||||
import org.jetbrains.kotlin.konan.util.DependencySource
|
||||
import org.jetbrains.kotlin.konan.util.visibleName
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
open class KonanCompilerDownloadTask : DefaultTask() {
|
||||
+8
-8
@@ -19,10 +19,10 @@ package org.jetbrains.kotlin.gradle.plugin.tasks
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.jetbrains.kotlin.gradle.plugin.KonanInteropLibrary
|
||||
import org.jetbrains.kotlin.gradle.plugin.KonanLibrary
|
||||
import org.jetbrains.kotlin.gradle.plugin.KonanProgram
|
||||
import org.jetbrains.kotlin.gradle.plugin.konanArtifactsContainer
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanInteropLibrary
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanLibrary
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanProgram
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.konanArtifactsContainer
|
||||
import org.jetbrains.kotlin.konan.target.Family
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import java.io.File
|
||||
@@ -51,10 +51,10 @@ open class KonanGenerateCMakeTask : DefaultTask() {
|
||||
private val host = HostManager.host
|
||||
|
||||
private fun generateCMakeLists(
|
||||
projectName: String,
|
||||
interops: List<KonanInteropLibrary>,
|
||||
libraries: List<KonanLibrary>,
|
||||
programs: List<KonanProgram>
|
||||
projectName: String,
|
||||
interops: List<KonanInteropLibrary>,
|
||||
libraries: List<KonanLibrary>,
|
||||
programs: List<KonanProgram>
|
||||
): String {
|
||||
val cMakeCurrentListDir = "$" + "{CMAKE_CURRENT_LIST_DIR}"
|
||||
|
||||
+7
-6
@@ -18,15 +18,13 @@ package org.jetbrains.kotlin.gradle.plugin.tasks
|
||||
|
||||
import groovy.lang.Closure
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.invocation.Gradle
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.gradle.workers.IsolationMode
|
||||
import org.gradle.workers.WorkerExecutor
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.KonanInteropSpec.IncludeDirectoriesSpec
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanInteropSpec.IncludeDirectoriesSpec
|
||||
import org.jetbrains.kotlin.gradle.plugin.model.KonanModelArtifact
|
||||
import org.jetbrains.kotlin.gradle.plugin.model.KonanModelArtifactImpl
|
||||
import org.jetbrains.kotlin.konan.library.defaultResolver
|
||||
@@ -43,7 +41,8 @@ import javax.inject.Inject
|
||||
|
||||
open class KonanInteropTask @Inject constructor(val workerExecutor: WorkerExecutor) : KonanBuildingTask(), KonanInteropSpec {
|
||||
|
||||
@Internal override val toolRunner: KonanToolRunner = KonanInteropRunner(project, project.konanExtension.jvmArgs)
|
||||
@Internal override val toolRunner: KonanToolRunner =
|
||||
KonanInteropRunner(project, project.konanExtension.jvmArgs)
|
||||
|
||||
override fun init(config: KonanBuildingConfig<*>, destinationDir: File, artifactName: String, target: KonanTarget) {
|
||||
super.init(config, destinationDir, artifactName, target)
|
||||
@@ -203,7 +202,9 @@ open class KonanInteropTask @Inject constructor(val workerExecutor: WorkerExecut
|
||||
|
||||
override fun run() {
|
||||
destinationDir.mkdirs()
|
||||
if (dumpParameters) { dumpProperties(this) }
|
||||
if (dumpParameters) {
|
||||
dumpProperties(this)
|
||||
}
|
||||
val args = buildArgs()
|
||||
if (enableParallel) {
|
||||
interchangeBox[this.path] = toolRunner
|
||||
+3
-4
@@ -19,13 +19,12 @@ package org.jetbrains.kotlin.gradle.plugin.model
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilder
|
||||
import org.jetbrains.kotlin.gradle.plugin.experimental.internal.AbstractKotlinNativeBinary
|
||||
import org.jetbrains.kotlin.gradle.plugin.konanArtifactsContainer
|
||||
import org.jetbrains.kotlin.gradle.plugin.konanExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.konanHome
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.konanArtifactsContainer
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.konanExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.konanHome
|
||||
import org.jetbrains.kotlin.konan.KonanVersion
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import java.io.File
|
||||
import java.lang.IllegalStateException
|
||||
|
||||
|
||||
object KonanToolingModelBuilder : ToolingModelBuilder {
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# Copyright 2010-2017 JetBrains s.r.o.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
shadow.org.jetbrains.kotlinx.serialization.gradle.SerializationKotlinGradleSubplugin
|
||||
@@ -19,8 +19,8 @@ package org.jetbrains.kotlin.gradle.plugin.test
|
||||
import org.gradle.api.internal.FeaturePreviews
|
||||
import org.gradle.api.internal.project.ProjectInternal
|
||||
import org.gradle.testfixtures.ProjectBuilder
|
||||
import org.jetbrains.kotlin.gradle.plugin.KonanPlugin
|
||||
import org.jetbrains.kotlin.gradle.plugin.konanArtifactsContainer
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.konanArtifactsContainer
|
||||
import org.jetbrains.kotlin.gradle.plugin.model.KonanToolingModelBuilder
|
||||
import org.jetbrains.kotlin.konan.KonanVersion
|
||||
import org.junit.Rule
|
||||
|
||||
Reference in New Issue
Block a user