envoie de mail avec ant depuis java
bonjour,
j'ai créé une target ant qui concatènent des fichiers csv et puis qui envoie ce fichiez à une adresse mail ce code fonctionne très bien avec la console ant , après cela j'ai créé un main qui fait appelle à une console ant depuis java pour qu'il éxécute cette target
sauf que quand je lance le main il me fait cette erreur-ci
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Exception in thread "main" /home/test/8.0.0.0/next7.portail.ejb3/build-fusion-errors.xml:32: The <mail> type doesn't support the nested "attachments" element.
at org.apache.tools.ant.IntrospectionHelper.throwNotSupported(IntrospectionHelper.java:590)
at org.apache.tools.ant.IntrospectionHelper.getNestedCreator(IntrospectionHelper.java:670)
at org.apache.tools.ant.IntrospectionHelper.createElement(IntrospectionHelper.java:699)
at org.apache.tools.ant.helper.ProjectHelperImpl$NestedElementHandler.init(ProjectHelperImpl.java:875)
at org.apache.tools.ant.helper.ProjectHelperImpl$TaskHandler.startElement(ProjectHelperImpl.java:785)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.tools.ant.helper.ProjectHelperImpl.parse(ProjectHelperImpl.java:133)
at be.thread.TestTimer.main(TestTimer.java:33) |
voila la target
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| <target name="fusion-project">
<concat destfile="junit/csv/all-projet.csv" force="yes">
<fileset file="title-projet.csv" />
<fileset dir="../">
<filename name="**/junit/csv/projet.csv" />
</fileset>
</concat>
<antcall target="sendMailProject" />
</target>
<target name="sendMailProject">
<mail mailhost="ss.yyy.uu" mailport="25" subject="liste des projets" charset="utf-8">
<from address="xxx@yy" />
<to address="zzz@yyy" />
<message>
Monsieur,
Vous trouverez en pièce jointe le fichier comprenant les statistiques
des différents projets en cour
</message>
<attachments>
<fileset dir="${basedir}/junit/csv/" id="id">
<include name="all-projet.csv" />
</fileset>
</attachments>
</mail>
</target>
</project> |
code du main
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| System.out.println("création d'un projet ant");
Project ant = new Project();
System.out.println("création de ProjetHelper");
ProjectHelper helper = new ProjectHelperImpl();
System.out.println(helper.toString());
// ajout d'un écouteur pour voir les événements générés par ANT
org.apache.tools.ant.DefaultLogger log = new org.apache.tools.ant.DefaultLogger();
log.setErrorPrintStream(System.err);
log.setOutputPrintStream(System.out);
log.setMessageOutputLevel(Project.MSG_INFO);
ant.addBuildListener(log);
// Inistialisation de ANT
System.out.println("code ant" + ant.toString());
System.out.println("initialisation de ant");
ant.init();
helper.parse(ant, new File("build-fusion-errors.xml"));
ant.executeTarget("fusion-errors");
System.out.println("fin du main"); |
je précise que j'utilise eclipse europa, ant 1.7
merci d'avance pour votre aide