我刚来格拉德尔,我不知道该怎么做。
下面是类星体关于如何通过Gradle安装类星体的文档:类星体博士
页面中还有一个模板项目:模板分级项目
最后这是我的build.gradle
group 'TGAdminsBot'
version '0.1'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'application'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
mainClassName = "Launcher"
idea {
module
{
downloadJavadoc = true
downloadSources = true
}
}
dependencies {
compile 'co.paralleluniverse:quasar-core:0.7.4:jdk8'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.4'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.4'
//compile 'com.github.User:Repo:Tag'
//compile 'com.mashape.unirest:unirest-java:1.4.9'
compile 'co.paralleluniverse:comsat-httpclient:0.7.0'
compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.2.0'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
configurations {
quasar
}
task runQuasar {
jvmArgs "-javaagent:${configurations.quasar.iterator().next()}"
}
run.dependsOn runQuasar我得到了一个错误:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\Sobhan\Documents\IntelliJIDEAProjects\TGAdminsBot\build.gradle' line: 39
* What went wrong:
A problem occurred evaluating root project 'TGAdminsBot'.
> java.util.NoSuchElementException (no error message)那我该怎么办?我再次很抱歉问了这个问题,但我对Gradle还是新手,在发布这个问题之前,我在谷歌上搜索了很多。谢谢
发布于 2016-05-06 14:43:28
有三个问题。
configurations是在dependencies之前定义的。dependencies中需要两行编译“co.PALEBY:类星体-核心:0.7.4:jdk8‘8”
类星体同平行宇宙:类星体-核:0.7.4:jdk8‘8’
tasks.withType(JavaExec){
jvmArgs "-javaagent:${configurations.quasar.iterator().next()}" }
最后,这是最终的build.gradle
group 'TGAdminsBot'
version '0.1'
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
idea {
module
{
downloadJavadoc = true
downloadSources = true
}
}
configurations {
quasar
}
dependencies {
compile 'co.paralleluniverse:quasar-core:0.7.4:jdk8'
quasar 'co.paralleluniverse:quasar-core:0.7.4:jdk8'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.4'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.4'
compile 'co.paralleluniverse:comsat-httpclient:0.7.0'
compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.2.0'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
tasks.withType(JavaExec)
{
jvmArgs "-javaagent:${configurations.quasar.iterator().next()}"
}
task run(type: JavaExec) {
main = 'com.sunova.bot.Launcher'
classpath = sourceSets.main.runtimeClasspath
}发布于 2016-05-06 06:30:50
我认为您的问题主要在于runQuasar的定义,它不是一个运行任务,因此没有jvmArgs属性,但是,如果您出于其他原因不需要它,只需执行与Gradle模板项目一样(代理配置),而不是定义runQuasar并声明run依赖于它:
applicationDefaultJvmArgs = [
"-javaagent:${configurations.quasar.singleFile}" // =v, =d
]如果您需要一个单独的runQuasar,我想您需要将它声明为一个JavaExec任务(请看一下这里)。
https://stackoverflow.com/questions/37049295
复制相似问题