HackCode
HackCode

Reputation: 1847

project building in eclipse but not from terminal/jenkins - using Ant

I am using Ant to build my java project. Basically, the build file is the default build.xml that is created when you right click on project in eclipse and select plug-in tools > create Ant build file. This builds the project with a couple of eclipse plugin dependencies and creates a folder with all the .class files.

When I run my default build.xml. from eclipse, it's working fine. It creates the folder with .class files just like I want.

However, when I try to run it through my terminal like:

ant -buildfile build.xml

or even through jenkins for that matter, I get errors like:

[javac] .jenkins/workspace/..../UserExitImpl.java:87: error: annotations are not supported in -source 1.3
[javac]     @Override
[javac]      ^
[javac]   (use -source 5 or higher to enable annotations)

And I get 100 such errors. It points to a different location every time but the error is the same. It says either annotations are not supported or generics are not supported.

Changing the source code is not an option for me so the source code doesn't matter here, since it already works fine from eclipse, which is suggested in many other StackOverflow answers.

Also, I tried checking how to user -source 5 or higher using Ant, but I found nothing.

How can I fix this?

Here's my build.xml file.

Thanks!

Upvotes: 0

Views: 241

Answers (1)

rtaft
rtaft

Reputation: 2348

<property name="javacSource" value="1.3"/> The error is pretty self explanatory. You are using syntax that was introduced in Java 1.5, but telling ant to use 1.3. Change the javacSource value in your build.xml to 1.5, remove the line altogether, or make the code compliant with 1.3.

Upvotes: 2

Related Questions