2012-07-17 2 views
4

cible Pour les structures de fourmis construire plus grandes et des projets assez complexes, je voudrais mettre en retrait la sortie de l'information (écho) en fonction comme appel profondeur cible:Ant: sortie écho de retrait en fonction de l'appel profondeur

[echo] running build from project/build.xml 
    [echo] running build from project/sub1/build.xml 
    [echo] running build from project/sub2/build.xml 
     [echo] running build from project/sub2/sub21/build.xml 
     [echo] running build from project/sub2/sub22/build.xml 
    [echo] running build from project/sub3/build.xml 

BUILD SUCCESSFUL 
Total time: x seconds 

Y a-t-il une telle modification, propriété de journalisation ou autre? ... peut-être les auditeurs xslt/ou d'un événement? Css

n'est pas le Indentation point mais de voir la hiérarchie des appels: éviter la recherche dans les fichiers build.xml ou en ajoutant propre fonction d'écho dans toutes les cibles et macrodefs.

+0

Ant décide tha t .... Vous pouvez avoir à vérifier le code source de fourmi ... – coolcfan

+0

Je voudrais éviter de comprendre l'analyse par la fourmi et changer le code, mais utiliser des mécanismes standard. – thoku

+0

thoku, je voudrais faire quelque chose de similaire. Avez-vous trouvé un outil/paramètre qui nous aidera? – user674669

Répondre

1

Voir https://ant.apache.org/manual/listeners.html

Le XmlLogger semble qu'il y ait utile, si un peu trop bavard - vous pouvez extraire la hiérarchie d'appel (avec echos aussi) avec un peu de script:

ant -logger org.apache. tools.ant.XmlLogger construire

avait également un certain succès avec log4j:

ant -listener org.apache.tools.ant.listener.Log4jListener -Lib ..../journalisation log4j-1.2.17/dist/lib/-lib. construire

Pour cela, je mets un fichier log4j.properties dans le répertoire courant, en utilisant le contenu échantillons au premier lien ci-dessus. Cela produit un build.log avec le contenu suivant:

[  0] Project : Build started. 
[ 908] Taskdef : Could not load definitions from resource checkstyletask.properties. It could not be found. 
[ 995] Target : Target "build" started. 
[ 4312]  Echo : com.ohmy: ivy.sorted.modules=thirdparty-plugins#com.sun.jaxb 
[ 4529] Taskdef : Could not load definitions from resource checkstyletask.properties. It could not be found. 
[ 4588] Target : Target "build_empty_unittests_jar_to_fulfill_dependencies" started. 
[ 4590] Target : Target "build_empty_unittests_jar_to_fulfill_dependencies" finished. 
[ 4591] Target : Target "build_nodeps" started. 
[ 4591]  Echo : Calling target 'build' for module com.sun.jaxb 
[ 4770] Taskdef : Could not load definitions from resource checkstyletask.properties. It could not be found. 
[ 4846] Target : Target "check_module_targets_file_exists" started. 
[ 4847] Target : Target "check_module_targets_file_exists" finished. 
[ 4847] Target : Target "check_module_target_exists" started. 
[ 4847] Target : Target "check_module_target_exists" finished. 

Maintenant, je viens dans ce petit tuyau ruby ​​une doublure pour pirater indentera:

ruby -pe 'BEGIN {$i=0};$i-=1 if /finished\.$/;print " " * $i;$i+=1 if /started\.$/' build.log 

qui donne

[  0] Project : Build started. 
[ 908] Taskdef : Could not load definitions from resource checkstyletask.properties. It could not be found. 
[ 995] Target : Target "build" started. 
    [ 4312]  Echo : com.ohmy: ivy.sorted.modules=thirdparty-plugins#com.sun.jaxb, com.ohmy 
    [ 4529] Taskdef : Could not load definitions from resource checkstyletask.properties. It could not be found. 
    [ 4588] Target : Target "build_empty_unittests_jar_to_fulfill_dependencies" started. 
    [ 4590] Target : Target "build_empty_unittests_jar_to_fulfill_dependencies" finished. 
    [ 4591] Target : Target "build_nodeps" started. 
    [ 4591]  Echo : Calling target 'build' for module com.sun.jaxb 
    [ 4770] Taskdef : Could not load definitions from resource checkstyletask.properties. It could not be found. 
    [ 4846] Target : Target "check_module_targets_file_exists" started. 
    [ 4847] Target : Target "check_module_targets_file_exists" finished. 
    [ 4847] Target : Target "check_module_target_exists" started. 
    [ 4847] Target : Target "check_module_target_exists" finished. 
    [ 4847] Target : Target "module_target" started. 
    [ 4847] Target : Target "module_target" finished. 
    [ 4847] Target : Target "default_target" started. 
    [ 4849] Target : Target "init" started. 
    [ 4850] Target : Target "check_module_ivy_file_uptodate" started. 
    [ 4858] Target : Target "check_module_ivy_file_uptodate" finished. 
    [ 4858] Target : Target "create_module_ivy_file" started. 
    [ 4858] Target : Target "create_module_ivy_file" finished. 
    [ 4859] Target : Target "check_build_file_uptodate" started. 
    [ 4862] Target : Target "check_build_file_uptodate" finished. 
    [ 4864] Target : Target "generate_module_build_file" started. 
    [ 4864] Target : Target "generate_module_build_file" finished. 
    [ 4865] Target : Target "update_module_build_file" started. 
     [ 4866] Target : Target "check_module_name" started. 
     [ 4868] Target : Target "check_module_name" finished. 
     [ 4869] Target : Target "check_manifest_version" started. 
     [ 4869]  Echo : Calling target 'check_manifest' for module com.sun.jaxb 
     [ 5041] Taskdef : Could not load definitions from resource checkstyletask.properties. It could not be found. 
     [ 5065] Target : Target "check_module_targets_file_exists" started. 
     [ 5065] Target : Target "check_module_targets_file_exists" finished. 
     [ 5065] Target : Target "check_module_target_exists" started. 
     [ 5065] Target : Target "check_module_target_exists" finished. 
     [ 5065] Target : Target "module_target" started. 
     [ 5065] Target : Target "module_target" finished. 
     [ 5066] Target : Target "default_target" started. 
     [ 5066] Target : Target "default_check_manifest" started. 
     [ 5067] Target : Target "default_check_manifest" finished. 
     [ 5067] Target : Target "default_target" finished. 
     [ 5067] Target : Target "module_specific_target" started. 
     [ 5067] Target : Target "module_specific_target" finished. 
     [ 5068] Target : Target "check_manifest_version" finished. 
    [ 5068] Target : Target "update_module_build_file" finished. 
    [ 5069] Target : Target "ivy_retrieve" started. 
     [ 5069]  Echo : Skipping 'ivy_retrieve' as everything is uptodate for com.sun.jaxb 
.... 

bien sûr, cela peut être affiné, mais il est assez bon pour moi en ce moment :)