FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Project:bootRun'.
> A problem occurred starting process 'command 'C:\Java\jdk1.8.0_65\bin\java.exe''
* 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: 2.332 secs
CreateProcess error=206, The filename or extension is too long. (파일 이름이나 확장명이 너무 깁니다.)
오전 10:58:49: Task execution finished 'bootRun'.
gradle library 추가 후 bootrun 실행시 발생한 오류. 뭔 파일 이름이나 확장명이 길다는건지; --debug 는 봐도 모르겠고...
검색 결과 클래스패스 종족성이 너무 길다는거 같은데, 클래스패스를 찍어 봤더니 약 33000자가 넘었다.ㅋㅋ;
Windows 에 CreateProcess 의 limit 가 32767 인거 같음.
Bootrun 시작 명령이 java -jar MyApp.jar -classpath a.jar,b.jar,c.jar,... 처럼 나열되는데 그럼 라이브러리를 몇 개 빼야하나;
해결책은 하나의 jar 파일에 저 종속성들을 나열하는 manifest 파일을 만들고 명령문에는 그 jar 파일 하나만을 호출하면 끝!
Gradle.build 코드는 다음과 같다.
task pathingJar(type: Jar) { dependsOn configurations.runtime appendix = 'pathing' doFirst { manifest { attributes "Class-Path": configurations.runtime.files.collect { it.toURI().toString().replaceFirst(/file:\/+/, '/') }.join(' ') } } } bootRun { dependsOn pathingJar doFirst { classpath = files("$buildDir/classes/main", "$buildDir/resources/main", pathingJar.archivePath) } } | cs |
이제 bootrun 을 실행하면 아래와 같이 manifest 파일이 담긴 pathing.jar 파일로 모든 종속성을 실행하게 된다.
> java -jar MyApp.jar -classpath pathing.jar | cs |
WRITTEN BY
- 손가락귀신
정신 못차리면, 벌 받는다.