Skip Eclipse validation of build.xml

2020-05-28 10:28发布

I've followed the steps given in the Android Developer Blog to generate a build.xml for building releases for an Android Application. I need to do a custom compiling so I have overwritten the target compile of the ant_rules_r3.xml as it is said in the generated build.xml.

 <target name="compile" depends="-resource-src, -aidl, -pre-compile" ...

The script works fine and generates the apk, but the problem is that Eclipse shows an error because it cannot find targets -resource-src, -aidl and -pre-compile (which are loaded when executing the script but are not really present on the build.xml). As there are these errors I cannot work with the project in Eclipse.

How can I skip the validation of this single file in Eclipse?

5条回答
戒情不戒烟
2楼-- · 2020-05-28 10:31

Kukudas's solution to "Ignore all buildfile problems" does solve the root problem.

However, Eclipse will still detect the buidl.xml as broken and will not allow Ant Builders to call the file. In fact, Eclipse will silently ignore such build steps in your project as if weren't there.

查看更多
Anthone
3楼-- · 2020-05-28 10:42

I do not know if you can do this for a single file but i think you can disable the validation within the eclipse preferences under Validation.

查看更多
够拽才男人
4楼-- · 2020-05-28 10:51

I found 2 solutions that work for me :

1 - The solution from kukudas above :

How about this: under preferences ant -> editor in the tab Problems "Ignore all buildfile problems" ? You can set there a specific file too if i'm not mistaken. – kukudas Oct 15 '10 at 10:28

While it works, this solution is workspace specific and can be quite tedious if a user wants to keep Ant validation for a few files but ignore a large number of files.

2 - Eclipse seems to validate ant files only when they are opened in an editor. Therefore, another solution involves never opening ant files that shouldn't be validated using eclipse. I managed to get rid of warnings by doing a file backup-delete-restore.

Ideally, ant validation should be done like all other XML validation so it may be configured at project level.

查看更多
Viruses.
5楼-- · 2020-05-28 10:52

I have figured out a much better solution to the problem of eclipse not finding build targets from the imported/included projects. First of all, upgrade to the r14 sdk. Revision 14 uses only a build.xml file from the ${sdk.dir}/tools/ant directory

At the bottom of the build.xml file within your own project, you'll see an import statement that looks like this:

<import file="${sdk.dir}/tools/ant/build.xml"/>

Change this statement to

<import file="${sdk.dir}/tools/ant/build.xml" as="androidbuild" />

Then from your project, you can reference those target with

<target name="compile" depends="androidbuild.-resource-src, androidbuild.-aidl, androidbuild.-pre-compile" />

Also note that now they have pre-compile/pre-build tasks that will be called before compiling. (checkout the full build.xml to see exactly when they are called). You can use these as hooks to do some work before compiling without overriding the original tasks.

查看更多
Anthone
6楼-- · 2020-05-28 10:57

Another workaround (less drastic than disable all validation/problem reporting): Go to Window->preferences->Ant->Problems tab. Add "build.xml" to the ignore list...

查看更多
登录 后发表回答