gpt4 book ai didi

linux - Gradle 仅在 Linux 上抛出错误

转载 作者:行者123 更新时间:2023-11-28 23:37:37 26 4
gpt4 key购买 nike

所以每当我尝试执行 gradle startMongoDB 时,我都会收到此错误:

gradle startMongoDB

FAILURE: Build failed with an exception.

* Where:
Build file '/home/kaspar/Eclipse/workspace/conference-application/app/build.gradle' line: 2

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method create() for arguments [tomcatRun, class org.gradle.api.plugins.tomcat.tasks.TomcatRun, org.gradle.api.plugins.tomcat.TomcatPlugin$_configureTomcatRun_closure2@1315391f] on task set.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 5.765 secs

这似乎只发生在我尝试在 Linux 机器上运行它时。在 Windows 上,它运行良好。可能是什么问题?

如果需要有关该错误的更多信息,请告诉我,我会提供。

构建.gradle:

import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'java'

repositories {
mavenCentral()
}

task wrapper(type: Wrapper, description: 'Gradle wrapper') {
gradleVersion = '1.11'

def jvmOpts = "-Xmx512m"
inputs.property("jvmOpts", jvmOpts)
doLast {
def optsEnvVar = "DEFAULT_JVM_OPTS"
scriptFile.write scriptFile.text.replace("$optsEnvVar=\"\"", "$optsEnvVar=\"$jvmOpts\"")
batchScript.write batchScript.text.replace("set $optsEnvVar=", "set $optsEnvVar=$jvmOpts")
}
}

task downloadMongoDB(description: 'Download and unpack MongoDB database') {

ext.mongoDBDir = new File('mongoDB')

if (!mongoDBDir.isDirectory()) {

ant.mkdir(dir: './mongoDB')
ant.mkdir(dir: './.tmp')

if (Os.isFamily(Os.FAMILY_WINDOWS)) {
ant.with{
get src: 'http://fastdl.mongodb.org/win32/mongodb-win32-i386-2.4.10-rc0.zip', dest: './.tmp/mongoDB.zip', skipexisting: true
unzip src: './.tmp/mongoDB.zip', dest: './', overwrite: true
copydir src: './mongodb-win32-i386-2.4.10-rc0/', dest: './mongoDB/'
delete dir: './mongodb-win32-i386-2.4.10-rc0', deleteonexit: true
}
} else if (Os.isFamily(Os.FAMILY_MAC)) {
ant.with{
get src: 'http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-2.4.10-rc0.tgz', dest: '.tmp/mongoDB.tgz', skipexisting: true
untar src: '.tmp/mongoDB.tgz', dest: './', overwrite: true, compression: 'gzip'
copydir src: './mongodb-osx-x86_64-2.4.10-rc0/', dest: './mongoDB/'
delete dir: './mongodb-osx-x86_64-2.4.10-rc0', deleteonexit: true
}
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
// Needs testing
ant.with{
get src: 'http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.4.10-rc0.tgz', dest: '.tmp/mongoDB.tgz', skipexisting: true
untar src: '.tmp/mongoDB.tgz', dest: './', overwrite: true, compression: 'gzip'
copydir src: './mongodb-linux-i686-2.4.10-rc0/', dest: './mongoDB/'
delete dir: './mongodb-linux-i686-2.4.10-rc0', deleteonexit: true
}
} else {
throw new StopExecutionException("Unknown operating system")
}
}
}

task repairMongoDB(type: Exec, dependsOn: 'downloadMongoDB', description: 'Repair MongoDB database') {
workingDir projectDir.path

ant.mkdir(dir: './data/db')

if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine '.\\mongoDB\\bin\\mongod', '--dbpath', '.\\data\\db', '--logpath', '.\\data\\db\\mongodb.log', '--rest', '--logappend', '--repair'
}else{
// After unpack the files do not have executable permission
FileTree tree = fileTree('./mongoDB/bin').include('*');
tree.each { File file ->
file.setExecutable(true);
}
commandLine './mongoDB/bin/mongod', '--dbpath', './data/db', '--logpath', './data/db/mongodb.log', '--rest', '--logappend', '--repair'
}
}

task startMongoDB(type: Exec, dependsOn: 'repairMongoDB', description: 'Run MongoDB database') {

workingDir projectDir.path

if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine '.\\mongoDB\\bin\\mongod','--port', '27017', '--dbpath', '.\\data\\db', '--logpath', '.\\data\\db\\mongodb.log', '--logappend', '--rest'
}else{
commandLine './mongoDB/bin/mongod', '--port', '27017', '--dbpath', './data/db', '--logpath', './data/db/mongodb.log', '--logappend', '--rest'
}
}

subprojects {
apply from: project.rootDir.path + "/gradle-include/eclipse.gradle"

if(project.file('src/main').exists()) {
apply from: project.rootDir.path + "/gradle-include/maven.gradle"
}
}

最佳答案

通过安装最新的底座 (1.11) 修复

关于linux - Gradle 仅在 Linux 上抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23227675/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com