I recently had some trouble with the invoker getting a good maven.home
value from the mvn script. I came across this code in the eclipse tests
that seems to work pretty well. Is there any objection to moving this
code into the invoker in a fall back scenario? (ie if the executable
can't be found via the normal means, try this) The code is basically
walking through the path to find mvn...in most cases a user will have
mvn on their path so it seems like a good assumption.

 

        String mavenHome = System.getProperty( "maven.home" );

 

        // maven.home is set by surefire when the test is run with
maven, but better make the test run in IDEs without

        // the need of additional properties

        if ( mavenHome == null )

        {

            String path = System.getProperty( "java.library.path" );

            String[] paths = StringUtils.split( path,
System.getProperty( "path.separator" ) );

            for ( int j = 0; j < paths.length; j++ )

            {

                String pt = paths[j];

                if ( new File( pt, "mvn" ).exists() )

                {

                    System.setProperty( "maven.home", new File( pt
).getAbsoluteFile().getParent() );

                    break;

                }

 

            }

        }

Reply via email to