![](/img/trans.png)
[英]groovy.lang.MissingPropertyException: Could not set unknown property 'useIR' for object of type org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsImpl
[英]groovy.lang.MissingPropertyException: Could not set unknown property 'versionKey' for project ':flamingo' of type org.gradle.api.Project
在尝试使用intelliJ编译Java的火烈鸟图形工具时遇到此错误。
这是错误项目的build.gradle文件:
import javax.swing.SwingUtilities
dependencies {
compile project(":trident")
compile group: 'org.tmatesoft.svnkit', name: 'svnkit', version:'1.2.3.5521'
compile group:'org.apache.xmlgraphics', name:'batik-swing', version:'1.7'
compile (group:'org.apache.xmlgraphics', name:'batik-transcoder', version:'1.7') {
exclude group:'xml-apis'
exclude group:'xalan'
exclude group:'commons-io'
exclude group:'commons-logging'
exclude group:'org.apache.avalon.framework'
}
testCompile group: 'com.jgoodies', name: 'forms', version: '1.2.0'
testCompile group: 'junit', name: 'junit', version: '4.3.1'
testCompile group: 'org.easytesting', name: 'fest-assert', version: '1.2'
testCompile group: 'org.easytesting', name: 'fest-reflect', version: '1.2'
testCompile group: 'org.easytesting', name: 'fest-swing', version: '1.2.1'
testCompile group: 'org.easytesting', name: 'fest-swing-junit', version: '1.2.1'
testCompile group: 'org.easytesting', name: 'fest-swing-junit-4.3.1', version: '1.2.1'
}
sourceSets {
main
test
}
test {
// if we are headless, don't run our tests
enabled = !Boolean.getBoolean("java.awt.headless")
}
jar {
manifest {
attributes(
"Flamingo-Version": version,
"Flamingo-VersionName": versionKey,
)
}
}
task testJar(type: Jar) {
classifier = 'tst'
from sourceSets.test.classes
manifest {
attributes(
"Flamingo-Version": version,
"Flamingo-VersionName": versionKey,
)
}
}
uploadArchives {
try {
def x = [deployUsername, deployPassword]
} catch (Exception e) {
deployUsername = 'unset'
deployPassword = ''
}
repositories {
mavenDeployer {
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication userName: deployUsername, password: deployPassword
}
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication userName: deployUsername, password: deployPassword
}
configurePOM(pom)
}
}
}
install {
configurePOM(repositories.mavenInstaller.pom)
}
private def configurePOM(def pom) {
configureBasePom(pom)
pom.project {
name "flamingo"
description "A fork of @kirilcool's flamingo project"
url "http://insubstantial.github.com/peacock"
}
// deal with a gradle bug where transitive=false is not passed into the generated POM
pom.whenConfigured {cpom ->
cpom.dependencies.each {it
switch (it.artifactId) {
case 'trident':
it.classifier = 'swing'
break
}
}
}
}
我不知道要为版本密钥添加什么,也不知道在哪里。
该项目位于GitHub上: 它是原始项目flamingo的分支 。
这是根目录下的build.gradle文件:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'de.huxhorn.gradle:de.huxhorn.gradle.pgp-plugin:0.0.3'
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'maven'
try {
def test = pgpSecretKeyRingFile // exception will throw if not set
apply plugin: 'sign'
apply plugin: de.huxhorn.gradle.pgp.PgpPlugin
} catch (Exception ignore) {}
group = 'com.github.insubstantial'
version = '6.3-SNAPSHOT'
versionKey = "6.3-defender"
release = "internal"
sourceCompatibility = 1.6
targetCompatibility = 1.6
configurations {
maven { extendsFrom archives }
}
repositories {
mavenRepo urls: 'https://oss.sonatype.org/content/groups/staging'
mavenCentral()
mavenRepo urls: new File(System.getProperty('user.home'), '.m2/repository').toURI().toString()
}
task sourceJar(type: Jar) {
from sourceSets.main.java
from sourceSets.main.resources
classifier = 'sources'
}
task javadocJar(type: Jar) {
dependsOn javadoc
from javadoc.destinationDir
classifier = 'javadoc'
}
artifacts {
maven sourceJar
maven javadocJar
}
uploadArchives {
try {
def x = [deployUsername, deployPassword]
} catch (Exception e) {
deployUsername = 'unset'
deployPassword = ''
}
configuration = configurations.maven
repositories {
mavenDeployer {
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication userName: deployUsername, password: deployPassword
}
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication userName: deployUsername, password: deployPassword
}
}
}
}
install {
configuration = configurations.maven
}
configureBasePom = { pom ->
pom.project {
modelVersion '4.0.0'
packaging 'jar'
scm {
connection 'scm:git:git@github.com:Insubstantial/insubstantial.git'
developerConnection 'scm:git:git@github.com:Insubstantial/insubstantial.git'
url 'scm:git:git@github.com:Insubstantial/insubstantial.git'
}
developers {
developer {
name 'Kirill Grouchnikov'
email 'kirillcool@yahoo.com'
roles {
role 'author'
role 'developer'
}
}
developer {
name 'Danno Ferrin'
email 'danno.ferrin@shemnon.com'
roles {
role 'maintainer'
}
}
}
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.0-milestone-2'
}
此外,主build.gradle包含单词“ Exception”,这会引起intelliJ错误。
好吧,您的主要问题是-这两个都是有效的语句,您可以自己选择更有吸引力的项目-该项目是为太旧的Gradle版本设计的,无法与当前的Gradle集成和/或您的IntelliJ版本一起使用(或更确切地说,其Gradle集成)对于该项目而言太新了。
从技术上讲,IDE Gradle插件使用Gradle Tooling API与Gradle构建进行交互(运行它,获取有关源路径,依赖项,任务等的信息)。 IDE插件中使用的Tooling API的当前版本与Gradle 1.2的版本兼容,而Gradle 1.2确实已经很古老了。 不过,您的构建旨在与Gradle 1.0-milestone-2(甚至不是生产性版本)一起运行,并在其Gradle包装器设置中对其进行了定义。
这意味着,如果从命令行运行Gradle,将自动使用1.0-milestone-2,并且构建按设计工作(这是包装程序的绝妙之处)。 如果您尝试使用IntelliJ的Gradle集成导入项目,并告诉它使用项目的默认包装器(默认选择,始终是最好的主意,并且如果项目不使用该包装器,请告诉他们添加它),IntelliJ会告诉您您The project is using an unsupported version of Gradle. Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)
The project is using an unsupported version of Gradle. Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)
。 我猜您随后丢弃了消息对话框,并告诉IntelliJ使用某些本地Gradle安装来代替,然后得到您提到的错误。 (顺便说一句,您应该提到您遵循这种方式,使帮助变得更加容易)
当Gradle版本中存在主要版本颠簸时,它们会根据其弃用和删除策略将已弃用的内容移除足够长的时间,并且构建可能会因这些更改而中断,这正是您所展现的,因为您使用的是此构建的Gradle版本不是为不兼容而设计的。
因此,您可以做两件事。
您或者没有在此项目中使用IntelliJ中的Gradle集成,而是仅从命令行使用Gradle。 您可以将allprojects { apply plugin: 'idea' }
到build.gradle
,然后使用./gradlew idea
生成正确配置的IntelliJ项目文件,然后可以使用IntelliJ打开并使用该项目。
另一个选项(即使要做更多的工作,我也确实会推荐它)是更新内部版本以使其与当前Gradle版本兼容,并配置包装器以使用该新版本,这样集成就可以正常工作,您也将从中受益自从真正的旧版本以来,所有在Gradle中进行的开发。 您可以阅读发行说明,了解重要更改,重大更改和有趣的更改。 为了做到这一点,还应该足以更新到最新的1.x版本,修复所有不推荐使用的警告,更新到最新的2.x版本,修复所有不推荐使用的警告,更新到最新的3.x版本,修复所有弃用警告,然后更新到最新的4.x版本。 即使构建可能不是最好的构建,这也至少应该使构建以指导方式使用最新版本,同时不要使用Gradle中添加的一些新功能。 但这至少可以用作启动器。
您可能会觉得自己也可以做一个中间的事情,而只是将包装器设置为使用1.2。 因为它在同一主版本中,所以该版本应该可以使用它,并且正如我之前说的,1.2是目前用于集成的最旧版本。 至少部分。 诸如取消构建之类的事情将无法工作,因为1.2尚不支持此功能,即使工具API支持。 但这是行不通的,因为即使使用1.0,它的构建也不可行。 由于1.0-milestone-2只是一个预发布版本,因此当然还没有稳定性保证,并且在该版本和1.0之间进行了更改,这破坏了您的构建。
关于您实际遇到的两个错误,第一个是属性未知的错误,这正是我提到的重大更改之一。 以前,您可以通过执行foo = 'value'
来简单地设置任何新属性。 问题是,人们经常错误输入属性,例如fop = 'value'
了fop = 'value'
,然后想知道为什么它不起作用,没有得到任何有用的错误消息。 因此,动态定义的属性是被禁止的,您必须在ext
名称空间(例如ext { foo = 'value' }
或ext.foo = 'value'
,但仅限于第一次出现时。 这定义了新的自定义属性,以后您只能通过其名称来获取和设置它。 如果首先它不应该是所讨论对象(在您的情况下为项目)的属性,而是构建脚本中的局部变量,则应将其简单地定义为局部变量,例如def foo = 'value'
像往常一样在Groovy其中摇篮的基础上的。
关于第二个错误, Exception
的IntelliJ正在抱怨。 我的一点也不抱怨,我不知道您可能启用了哪些检查,但是如果Gradle没问题,那么IntelliJ应该没问题,您应该将其作为错误报告给JetBrains,但是我说,这里不是红色。 但是,无论是在构建脚本中,还是在Java中,甚至在编程中,使用像在该构建脚本中那样的流程控制都使用异常是非常不好的做法。
try {
def test = pgpSecretKeyRingFile // exception will throw if not set
apply plugin: 'sign'
apply plugin: de.huxhorn.gradle.pgp.PgpPlugin
} catch (Exception ignore) {}
例如可以写成
if (project.hasProperty('pgpSecretKeyRingFile')) {
apply plugin: 'sign'
apply plugin: de.huxhorn.gradle.pgp.PgpPlugin
}
和
try {
def x = [deployUsername, deployPassword]
} catch (Exception e) {
deployUsername = 'unset'
deployPassword = ''
}
例如可以写成
if (!(project.hasProperty('deployUsername') && project.hasProperty('deployPassword'))) {
deployUsername = 'unset'
deployPassword = ''
}
无需更改代码的含义
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.