Ignore Ant warning with comment

I have a very simple Ant example here that causes Eclipse to report a warning:

<ivy:cachepath pathid="path.pmd" organisation="pmd" module="pmd" revision="4.3" conf="default" inline="true" /> <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="path.pmd" /> 

Reported Issue:

 Description Resource Path Location Type Reference path.pmd not found. build.xml /MyPrj line 20 Ant Buildfile Problem 

Now itโ€™s completely clear what is happening here. Ant does not see path.pmd defined in the ivy caching task and generates a warning. Now I would like to ignore this warning. However, I do not want to ignore the warning using the Ant settings in Eclipse. I know this is easy, but it also means that one day, when I really have the missing link, I will not receive a warning.

Does Ant ignore comment style? Like in PMD, when you can use // NOPMD to ignore any warning on the specified line. If there is, please enlighten me :)

If not, is there another way to remove this warning from this particular line in the Ant build file.

Any help would be appreciated.

+4
source share
3 answers

I think preference is the key, even if you don't want it, check it out, you might find something else in a few links:

How to tell Eclipse to ignore errors in Ant build.xml?

I found this on the nodes:

"Another workaround (less drastic than disabling all checks / problem reports): go to the Window-> preferences โ†’ Ant โ†’ Problems tab. Add" build.xml "to the ignore list ..."

+1
source

The answer to your question is no.

However, you can use properties to enable / disable goals as follows:

 <target name="resolve-ivy" if="use.ivy"> <ivy:cachepath pathid="path.pmd".... </target> <target name="resolve-ant" unless="use.ivy"> <path id="path.pmd"> <pathelement location="/path/to/pmd/jar/pmd.jar"/> </path> </target> <target name="create-tasks" depends="resolve-ivy,resolve-ant"> <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="path.pmd" /> </target> 

So, if the "use.ivy" property is set, your assembly will use ivy to load the dependencies of the assembly.

I have a number of observations ....

Is this warning really ignorant?

Why are you using two mechanisms to control your assembly class paths?

If you are using Eclipse, perhaps investigate the use of the Eclipse plugin and external ivy.xml to track dependencies between projects. This approach will synchronize the class paths used by both ANT and Eclipse.

PMD Modules at Maven Central

ivy pulls the wrong module from Maven Central. Latest version of PMD 5.0.1:

I would suggest the following alternative configuration of ivy tasks

 <ivy:cachepath pathid="path.pmd"> <dependency org="net.sourceforge.pmd" name="pmd" rev="5.0.1" conf="default"/> </ivy:cachepath> 

NOTE:

Did you consider Sonar?

Perhaps an easier way to enable PMD is to use the Sonar ANT task , which will also analyze your code using Findbugs and Checkstyle.

This task can also be restored using ivy:

 <ivy:cachepath pathid="path.sonar"> <dependency org="org.codehaus.sonar-plugins" name="sonar-ant-task" rev="2.0" conf="conf"/> </ivy:cachepath> 
+1
source

Go to the Window-> Settings โ†’ Ant โ†’ Problems tab. Add "build.xml" to the ignore list. This should solve your problem.

0
source

All Articles