IntelliJ IDEA v2019.2
例如,我有一个Gradle插件项目,该项目通过./gradlew build
构建在OSX命令行上。我将项目“从现有来源导入”到IntelliJ中,当我构建时,我得到了
Error:(3, 22) java: package org.gradle.api does not exist
Error:(4, 28) java: package org.gradle.api.tasks does not exist
Error:(5, 36) java: package org.gradle.api.tasks.options does not exist
Error:(6, 22) java: package org.gradle.api does not exist
,当然也因此,我得到后续的Cannotfine symbol error。这在我的build.gradle文件中。
plugins {
id 'idea'
id 'java'
id 'maven'
id 'maven-publish'
id 'java-gradle-plugin'
}
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'java-gradle-plugin'
group=project.groupId
version = '0.0.1'
dependencies {
compile gradleApi()
}
jar {
manifest {
attributes 'artifactId': project.artifactId,
'groupId': project.groupId,
'version': project.version
}
baseName artifactId
doLast {
println "artifactId: $project.artifactId\ngroupId: $project.groupId\nversion: $version"
}
}
jar {
manifest {
attributes 'artifactId': project.artifactId,
'groupId': project.groupId,
'version': project.version
}
baseName artifactId
doLast {
println "artifactId: $project.artifactId\ngroupId: $project.groupId\nversion: $version"
}
}
gradlePlugin {
plugins {
simplePlugin {
id = 'com.zift.utilities.zift-version-plugin'
implementationClass = 'com.zift.utilities.ZiftVersionPlugin'
}
}
}
我在项目的“外部库”列表中看到org.gradle.api.*
。
我想念什么?
更新:
如果我打开Gradle边栏并双击Tasks->build->build
,它将建立,但是当我单击绿色锤子来Build Project
时,它将失败。有什么不同? (我是IntelliJ的新手。)