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

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

问题描述

当通过antrun的maven执行此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创建了冗长的类路径.我们需要使用一个路径罐子.

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

  • 将Classpath转换为字符串
  • 转义Windows驱动器号(C:=坏\ C:=很好)
  • 创建具有类路径属性的仅清单jar
  • 使用路径jar代替maven编译classpath

<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错误= 206,文件名或扩展名太长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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