Maven Project Web Site
  1. Maven Project Web Site
  2. MNGSITE-97

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

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Labels:
      None
    • Number of attachments :
      0

      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

        Activity

        Hide
        Brett Porter added a comment -

        how does this differ from MNG-3928 ?

        Show
        Brett Porter added a comment - how does this differ from MNG-3928 ?
        Hide
        Sylvain MOUQUET added a comment - - edited

        in my script, I select all goals like :
        mvn pre-integration-test
        mvn install

        (i select all phase of the pom, but i can select all default lifecycle from http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html)

        in MNG-3928, it provides generic goals for maven plugins (selected from http://repo1.maven.org/maven2/org/apache/maven/plugins/) like :
        mvn help:effective-pom

        i think it will be better to provide the 2 choice because my tool is specific of the current pom configuration and the MNG-3928 provides generic tools.

        Show
        Sylvain MOUQUET added a comment - - edited in my script, I select all goals like : mvn pre-integration-test mvn install (i select all phase of the pom, but i can select all default lifecycle from http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html ) in MNG-3928 , it provides generic goals for maven plugins (selected from http://repo1.maven.org/maven2/org/apache/maven/plugins/ ) like : mvn help:effective-pom i think it will be better to provide the 2 choice because my tool is specific of the current pom configuration and the MNG-3928 provides generic tools.

          People

          • Assignee:
            Unassigned
            Reporter:
            Sylvain MOUQUET
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: