zoukankan      html  css  js  c++  java
  • java project打包生成jar包(通用)

    1. 在工程目录下新建一个build.xml文件,如下图所示,注意必须是在工程目录下,而不是在工程目录的src目录里。

    2.编写ant脚本,内容如下,jar文件名称(com.anllin.rup.bookshop.stub.jar)需要更改,其他通用。

    <?xml version="1.0" encoding="utf-8"?>
    <project name="buildJarFile" default="compile" basedir=".">
        <!-- the directory containing source code-->
        <property name="src.dir" value="src" />
    
        <!-- Temporary build directories -->
        <property name="build.dir" value="build" />
        <property name="build.classes" value="${build.dir}/classes" />
        <property name="build.lib" value="${build.dir}/lib" />
    
        <!-- Target to  create the build directories prior to the compile target-->
        <target name="init">
            <mkdir dir="${build.dir}" />
            <mkdir dir="${build.classes}" />
            <mkdir dir="${build.lib}" />
        </target>
    
        <target name="clean" description="Remove all generted files">
            <delete dir="${build.dir}" />
        </target>
    
        <target name="compile" depends="init" description="Compiles all source code">
            <javac srcdir="${src.dir}" destdir="${build.classes}" />
        </target>
    
        <target name="jar" depends="compile" description="Generates jar file in 'dist' diretory">
            <!-- Exclude unit tests from the final JAR file-->
            <jar jarfile="${build.lib}/com.anllin.rup.bookshop.stub.jar" basedir="${build.classes}" excludes="**/*Test.class" />
        </target>
    
        <target name="alll" depends="clean, jar" description="Cleans, complies, then builds the JAR files.">
        </target>
    </project>

    3.选中build.xml,右键选择run as -> ant build, 执行脚本后,生成build目录如下图:

  • 相关阅读:
    OpenCV 使用FLANN进行特征点匹配
    OpenCV 特征描述
    OpenCV 特征点检测
    OpenCV 亚像素级的角点检测
    OpenCV Shi-Tomasi角点检测子
    OpenCV Harris 角点检测子
    OpenCV 模板匹配
    OpenCV 直方图计算
    OpenCV 直方图均衡化
    OpenCV 仿射变换
  • 原文地址:https://www.cnblogs.com/zfc2201/p/3474835.html
Copyright © 2011-2022 走看看