栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在所有子文件夹中编译Java文件?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在所有子文件夹中编译Java文件?

使用诸如Ant或Maven之类的构建工具。与使用

find
UNIX工具相比,这两种方法都可以使您以更好的方式管理依赖关系。And和Maven都还允许您定义除编译之外要执行的自定义任务。Maven还附带了用于管理远程存储库中的外部依赖项的约定,以及用于运行单元测试和支持连续集成的功能的约定。

即使您只需要偶尔编译一次源文件,您也可能会发现,设置一个简单的Ant

build.xml
文件最终可以节省大量时间。

最后,大多数流行的IDE和代码编辑器应用程序都与Ant构建脚本进行了某种形式的集成,因此您可以在编辑器中运行所有Ant任务。NetBeans,Eclipse,IDEA等还具有对Maven的内置支持。

如果您是Ant的新手,请先阅读本文。以下是链接中的示例构建文件:

<project name="MyProject" default="dist" basedir=".">    <description>        simple example build file    </description>  <!-- set global properties for this build -->  <property name="src" location="src"/>  <property name="build" location="build"/>  <property name="dist"  location="dist"/>  <target name="init">    <!-- Create the time stamp -->    <tstamp/>    <!-- Create the build directory structure used by compile -->    <mkdir dir="${build}"/>  </target>  <target name="compile" depends="init"        description="compile the source " >    <!-- Compile the java pre from ${src} into ${build} -->    <javac srcdir="${src}" destdir="${build}"/>  </target>  <target name="dist" depends="compile"        description="generate the distribution" >    <!-- Create the distribution directory -->    <mkdir dir="${dist}/lib"/>    <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->    <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>  </target>  <target name="clean"        description="clean up" >    <!-- Delete the ${build} and ${dist} directory trees -->    <delete dir="${build}"/>    <delete dir="${dist}"/>  </target></project>

熟悉Ant之后,您会发现迁移到Maven更容易。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/437508.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号