简体   繁体   English

在Eclipse中构建项目,但不是从终端/詹金斯中进行-使用Ant

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

I am using Ant to build my java project. 我正在使用Ant构建我的Java项目。 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 . 基本上,构建文件是在Eclipse中右键单击项目并选择plug-in tools > create Ant build file时创建的默认build.xml This builds the project with a couple of eclipse plugin dependencies and creates a folder with all the .class files. 这将使用几个eclipse插件依赖项来构建项目,并创建一个包含所有.class文件的文件夹。

When I run my default build.xml. 当我运行默认的build.xml. from eclipse, it's working fine. 从日食,它工作正常。 It creates the folder with .class files just like I want. 就像我想要的那样,它使用.class文件创建文件夹。

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. 我得到100个这样的错误。 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. 更改源代码对我来说不是一个选择,因此源代码在这里无关紧要,因为它已经可以从eclipse正常工作 ,这在许多其他StackOverflow答案中都建议使用。

Also, I tried checking how to user -source 5 or higher using Ant , but I found nothing. 另外,我尝试检查如何使用Ant来对用户使用source 5或更高版本 ,但是什么也没找到。

How can I fix this? 我怎样才能解决这个问题?

Here's my build.xml file. 这是我的build.xml文件。

Thanks! 谢谢!

<property name="javacSource" value="1.3"/> The error is pretty self explanatory. <property name="javacSource" value="1.3"/>该错误很<property name="javacSource" value="1.3"/>解释。 You are using syntax that was introduced in Java 1.5, but telling ant to use 1.3. 您正在使用Java 1.5中引入的语法,但要告诉ant使用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. 将build.xml中的javacSource值更改为1.5,完全删除该行,或使代码与1.3兼容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM