У меня есть приведенный ниже скрипт gradle из структуры Jhipster. Он используется для запуска тестов Gatling, и из-за ограничения командной строки в окнах я пробовал использовать подход jar только для манифеста. Подробное обсуждение этого вопроса можно найти здесь проблема с Jhipster. сгенерируйте банку манифеста правильно, но JavaExec не может найти основной класс, некоторый указатель на это был бы действительно полезен. Журнал ошибок консоли также приведен ниже.
Я разместил это на форуме Gradle здесь, но пока безуспешно
применить плагин: 'скала'
sourceSets {
test {
scala {
srcDirs = ['src/test/gatling/simulations']
output.classesDir = 'target/test-classes'
}
}
}
task manifestJar(dependsOn:'compileTestScala',type: Jar) {
dependsOn configurations.runtime
classifier 'pathing'
doFirst {
manifest {
// uri is just needed for Windows-compatibility
attributes 'Class-Path': configurations.runtime.files.collect{ project.uri(it) }.join(' ')
}
}
}
task gatlingRun(dependsOn:'manifestJar', type: JavaExec) {
//dependsOn configurations.runtime
group = "gatling"
standardInput = System.in
final def sourceSet = sourceSets.test
File configFile = file('src/test/gatling/conf/gatling.conf')
def String gatlingDataFolder = "$project.rootDir.absolutePath/src/test/gatling/data"
def String gatlingReportsFolder = "$project.buildDir.absolutePath/reports/gatling"
def String gatlingBodiesFolder = "$project.rootDir.absolutePath/src/test/gatling/bodies"
def String gatlingSimulationsFolder = "$project.rootDir.absolutePath/src/test/gatling/simulations"
//classpath sourceSet.output + sourceSet.runtimeClasspath + files("src/test/gatling/conf")
classpath sourceSet.output + files(manifestJar.archivePath) + files("src/test/gatling/conf")
//classpath = files(pathingJar.archivePath)
main = "io.gatling.app.Gatling"
environment GATLING_HOME:''
args '-df', gatlingDataFolder
args '-rf', gatlingReportsFolder
args '-bdf', gatlingBodiesFolder
args "-sf", gatlingSimulationsFolder
args "-rd", ""
}
Журнал консоли:
:compileTestJava UP-TO-DATE
:compileTestJava (Thread[main,5,main]) completed. Took 0.973 secs.
:compileTestScala (Thread[main,5,main]) started.
:compileTestScala
Skipping task ':compileTestScala' as it is up-to-date (took 0.325 secs).
:compileTestScala UP-TO-DATE
:compileTestScala (Thread[main,5,main]) completed. Took 0.344 secs.
:manifestJar (Thread[main,5,main]) started.
:manifestJar
Skipping task ':manifestJar' as it is up-to-date (took 0.012 secs).
:manifestJar UP-TO-DATE
:manifestJar (Thread[main,5,main]) completed. Took 0.038 secs.
:processTestResources (Thread[main,5,main]) started.
:processTestResources
Skipping task ':processTestResources' as it is up-to-date (took 0.013 secs).
:processTestResources UP-TO-DATE
:processTestResources (Thread[main,5,main]) completed. Took 0.041 secs.
:testClasses (Thread[main,5,main]) started.
:testClasses
Skipping task ':testClasses' as it has no actions.
:testClasses UP-TO-DATE
:testClasses (Thread[main,5,main]) completed. Took 0.019 secs.
:gatlingRun (Thread[main,5,main]) started.
:gatlingRun
Executing task ':gatlingRun' (up-to-date check took 0.001 secs) due to:
Task has not declared any outputs.
Starting process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe''. Working directory: D:\Projects\jh5 Command: C:\Program Files\Java\jdk1.8.
0_45\bin\java.exe -Dfile.encoding=windows-1252 -Duser.country=SG -Duser.language=en -Duser.variant -cp D:\Projects\jh5\target\test-classes;D:\Projects
\jh5\build\resources\test;D:\Projects\jh5\build\libs\jhipster-pathing.jar;D:\Projects\jh5\src\test\gatling\conf io.gatling.app.Gatling -df D:\Projects
\jh5/src/test/gatling/data -rf D:\Projects\jh5\build/reports/gatling -bdf D:\Projects\jh5/src/test/gatling/bodies -sf D:\Projects\jh5/src/test/gatling
/simulations -rd
Successfully started process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe''
Error: Could not find or load main class io.gatling.app.Gatling
:gatlingRun FAILED
:gatlingRun (Thread[main,5,main]) completed. Took 0.166 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':gatlingRun'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
Total time: 28.134 secs
Stopped 0 compiler daemon(s).
java -jar thejar.jar
. Если вы укажете путь к классам с помощью -cp и основной класс для выполнения, это не будет иметь никакого эффекта. - person JB Nizet   schedule 04.07.2015