IntelliJ Kotlin多平台项目Gradle sync非常长
我为IntelliJ Kotlin多平台项目Gradle sync非常长,gradle,intellij-idea,kotlin,kotlin-multiplatform,Gradle,Intellij Idea,Kotlin,Kotlin Multiplatform,我为Andrid和iOS(移动共享库)创建了一个新的Kotlin多平台项目。该项目工作正常,但每次我运行Gradlesync时,每次都需要5分钟以上。它总是卡在同一行上: Gradle:为根项目“MyProject”构建模型“org.jetbrains.kotlin.Gradle.KotlinMPPGradleModel” 为什么每次都要花这么长时间 我使用的是Gradle5.1版。 这是我的build.gradle文件: buildscript { ext.kotlin_version
Andrid
和iOS
(移动共享库)创建了一个新的Kotlin多平台
项目。该项目工作正常,但每次我运行Gradle
sync时,每次都需要5分钟以上。它总是卡在同一行上:
Gradle:为根项目“MyProject”构建模型“org.jetbrains.kotlin.Gradle.KotlinMPPGradleModel”
为什么每次都要花这么长时间
我使用的是Gradle
5.1版。
这是我的build.gradle
文件:
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1"
}
}
plugins {
id 'kotlin-multiplatform' version '1.3.11'
}
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
repositories {
mavenCentral()
}
group 'com.example'
version '0.0.1'
apply plugin: "com.android.library"
apply plugin: "com.jfrog.artifactory"
apply plugin: 'maven-publish'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName version
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions.incremental = false
}
kotlin {
targets {
fromPreset(presets.android, 'android')
// This preset is for iPhone emulator
// Switch here to presets.iosArm64 to build library for iPhone device
fromPreset(presets.iosX64, 'ios') {
compilations.main.outputKinds('FRAMEWORK')
}
}
sourceSets {
commonMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
}
}
commonTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test-common'
implementation 'org.jetbrains.kotlin:kotlin-test-annotations-common'
}
}
androidMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
}
}
androidTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test'
implementation 'org.jetbrains.kotlin:kotlin-test-junit'
}
}
iosMain {
}
iosTest {
}
}
}
configurations {
compileClasspath
}
问题的屏幕截图:
尝试使用--parallel选项从命令行运行Gradle任务
否则,请参阅此配置文件渐变执行指南。存在一个已知问题,即每次同步时都会重新获取Kotlin/本机依赖项,这可能就是您看到的。您可以查看详细信息并进行跟踪
正如发布到该期的文章所述,您可以尝试一种解决方法,它主要包括添加
{content{excludeGroup(“Kotlin/Native”}}
到您的存储库中的每一项块。正如@Brucelet指出的,这是一个。为了补充他的答案,下面是Groovy
中解决方法的完整实现:
repositories {
mavenCentral().content() {
excludeGroup "Kotlin/Native"
}
google().content() {
excludeGroup "Kotlin/Native"
}
jcenter() {
content {
excludeGroup("Kotlin/Native")
}
}
maven {
url 'https://jitpack.io'
content {
excludeGroup("Kotlin/Native")
}
}
}
在Kotlin DSL的中:
repositories {
mavenLocal().apply {
content {
excludeGroup("Kotlin/Native")
}
}
maven {
url = uri("https://dl.bintray.com/soywiz/soywiz")
content {
includeGroup("com.soywiz")
excludeGroup("Kotlin/Native")
}
}
jcenter() {
content {
excludeGroup("Kotlin/Native")
}
}
google().apply {
content {
excludeGroup("Kotlin/Native")
}
}
}
我已经尝试了本指南中的所有内容。问题不在于构建速度快,而在于同步。升级到最新版本(Kotlin1.3.21
和Gradle5.2.1
)为我解决了这个问题。