PDA

View Full Version : Ant task to validate applicationContext.xml



amit
Aug 17th, 2004, 04:38 AM
Hi,

Any support on the Ant tasks doing validation of applicationContext.xml ?

Torsten Juergeleit
Aug 17th, 2004, 05:04 AM
Amit,

currently an ANT task which validates Spring beans config files is not planned.

But it can be done. All the code for the validation itself is already available in the core plugin. But this code leverages the project management stuff (config XML file ".springBeansProject") provided by the Eclipse plugin. The file and it's settings (list of config files and config sets) is maintained by the project properties dialog.

If anybody has the time to investigate further...

Regards,
Torsten

jbetancourt
Aug 17th, 2004, 11:54 AM
If by validate one means 'XML validation', then Ant should be able to do this easily (?) using the Spring DTD.

On my project I wrote an Ant target that validates an XML MVC definition file using XSD (I used BeanShell in Ant), so anything is possible.

J. Betancourt

Torsten Juergeleit
Aug 17th, 2004, 12:32 PM
If by validate one means 'XML validation', then Ant should be able to do this easily (?) using the Spring DTD.


Yes, DTD validation is the easy part.

Creating the entire BeanDefinitionRegistry from a single application context and validating it's (inner and outer) bean classes with their properties + constructor arguments + parent bean is the fun part. Doing this for a hierachy of application contexts (with additional checking for bean overrides) is more fun ;-).

Regards,
Torsten

Colin Sampaleanu
Aug 17th, 2004, 12:54 PM
I actually took a look at doing an ANT validator based on Torsten's code, essentially ripping out the Eclipse dependencies, which would not be very significant for that part of the codebase.

The problem is that at the time (about a month ago), the Spring-IDE code was (and I believe still is) behind the current Spring version, so I put this off until such a time as

a) the two are in sync, and
b) I have some time :-)

Regards,

amit
Aug 19th, 2004, 02:22 AM
Hi,

Rite now i was trying to do xmlvalidaion using spring dtd.
Following is the target i was using.

<target name="xmlvalidate" description="Generates a report of code convention violations.">
<xmlvalidate failonerror="yes" warn="yes">
<fileset dir="${web.dir}/WEB-INF" includes="applicationContext.xml"/>
<xmlcatalog>
<dtd
publicId="-//SPRING//DTD BEAN//EN"
location="http://www.springframework.org/dtd/spring-beans.dtd"/>
</xmlcatalog>
</xmlvalidate>
</target>

And the result is:

BUILD FAILED
file:E:/eclipse_workspace/windows_2.1_M4/<project>/build/build.xml:109: Could not validate document E:\eclipse_workspace\windows_2.1_M4\<project>\build\<project>\WEB-INF\applicationContext.xml

Any Idea wht could be the problem here? How could i get where is the problem or more verbose output ?

Regards,

amit
Aug 19th, 2004, 03:18 AM
Hi,

That worked when i changed the location to local directory.
Probably now shld have a look at the Eclipse IDE code

Thanks,

amit
Aug 19th, 2004, 05:29 AM
Hi,

That worked when i changed the location to local directory.
Probably now shld have a look at the Eclipse IDE code

Thanks,

rpark68
Dec 14th, 2004, 04:04 PM
I'm concerned about maintaining the 2 xml files as our system grows. If I rename classes or add dependencies for example, I can easily work the kinks out of the spring-test.xml, but is there a way for me to "validate" the production spring.xml without waiting for runtime exceptions?

And I'm referring to Torsten's more complex definition of validate here.

I haven't yet tried out the Eclipse plugin, so is that the way to go?

.rob.park.

hucmuc
Jun 21st, 2005, 12:50 PM
Is there any plan to support validation via ant?

dino

davison
Jun 21st, 2005, 02:23 PM
Still depends what you mean by validate :)

You could easily create a task to simply load the context files as a BeanFactory and verify no dependency errors for example. Alternatively use the beandoc ant task to documet/graph the context, though that would need manual validation by reading the output docs.

Regards,

hucmuc
Jun 22nd, 2005, 11:35 AM
Still depends what you mean by validate :)

You could easily create a task to simply load the context files as a BeanFactory and verify no dependency errors for example. Alternatively use the beandoc ant task to documet/graph the context, though that would need manual validation by reading the output docs.

Regards,

Just implement what the eclipse plug-in does. It would be nice if the actual validation logic was moved from the eclipse project into another project. THEN write tools on top of it (e.g. ant, eclipse, idea etc).

Dino