Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从项目名称中创建Ant类路径_Ant_Classpath - Fatal编程技术网

从项目名称中创建Ant类路径

从项目名称中创建Ant类路径,ant,classpath,Ant,Classpath,在ant构建脚本中,我有一个我们依赖的项目列表。我需要创建一个用于编译的类路径 我有: included.projects=ProjectA, ProjectB 我需要: included.project.classpath=../ProjectA/bin, ../ProjectB/bin 当前代码: <echo message="${included.projects}" /> <pathconvert property="included.projects.class

在ant构建脚本中,我有一个我们依赖的项目列表。我需要创建一个用于编译的类路径

我有:

included.projects=ProjectA, ProjectB
我需要:

included.project.classpath=../ProjectA/bin, ../ProjectB/bin
当前代码:

<echo message="${included.projects}" />

<pathconvert property="included.projects.classpath" dirsep="," >
      <map from="" to="../"/>
        <path location="${included.projects}"/>
    </pathconvert>

<echo message="${included.projects.classpath}" />

<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6">
    <classpath>
        <pathelement path="${classpath}" />
        <dirset includes="${included.projects.classpath}" />
    </classpath>
</javac>

我也尝试过显式声明,但没有成功:

<path id="modules.classpath"> 
  <fileset dir="../ModuleA/bin" /> 
  <fileset dir="../ModuleB/bin"/> 
</path> 
<path id="libraries.classpath"> 
  <fileset dir="lib" includes="*.jar"/> 
</path> 
<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6"> 
   <classpath refid="libraries.classpath" /> 
   <classpath refid="modules.classpath" /> 
</javac>


我很好奇,显式声明代码有什么问题,是否可以用逗号分隔的字符串到类路径解决方案来解决

我认为在构建顶部明确声明类路径会更简单,如下所示:

<path id="compile.path">
   <fileset dir="../ProjectA/bin" includes="*.jar"/>
   <fileset dir="../ProjectB/bin" includes="*.jar"/>
</path>
<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6">
    <classpath>
        <path refid="compile.path"/>
        <pathelement path="${classpath}" />
    </classpath>
</javac>

用法如下:

<path id="compile.path">
   <fileset dir="../ProjectA/bin" includes="*.jar"/>
   <fileset dir="../ProjectB/bin" includes="*.jar"/>
</path>
<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6">
    <classpath>
        <path refid="compile.path"/>
        <pathelement path="${classpath}" />
    </classpath>
</javac>

注:

  • 我再次阅读了你的问题,才意识到你没有使用其他项目构建的jar文件,是吗。。。。不是个好主意

对于您的解决方案,我需要在我的所有build.xml中添加大的“compile.path”声明,但我希望使用commmon build.xml。关于注:当然。。。我为什么要这么做?我知道这是一种标准,但我看不出我的例子有什么意义:这是一个有5-10个模块的小项目,而且一切都在不断变化。这样我可以保存压缩、复制到存储库和解压缩。使用