Maven和Ant无法运行Java - CreateProcess error = 206,文件名或扩展名太长

Pet*_*ahn 5 ant maven maven-antrun-plugin

当maven通过antrun执行这个java代码时,我得到了可怕的错误= 206,文件名或扩展名太长了

<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>
Run Code Online (Sandbox Code Playgroud)

Pet*_*ahn 6

由于本地 Maven 存储库的结构和位置,Maven 会创建冗长的类路径。我们需要使用路径 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>
Run Code Online (Sandbox Code Playgroud)