Ant 蚂蚁路径转换
下午好 我正在运行ant来处理一些代码,现在我在属性中有路径“com/source/project”,但我需要将“com.source.project”传递给我的java代码,我是否可以使用ant命令将“/”转换为“.” 谢谢任务适合您,但您需要安装Ant 蚂蚁路径转换,ant,path,Ant,Path,下午好 我正在运行ant来处理一些代码,现在我在属性中有路径“com/source/project”,但我需要将“com.source.project”传递给我的java代码,我是否可以使用ant命令将“/”转换为“.” 谢谢任务适合您,但您需要安装 下面是一些使用的完整项目。我还必须用“.”替换${path.separator}来启动一些java类。请参阅以“;”开头的注释 <project xmlns:fl="antlib:it.haefelinger.flaka"> &l
下面是一些使用的完整项目。我还必须用“.”替换${path.separator}来启动一些java类。请参阅以“;”开头的注释
<project xmlns:fl="antlib:it.haefelinger.flaka">
<fl:install-property-handler/>
<property name="srcroot" value="path/to/srcrootdir"/>
<property name="classroot" value="path/to/classrootdir"/>
<!-- determine all main classes -->
<fileset dir="${srcroot}" includes="**/*.java" id="mainclasses">
<contains text="public static void main"/>
</fileset>
<!-- iterate over those main classes and
call the corresponding classfile -->
<fl:for var="file" in="split('${toString:mainclasses}', ';')">
<fl:let>
; strip the .java Extension
file = replace(file, '', '.java')
; replace fileseparator with '.'
; on Windows you have to use the following line
; replace(file, '\.', '${file.separator}${file.separator}')
file = replace(file, '\.', '${file.separator}')
</fl:let>
<fl:echo>
starting => #{file} in ${classroot}
</fl:echo>
<java classname="#{file}">
<classpath>
<!--
when using a fileset you'll get a
java.util.zip.ZipException because you're
referencing classfiles and no jars
therefore you have to use
pathelement and location
-->
<pathelement location="${classroot}"/>
</classpath>
</java>
</fl:for>
</project>
; 去掉.java扩展名
file=replace(文件,,.java)
; 将fileseparator替换为“.”
; 在Windows上,您必须使用以下行
; 替换(文件“\”,“${file.separator}${file.separator}”)
file=replace(文件“\.”,“${file.separator}”)
在${classroot}中启动=>{file}
<project xmlns:fl="antlib:it.haefelinger.flaka">
<fl:install-property-handler/>
<property name="srcroot" value="path/to/srcrootdir"/>
<property name="classroot" value="path/to/classrootdir"/>
<!-- determine all main classes -->
<fileset dir="${srcroot}" includes="**/*.java" id="mainclasses">
<contains text="public static void main"/>
</fileset>
<!-- iterate over those main classes and
call the corresponding classfile -->
<fl:for var="file" in="split('${toString:mainclasses}', ';')">
<fl:let>
; strip the .java Extension
file = replace(file, '', '.java')
; replace fileseparator with '.'
; on Windows you have to use the following line
; replace(file, '\.', '${file.separator}${file.separator}')
file = replace(file, '\.', '${file.separator}')
</fl:let>
<fl:echo>
starting => #{file} in ${classroot}
</fl:echo>
<java classname="#{file}">
<classpath>
<!--
when using a fileset you'll get a
java.util.zip.ZipException because you're
referencing classfiles and no jars
therefore you have to use
pathelement and location
-->
<pathelement location="${classroot}"/>
</classpath>
</java>
</fl:for>
</project>