ant编辑java忽略注释,ANT - 如何使用排除,excludesfile用javac?

Looked at several post on stackoverflow as well as other sources (online + ANT definition guide book) but none of them helped so far. I can't exclude the file from compiling.

I have just one file that wants to exclude from compiling and ANT documentation is not really telling the detail.

I'm trying to exclude HTMLParser.java from compiling.

Also tried using excludesfile too. But it still complies HTMLParser.java

I wrote simple ANT to examine trying different variation below.

Could anyone tell me what's wrong?

name="CompileMasatosan"

default="main"

basedir="C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\head_first\src\com\masatosan">

location="C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\head_first\WEB-INF\classes" />

location="C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\head_first\src\com\masatosan\utilities" />

The HTMLParser.java I believe has no dependency since I commented all lines out except class declaration line.

HTMLParser.java

package com.masatosan.utilities;

public class HTMLParser {

/* commenting out since Eclipse doesn't like some characters :(

public static final String escapeHTML(String s){

StringBuffer sb = new StringBuffer();

int n = s.length();

for (int i = 0; i < n; i++) {

char c = s.charAt(i);

switch (c) {

case '

case '>': sb.append(">"); break;

case '&': sb.append("&"); break;

case '"': sb.append("""); break;

case 'à': sb.append("à");break;

case 'À': sb.append("À");break;

case 'â': sb.append("â");break;

case 'Â': sb.append("Â");break;

case 'ä': sb.append("ä");break;

case 'Ä': sb.append("Ä");break;

case 'Ã¥': sb.append("å");break;

case 'Ã…': sb.append("Å");break;

case 'æ': sb.append("æ");break;

case 'Æ': sb.append("Æ");break;

case 'ç': sb.append("ç");break;

case 'Ç': sb.append("Ç");break;

case 'é': sb.append("é");break;

case 'É': sb.append("É");break;

case 'è': sb.append("è");break;

case 'È': sb.append("È");break;

case 'ê': sb.append("ê");break;

case 'Ê': sb.append("Ê");break;

case 'ë': sb.append("ë");break;

case 'Ë': sb.append("Ë");break;

case 'ï': sb.append("ï");break;

case 'Ã�': sb.append("Ï");break;

case 'ô': sb.append("ô");break;

case 'Ô': sb.append("Ô");break;

case 'ö': sb.append("ö");break;

case 'Ö': sb.append("Ö");break;

case 'ø': sb.append("ø");break;

case 'Ø': sb.append("Ø");break;

case 'ß': sb.append("ß");break;

case 'ù': sb.append("ù");break;

case 'Ù': sb.append("Ù");break;

case 'û': sb.append("û");break;

case 'Û': sb.append("Û");break;

case 'ü': sb.append("ü");break;

case 'Ãœ': sb.append("Ü");break;

case '®': sb.append("®");break;

case '©': sb.append("©");break;

case '€': sb.append("€"); break;

// be carefull with this one (non-breaking whitee space)

case ' ': sb.append(" ");break;

default: sb.append(c); break;

}

}

return sb.toString();

}

*/

}//

UPDATE

As suggested in the comment, I change the excludesfile name attribute to relative path of srcdir and that was it! So the snipped looks like:

解决方案

Obvious thing I imagine you have already checked is that nothing that you are compiling has a dependency in HTMLParser. If this is the case, the javac command will compile the file anyways.

To clarify, the problem above was using an absolute path with the exclude property. When a srcdir is given, ant creates an implicit path with exclude file names.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值