我想在网络应用程序上进行一些黑盒测试。 因此,我想做以下事情: 1)解压缩tomcat以构建目录 2)解压缩Web应用程序以构建目录 3)从步骤1开始tomcat安装 4)做测试 5)停止tomcat
我迈出的第一步...
cargo {
containerId = 'tomcat6x'
port = 17388
local {
homeDir = file("$buildDir/install/apache-tomcat-6.0.30")
}
}
task unpackTomcat << {
file("$buildDir/install").mkdirs()
ant.unzip(src: configurations.tomcat.files.iterator().next(), dest: "$buildDir/install")
}
task largeTests << {
doFirst {
unpackTomcat
}
doLast {
cargoStartLocal
}
}
...
在执行largeTests任务时导致以下错误:
Build aborted because of an unexpected internal error. Please file an issue at: http://www.gradle.org.
* Try:
Run with --debug option to get additional debug info.
* Exception is:
java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:48)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:34)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:243)
at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:192)
at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:177)
at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:83)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:36)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:70)
at org.gradle.execution.DefaultBuildExecuter.access$300(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:80)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:70)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:63)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:157)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:112)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:80)
at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:42)
at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:28)
at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)
at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:233)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:217)
at org.gradle.launcher.Main.doAction(Main.java:48)
at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:53)
at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:51)
at org.gradle.launcher.exec.Execution.execute(Execution.java:28)
at org.gradle.launcher.exec.EntryPoint.run(EntryPoint.java:39)
at org.gradle.launcher.Main.main(Main.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:51)
at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:33)
at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
BUILD FAILED
答案 0 :(得分:1)
<<
是doLast
的简写。因此largeTests
从另一个操作添加了两个任务操作,这太晚了(必须在配置时添加操作)。不幸的是,错误信息不是很好。 :-)如果您在<<
之后移除largeTests
,则会在离开时出错。
另一项改进是对Copy
使用unpackTomcat
任务:
task unpackTomcat(type: Copy) {
from zipTree(configurations.tomcat.singleFile)
into "$buildDir/install"
}
答案 1 :(得分:0)
Peter是正确的,尽管你可能想要在解压缩后在shell脚本上设置正确的权限 - 如果你想让Gradle识别它已经执行了那个任务并跳过它,你应该考虑设置你的输入/输出同样。
这是我用来解压缩/复制新下载的tomcat副本并设置它的片段。
/**
* Expand the downloaded archive if it hasn't already been expanded
*/
task explodeTomcatServer(dependsOn: downloadTomcat) {
inputs.file file(tomcatZipFileLocation);
outputs.dir file(tomcatBaseName);
doLast {
copy {
from zipTree(tomcatZipFileLocation);
into project.projectDir;
include tomcatBaseName + '/bin/**';
include tomcatBaseName + '/conf/**';
include tomcatBaseName + '/lib/**';
include tomcatBaseName + '/webapps/**';
include tomcatBaseName + '/work/**';
}
// make sure that the shell scripts are set +x on linux / macs
if (System.getProperty("os.name").toLowerCase().indexOf("win") < 0) {
FileTree tree = fileTree(tomcatBaseName + '/bin').include('**/*.sh');
tree.each { File file ->
logger.info('Setting +x permission on ' + file);
file.setExecutable(true);
}
}
}
}