gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 17:22:44 26 4
gpt4 key购买 nike

当 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>

最佳答案

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

  • 将类路径转换为字符串
  • 转义 Windows 驱动器号 (C: = 坏\C: = 好)
  • 使用类路径属性创建仅 list 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,文件名或扩展名太长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17749010/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com