java保存很长的文本报错,gradle windows java.io.IOException:CreateProcess错误= 206,文件名太长...

A couple of solutions to the problem of the windows path being too long are present for gradle:

However, it is unclear to me how to handle this in a multi project setup. Would all sub-projects with the application plugin require these changes?

Could this also be specified in the init.gradle file?

Also is there a better workaround?

Apparently https://github.com/viswaramamoorthy/gradle-util-plugins/ has been published. However, it does not fix the problems for me. The initial java problem is solved - but not correctly. Some classes can no longer be loaded i.e. unit tests be executed in case of scala.

edit

experimenting with

task testPathingJar(type: Jar) {

appendix = "testPathing"

doFirst {

manifest {

attributes "Class-Path": configurations.testCompile.files.join(" ")

}

}

}

compileTestScala {

dependsOn(testPathingJar)

classpath = files(testPathingJar.archivePath)

}

task pathingJar(type: Jar) {

appendix = "pathing"

doFirst {

manifest {

attributes "Class-Path": configurations.compile.files.join(" ")

}

}

}

compileScala {

dependsOn(pathingJar)

classpath = files(pathingJar.archivePath)

}

build {

dependsOn pathingJar

doFirst {

classpath = files("$buildDir/classes/main", "$buildDir/resources/main", pathingJar.archivePath)

}

}

unfortunately fails with during shadowJar as the manifest tricks reported in several of the links seem to have a problem with scala:

Cannot infer Scala class path because no Scala library Jar was found. Does project ':tma-mobility-frequencyCounting' declare dependency to scala-library? Searched classpath: file collection.

trying:

jar {

manifest {

attributes(

"Class-Path": configurations.compileOnly.collect { it.getName() }.join(' '))

}

}

fails for task `shadowDistZip` when executing `gradle build` with:

java.io.IOException: Cannot run program "C:\Program Files\Java\jdk1.8.0_131\bin\java.exe" (in directory "D:\users\username\development\projects\projectName\Code\spark\module_name"): CreateProcess error=206, Der Dateiname oder die Erweiterung ist zu lang

moving gradle user home to the root (also the project) of the partition:

.\gradlew.bat build --gradle-user-home D:\projects\gradleHome

fails with the same error for task `test`.

When trying the strategy of https://github.com/jhipster/generator-jhipster/pull/4324/files like:

task pathingJar(type: Jar) {

dependsOn configurations.runtime

appendix = 'pathing'

doFirst {

manifest {

attributes 'Class-Path': configurations.runtime.files.collect {

it.toURL().toString().replaceFirst(/file:\/+/, '/')

}.join(' ')

}

}

}

build {

dependsOn pathingJar

doFirst {

classpath = files("$buildDir/classes/main", "$buildDir/resources/main", pathingJar.archivePath) }

}

task pathingJarTest(type: Jar) {

dependsOn configurations.runtime

appendix = 'pathing'

doFirst {

manifest {

attributes 'Class-Path': configurations.runtime.files.collect {

it.toURL().toString().replaceFirst(/file:\/+/, '/')

}.join(' ')

}

}

}

test {

dependsOn pathingJarTest

doFirst {

classpath = files("$buildDir/classes/main", "$buildDir/resources/main", pathingJarTest.archivePath) }

}

Fails with

Caused by: org.gradle.api.GradleException: There were failing tests. See the report at: file:///C:/tmp/projectName/moduleName/reports/tests/test/index.html

even though this file never is created

trying one more thing: a fat jar including all the test cases:

task fatTestJar(type: Jar) {

baseName = project.name + '-test-all'

from {

from { configurations.testRuntime.collect { it.isDirectory() ? it : zipTree(it) }}

from sourceSets.test.output

}

with jar

}

however, this does not yet compile.

解决方案

test {

doFirst {

def cp = CollectionUtils.join(File.pathSeparator, classpath.getFiles())

environment 'CLASSPATH', cp

classpath = classpath.filter { false }

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值