Maven 和 Ant 无法运行 Java - CreateProcess error=206,文件名或扩展名太长 [英] Maven and Ant Can't run Java - CreateProcess error=206, The filename or extension is too long

查看:145
本文介绍了Maven 和 Ant 无法运行 Java - CreateProcess error=206,文件名或扩展名太长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当 maven 通过 antrun 执行此 java 代码时,出现可怕的错误 = 206,文件名或扩展名太长

When maven via antrun executes this java code I get the dreaded error=206, The filename or extension is too long

<java classname="com.me.api" failonerror="true" fork="true" maxmemory="128m" output="${wsdlFile}.out">
  <arg value="${className}" />
  <arg value="${name}" />
  <arg value="${wsdlFile}" />
  <classpath>
    <path refid="maven.test.classpath" />
  </classpath>

推荐答案

由于本地 Maven 存储库的结构和位置,Maven 创建了冗长的类路径.我们需要使用路径 jar.

Maven creates lengthy classpaths due to the structure and location of the local maven repo. We need to use a pathing jar.

  • 将类路径转换为字符串
  • 转义 Windows 驱动器号(C: = 坏 \C: = 好)
  • 仅使用类路径属性创建清单 jar
  • 使用路径 jar 而不是 maven 编译类路径

<mkdir dir="${classpath-compile.dir}"/>

<!-- Convert into usable string .   -->
<pathconvert property="compile_classpath_raw" pathsep=" ">
    <path refid="maven.compile.classpath"/>                        
</pathconvert>

<!-- escape windows drive letters (remove C: from paths -- need to wrap with a condition os.family="windows")-->
<propertyregex property="compile_classpath_prep" 
  input="${compile_classpath_raw}"
  regexp="([A-Z]:)"
  replace="\\\\\1"
  casesensitive="false"
  global="true"/>

<!-- Create pathing Jars -->
<jar destfile="${classpath-compile.jar}">
  <manifest>
    <attribute name="Class-Path" value="${compile_classpath_prep}"/>
  </manifest>                      
</jar>

<java classname="com.me.api" failonerror="true" fork="true" maxmemory="128m" output="${wsdlFile}.out">
  <arg value="${className}" />
  <arg value="${name}" />
  <arg value="${wsdlFile}" />
  <classpath>
    <pathelement location="${classpath-compile.jar}" />
  </classpath>

这篇关于Maven 和 Ant 无法运行 Java - CreateProcess error=206,文件名或扩展名太长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆