Convert Ant build file to Makefile

馋奶兔 提交于 2020-01-14 04:07:33

问题


I have Ant build file which is used in Docbook. Now I am going to convert that Ant build file to a Makefile which uses Xsltproc processor. I am not particularly familiar with either Makefile or Ant. So please help me to convert it. Are there any resources which I should follow?

Here I want to, 1. copy folder structure and its content into another folder 2. configure java system properties 3. configure classpath

In ant script, it has code like this,

<copy todir="${output-dir}">
<fileset dir="${ant.file.dir}/template">
<include name="**/*"/>
</fileset>
</copy>

 <java classname="com.nexwave.nquindexer.IndexerMain" fork="true"> 
         <sysproperty key="htmlDir" value="${output-dir}/content"/>
         <sysproperty key="htmlExtension" value="${html.extension}"/>
           <classpath>
        <path refid="classpath"/>
        <pathelement location="${xercesImpl.jar}"/>         
        <pathelement location="/usr/share/xml-commons/lib/xml-apis.jar"/>    
      </classpath>
    </java>

I want to convert above 2 codes in make. Thank you..!!


回答1:


Make and ANT are very different technologies. Your requirement would difficult to fufil for all but the simplest use cases.

Here are some of the technical challenges:

  • ANT is not Make. On the surface it looks similar, but underneath works quite differently.
  • Surprisingly make is not very cross platform. Different flavours have subtle differences that could break an ANT to Makefile convertor.
  • ANT is designed to support Java programs, this means it has a rich syntax for managing nasty things like Java classpaths. Again difficult to translate.

Update

The following ANT java task

 <java classname="com.nexwave.nquindexer.IndexerMain" fork="true"> 
         <sysproperty key="htmlDir" value="${output-dir}/content"/>
         <sysproperty key="htmlExtension" value="${html.extension}"/>
           <classpath>
        <path refid="classpath"/>
        <pathelement location="${xercesImpl.jar}"/>         
        <pathelement location="/usr/share/xml-commons/lib/xml-apis.jar"/>    
      </classpath>
 </java>

can be translated into the following unix java command-line.

java \
   -DhtmlDir=$PUT_OUTPUT_DIR_HERE \
   -DhtmlExtension=$PUT_EXT_HERE \
   -cp $CLASSPATH:$PATH_TO_XERCES_JAR:/usr/share/xml-commons/lib/xml-apis.jar \
   com.nexwave.nquindexer.IndexerMain


来源:https://stackoverflow.com/questions/10810236/convert-ant-build-file-to-makefile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!