小编soj*_*ner的帖子

与ant和java的windows classpath问题

我已经在这些战壕中战斗了一段时间,但尚未开始工作.在SO以及其他类似博客此SO帖子中使用了很多示例,我仍然无法超越Windows类路径限制.我目前正在处理一个在我的源代码中运行java类中的单个main方法的ant任务.如果我能在这里工作,我可以在其他地方推断.

首先,我原来的相关构建任务

<path id="code.classpath">
    <path id="code.classpath">
    <path refid="jars.code"/>
    <path refid="jars.common"/>
    <path refid="jars.servlet-api"/>
    <dirset dir="${code.dir}" excludes="xlib/scripts/**"/>
</path>
<target name="code.exec" description="Execute a class file">
    <echo>${code}</echo>
    <input addproperty="code.exec.class">Enter full class name (e.g. ${atmr.pkg}.FooBar):</input>
    <input addproperty="code.exec.args">Enter arguments:</input>
    <java classname="${code.exec.class}"
          fork="true"
          dir="${code.src.dir}"
          failonerror="true"
          classpathref="code.classpath">
        <jvmarg value="-Xmx4048M"/>
        <jvmarg value="-ea"/>
        <jvmarg value="-Dlog4j.configuration=file:${basedir}/log4j.xml"/>
        <syspropertyset refid="proxy.properties"/>
        <assertions refid="code.exec.assertions"/>
        <arg line="${code.exec.args}"/>
    </java>
</target>
Run Code Online (Sandbox Code Playgroud)

接下来,我最近尝试解决方案

<path id="code.source">
    <dirset dir="${code.dir}" excludes="xlib/scripts/**"/>
</path>

<target name="code.classpath.acme">
    <manifestclasspath property="jar.classpath" jarfile="${app.dir}/acme.jar">
        <classpath refid="code.source"/>
    </manifestclasspath>

    <jar destfile="${app.dir}/acme.jar" index="true">
        <manifest>
            <attribute name="Class-Path" value="${jar.classpath}"/>
        </manifest> …
Run Code Online (Sandbox Code Playgroud)

java ant jar manifest classpath

5
推荐指数
1
解决办法
902
查看次数

标签 统计

ant ×1

classpath ×1

jar ×1

java ×1

manifest ×1