开发者

Javac exclusion of package in ANT build.xml

开发者 https://www.devze.com 2023-01-18 20:40 出处:网络
I\'m trying to compile all my packages except two of them, here is what my javac in build.xml looks like

I'm trying to compile all my packages except two of them, here is what my javac in build.xml looks like

<javac srcdir="${src}" destdir="${output}" debug="${debug}" failonerror="yes" >
    <exclude name="com/abc/uyyy/**"/>
    <exclude name="com/abc/zzz/**"/>
    <include name="com/abc/zzz/Text.java"/>
    <pa开发者_开发百科tternset refid="excluded.from.compilation.abc"/>
    <classpath refid="abc.module.classpath"/>
</javac>

But all the files in package are compiled :(.

I've read the documentation (http://ant.apache.org/manual/Tasks/javac.html), but still no success, any help?

NOTE: After the Text.java is compiled, I need to build the WSDL file and then build the excluded packages. I'm using Metro to write and build my WS.


Is it not possbile to compile all the class files into one directory, then use the copy task like below to only copy the ones you want for WSDL?

<target name="copy_all_class_files">
    <copy todir="${output}">
        <fileset dir="classes">
            <include name="com/abc/zzz/Text.class"/>
            <exclude name="com/abc/uyyy/**"/>
            <exclude name="com/abc/zzz/**"/>
        </fileset>
    </copy>
</target> 


Ok here is what I did,I wrote a new target to compile only the WS file and then generate the classes, it works fine :)

<target name="compile-ws-server">
        <javac srcdir="${src}" destdir="${output}"
        debug="${debug}" failonerror="yes">
            <include name="com/abc/xxx/Text.java"/>
            <exclude name="${src}/abc/xxx/**"/>
            <classpath refid="abc.module.classpath"/>
        </javac>
    </target>


All Above is not proper way ...

I have done like

<target name="compile" depends="init">
    <javac srcdir="${src}" destdir="${build}" excludes="com/company/example/test/**" />
</target>

Here we should avoid placing ${src} and start from inside src folder.

0

精彩评论

暂无评论...
验证码 换一张
取 消