mcconnell 2003/10/18 17:02:03
Modified: merlin/kernel/unit/src/java/org/apache/avalon/merlin/unit
AbstractMerlinTestCase.java
Log:
Update the test case to correctly resolve the maven repository (bug reported by
Alexis Agahi).
Revision Changes Path
1.12 +51 -13
avalon/merlin/kernel/unit/src/java/org/apache/avalon/merlin/unit/AbstractMerlinTestCase.java
Index: AbstractMerlinTestCase.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/kernel/unit/src/java/org/apache/avalon/merlin/unit/AbstractMerlinTestCase.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- AbstractMerlinTestCase.java 17 Oct 2003 22:05:48 -0000 1.11
+++ AbstractMerlinTestCase.java 19 Oct 2003 00:02:02 -0000 1.12
@@ -390,35 +390,73 @@
private File getMavenRepositoryDirectory()
{
//
- // get the ${maven.home.local} system property - this may
- // be null in which case to fallback to ${maven.home}
+ // get ${maven.home.local} system property - this may
+ // be null in which case to fallback to ${user.home}/.maven
//
- final String system = System.getProperty( "maven.home.local" );
- if( system != null )
+ final String local = System.getProperty( "maven.home.local" );
+ if( local != null )
{
- return new File( new File( system ), "repository" );
+ try
+ {
+ File sys = getDirectory( new File( local ) );
+ return getDirectory( new File( sys, "repository" ) );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to resolve repository from ${maven.home.local}.";
+ throw new UnitRuntimeException( error, e );
+ }
}
else
{
//
// try to establish the repository relative to
- // ${maven.home}/repository
+ // ${user.home}/.maven/repository
//
- final String home = System.getProperty( "maven.home" );
- if( home != null )
+ final String userHome = System.getProperty( "user.home" );
+ if( userHome != null )
{
- return new File( new File( home ), "repository" );
+ try
+ {
+ File home = getDirectory( new File( userHome ) );
+ File maven = getDirectory( new File( home, ".maven" ) );
+ return getDirectory( new File( maven, "repository" ) );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to resolve the maven repository relative to
${user.home}.";
+ throw new UnitRuntimeException( error, e );
+ }
}
else
{
- // probaly unrealistic - but if we get here then there is a lot
- // of stuff missing - return the total fallback maven repository
+ //
+ // should never happen
+ //
- File user = new File( System.getProperty( "user.dir" ) );
- return new File( user, ".maven/repository" );
+ final String error =
+ "Unable to resolve maven repository.";
+ throw new IllegalStateException( error );
}
+ }
+ }
+
+ private File getDirectory( File file )
+ {
+ if( file == null ) throw new NullPointerException( "file" );
+ if( file.exists() )
+ {
+ return file;
+ }
+ else
+ {
+ final String error =
+ "Directory [" + file + "] does not exist.";
+ throw new IllegalArgumentException( error );
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]