Brian E. Fox wrote:
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.

The code below is bad. The system path is NOT set in java.library.path - this
is for dll/so files (jni stuff).

Assuming maven is in the path when no env var can be found is ok though,
i'm not sure why the maven home is even needed.

Btw, i already updated both the invoker and the verifier to also
check the M2_HOME env var, which should fix things on some installations.

Back to the code below. If it's changed to 'path = System.getenv( "PATH" )
it may work.

However, if you look at the 'mvn' script, it sets the maven.home variable:

exec "$JAVACMD" \
 $MAVEN_OPTS \
 -classpath "${M2_HOME}"/lib/maven-embedder-*.jar \
 "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
 "-Dmaven.home=${M2_HOME}"  \
 ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS

so ideally the maven.home property should just work. I don't know why it 
doesn't,
but maybe we should look into that as maven just provides this information
since version 2.0.

-- Kenney


        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;

                }

            }

        }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to