Barry,

it seems to create an issue :
http://ci.sonatype.org/job/plugins-CI-with-maven-2.0.x/org.apache.maven.plugins$maven-eclipse-plugin/439/testReport/

Cheers

arnaud

On Wed, Sep 17, 2008 at 8:46 AM, <[EMAIL PROTECTED]> wrote:

> Author: baerrach
> Date: Tue Sep 16 23:46:57 2008
> New Revision: 696176
>
> URL: http://svn.apache.org/viewvc?rev=696176&view=rev
> Log:
> [MECLIPSE-261] fixing IdeUtils.toRelativeAndFixSeparator to support Windows
> Root directories as basedir
>
> The the canonical form of a windows root dir ends in a slash.
> Whereas the canonical form of any other directory does not.
>
> Modified:
>
>  
> maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java
>
>  
> maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/ide/IdeUtilsTest.java
>
> Modified:
> maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java
> URL:
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java?rev=696176&r1=696175&r2=696176&view=diff
>
> ==============================================================================
> ---
> maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java
> (original)
> +++
> maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java
> Tue Sep 16 23:46:57 2008
> @@ -393,21 +393,29 @@
>             fileToAdd = new File( basedir, fileToAdd.getPath() );
>         }
>
> -        String basedirpath;
> -        String absolutePath;
> +        String basedirPath = getCanonicalPath( basedir );
> +        String absolutePath = getCanonicalPath( fileToAdd );
>
> -        basedirpath = getCanonicalPath( basedir );
> -        absolutePath = getCanonicalPath( fileToAdd );
> +        String relative = null;
>
> -        String relative;
> -
> -        if ( absolutePath.equals( basedirpath ) )
> +        if ( absolutePath.equals( basedirPath ) )
>         {
>             relative = "."; //$NON-NLS-1$
>         }
> -        else if ( absolutePath.startsWith( basedirpath ) )
> +        else if ( absolutePath.startsWith( basedirPath ) )
>         {
> -            relative = absolutePath.substring( basedirpath.length() + 1 );
> +            // MECLIPSE-261
> +            // The canonical form of a windows root dir ends in a slash,
> whereas the canonical form of any other file
> +            // does not.
> +            // The absolutePath is assumed to be: basedirPath + Separator
> + fileToAdd
> +            // In the case of a windows root directory the Separator is
> missing since it is contained within
> +            // basedirPath.
> +            int length = basedirPath.length();
> +            if ( !basedirPath.endsWith( "\\" ) )
> +            {
> +                length++;
> +            }
> +            relative = absolutePath.substring( length );
>         }
>         else
>         {
> @@ -426,8 +434,7 @@
>     }
>
>     /**
> -     * Convert the provided filename from a Windows separator \\ to a
> unix/java
> -     * separator /
> +     * Convert the provided filename from a Windows separator \\ to a
> unix/java separator /
>      *
>      * @param filename file name to fix separator
>      * @return filename with all \\ replaced with /
>
> Modified:
> maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/ide/IdeUtilsTest.java
> URL:
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/ide/IdeUtilsTest.java?rev=696176&r1=696175&r2=696176&view=diff
>
> ==============================================================================
> ---
> maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/ide/IdeUtilsTest.java
> (original)
> +++
> maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/ide/IdeUtilsTest.java
> Tue Sep 16 23:46:57 2008
> @@ -51,10 +51,10 @@
>         name = IdeUtils.getProjectName(
> IdeUtils.PROJECT_NAME_WITH_VERSION_TEMPLATE, dependency );
>         assertEquals( dependency.getArtifactId() + "-" +
> dependency.getVersion(), name );
>     }
> -
> +
>     /**
> -     * When the file to add is on a different drive and an absolute path
> expect
> -     * that the returned value is the same as the file to add (but with
> /s)
> +     * When the file to add is on a different drive and an absolute path
> expect that the returned value is the same as
> +     * the file to add (but with /s)
>      *
>      * @throws Exception
>      */
> @@ -71,8 +71,8 @@
>     }
>
>     /**
> -     * When the file to add is a relative file then expect the result to
> be
> -     * relative to the basedir (not whatever the current processes basedir
> is set to)
> +     * When the file to add is a relative file then expect the result to
> be relative to the basedir (not whatever the
> +     * current processes basedir is set to)
>      *
>      * @throws Exception
>      */
> @@ -86,6 +86,29 @@
>         String expected = "target/main-output";
>
>         assertEquals( actual, expected );
> -    }
> +    }
> +
> +    /**
> +     * See MECLIPSE-261.
> +     * <p>
> +     * When the base dir is a windows root directory the assumption that
> the full path to fileToAdd is basedir + "/" +
> +     * fileToAdd is incorrect.
> +     * <p>
> +     * As the canonical form of a windows root dir ends in a slash,
> whereas the canonical form of any other file does
> +     * not.
> +     *
> +     * @throws Exception
> +     */
> +    public void testToRelativeAndFixSeparator_MECLIPSE_261()
> +        throws Exception
> +    {
> +        File basedir = new File( "Z:" );
> +        File fileToAdd = new File( "target/main-output" );
> +
> +        String actual = IdeUtils.toRelativeAndFixSeparator( basedir,
> fileToAdd, false );
> +        String expected = "target/main-output";
> +
> +        assertEquals( actual, expected );
> +    }
>
>  }
>
>
>


-- 
..........................................................
Arnaud HERITIER
..........................................................
OCTO Technology - aheritier AT octo DOT com
www.octo.com | blog.octo.com
..........................................................
ASF - aheritier AT apache DOT org
www.apache.org | maven.apache.org
...........................................................

Reply via email to