Gradle仅在Linux上抛出错误
因此,每当我尝试执行gradle startMongoDB时,就会出现以下错误:Gradle仅在Linux上抛出错误,linux,tomcat,gradle,Linux,Tomcat,Gradle,因此,每当我尝试执行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 evalua
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上,它运行良好。有什么问题吗
请告诉我,如果有任何更多的信息是需要的错误,我会提供它
Build.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"
}
}
通过安装最新的gradle 1.11进行修复粘贴build.gradle可能会有所帮助。使用它编辑我的帖子通过安装最新的gradle:1.11修复了此问题。