Uploaded image for project: 'Maven Project Web Site'
  1. Maven Project Web Site
  2. MNGSITE-97

Add enabled phases from current pom.xml for auto completion using BASH

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Auto Closed
    • None

    Description

      I provide a new feature which get all enabled phases from the current pom.xml. I don't read the parent pom or settings.xml because it's difficult to know which parent pom is used, and the current configuration (profile activated, ...). And then it's a small tool, my goal was not corrupting the performance of the bash

      #!/bin/bash
      
      _m2_make_goals()
      {
        plugin=$1
        mojos=$2
        for mojo in $mojos
        do
          export goals="$goals $plugin:$mojo"
        done
      }
      
      _m2_add_phases()
      {
        for phase in `grep -i '<phase>' pom.xml | sed 's/<phase>\(.*\)<\/phase>/\1/i'`
        do
          export goals="$goals $phase"
        done
      }
      
      _m2_complete()
      {
        local cur goals
      
        COMPREPLY=()
        cur=${COMP_WORDS[COMP_CWORD]}
        if [ -f pom.xml ]; then
        	goals='clean compile test install package deploy site help:effective-pom dependency:tree'
      	goals=$goals _m2_make_goals "eclipse" "eclipse"
      	goals=$goals _m2_add_phases
        fi
        COMPREPLY=($(compgen -W "${goals}" ${cur} | sed 's/\\\\//g') )
      }
      
      complete -F _m2_complete -o filenames mvn

      Attachments

        Activity

          People

            Unassigned Unassigned
            revo Sylvain MOUQUET
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: