---
title: "ant中使用eclipse编译器"
author: "zhou_wu"
date: "2012-01-12T15:34:02Z"
tags: []
categories: ["开源软件"]
slug: "ant-eclipse"
draft: false
lastmod: "2013-05-14T17:52:17Z"
id: 1343518
url: "https://leesmart.iteye.com/blog/1343518"
---

问题场景：
java代码里有些字符串常量太长了，超过了64k，使用默认的JDK编译是无法编译成功的，出现Constant string too long的exception.但是这个class在Eclipse中是可以编译通过的。所以基本想法就是在ant中执行某个target的时候使用eclipse的编译器,这里叫jdtCompilerAdapter.

解决方案：
1.ant的lib里加上jdtCompilerAdapter.jar和org.eclipse.jdt.core_xxx.jar
2.buid.xml中

```xml
	<javac destdir="xxxx/WEB-INF/classes" debug="on" target="1.5" source="1.5" fork="true"failonerror="true" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"></javac>
```