A Bash parser for Maven project layout.

There are two points to this page.

  • Next to Python, Bash/sh is the flamethrower of the *nix world.
  • Projects built using Maven can get ridiculously complex, but if the authors are mindful, can be organized enough so that you can garner information about its structure with just a bit of file munging (no compiling code at all).

This is a proof of concept of the second point above (and lots of the first).

What it does

Basically, say we have this following directory structure:

     |     /leaf2

Say root, node1 and node2 have files, called pom.xml in them that describe their name and what they do.

  • in /root:
    <description>This is the root</description>
  • in nodes:
    <description>This is node n</description>

So going back to the directory tree, we take that, and turn it into the following, wiki-friendly things:

  • the first is an indented list:
     * root
     ** node1
     *** leaf1
     *** leaf2
     ** node2
     *** leaf3
     *** leaf4
  • and the second and third are bulleted lists of the names and descriptions
     * root-of-project
     * node-1-of-project
     * node-2-of-project
     * This is the root
     * This is node 1
     * This is node 2

This is also considerably easier to look at than going through each directory and figuring it out/formatting something manually.

The script

The script that does this is attached below. The rest of this page points out the various parts of the script, not because it is great, but it could sort of be a primer of some of the messier things that can be done with Bash.

Last modified 10 years ago Last modified on Nov 25, 2014, 3:45:09 AM

Attachments (1)

  • tree-fmt (3.7 KB ) - added by akoshibe 10 years ago.

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.