You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2018/06/30 18:53:33 UTC

[maven-jxr] branch master updated: Replace File/String with Path where possible

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-jxr.git


The following commit(s) were added to refs/heads/master by this push:
     new 391c4e9  Replace File/String with Path where possible
391c4e9 is described below

commit 391c4e983f0427d2a6681575d343e8d4395fa6a3
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Jun 30 20:53:25 2018 +0200

    Replace File/String with Path where possible
---
 .../apache/maven/plugin/jxr/AbstractJxrReport.java |  22 ++--
 .../org/apache/maven/jxr/DirectoryIndexer.java     |  26 ++--
 .../src/main/java/org/apache/maven/jxr/JXR.java    | 134 +++------------------
 .../org/apache/maven/jxr/JavaCodeTransform.java    |  95 +++------------
 .../org/apache/maven/jxr/IncludeExcludeTest.java   |  20 +--
 .../apache/maven/jxr/JavaCodeTransformTest.java    |  25 ++--
 .../java/org/apache/maven/jxr/JxrBeanTest.java     |   5 +-
 7 files changed, 91 insertions(+), 236 deletions(-)

diff --git a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java
index 199e15a..2ec3b01 100644
--- a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java
+++ b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java
@@ -22,6 +22,8 @@ package org.apache.maven.plugin.jxr;
 import java.io.File;
 import java.io.IOException;
 import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collection;
@@ -248,7 +250,7 @@ public abstract class AbstractJxrReport
         throws IOException, JxrException
     {
         JXR jxr = new JXR();
-        jxr.setDest( destinationDirectory );
+        jxr.setDest( Paths.get( destinationDirectory ) );
         if ( StringUtils.isEmpty( inputEncoding ) )
         {
             String platformEncoding = System.getProperty( "file.encoding" );
@@ -525,10 +527,10 @@ public abstract class AbstractJxrReport
     /**
      * @return a String that contains the location of the javadocs
      */
-    private String getJavadocLocation()
+    private Path getJavadocLocation()
         throws IOException
     {
-        String location = null;
+        Path location = null;
         if ( linkJavadoc )
         {
             // We don't need to do the whole translation thing like normal, because JXR does it internally.
@@ -536,7 +538,7 @@ public abstract class AbstractJxrReport
             if ( getJavadocDir().exists() )
             {
                 // XRef was already generated by manual execution of a lifecycle binding
-                location = getJavadocDir().getAbsolutePath();
+                location = getJavadocDir().toPath().toAbsolutePath();
             }
             else
             {
@@ -553,12 +555,11 @@ public abstract class AbstractJxrReport
 
                     if ( isAggregate() && javadocAggregate )
                     {
-                        File outputDirectory = new File( stagingDirectory, structureProject );
-                        location = outputDirectory + "/" + javadocDestDir;
+                        location = Paths.get( stagingDirectory, structureProject, javadocDestDir );
                     }
                     if ( !isAggregate() && javadocAggregate )
                     {
-                        location = stagingDirectory + "/" + javadocDestDir;
+                        location = Paths.get( stagingDirectory, javadocDestDir );
 
                         String hierarchy = project.getName();
 
@@ -568,8 +569,7 @@ public abstract class AbstractJxrReport
                             hierarchy = parent.getName();
                             parent = parent.getParent();
                         }
-                        File outputDirectory = new File( stagingDirectory, hierarchy );
-                        location = outputDirectory + "/" + javadocDestDir;
+                        location = Paths.get( stagingDirectory, hierarchy, javadocDestDir );
                     }
                     if ( isAggregate() && !javadocAggregate )
                     {
@@ -578,12 +578,12 @@ public abstract class AbstractJxrReport
                     }
                     if ( !isAggregate() && !javadocAggregate )
                     {
-                        location = stagingDirectory + "/" + structureProject + "/" + javadocDestDir;
+                        location = Paths.get( stagingDirectory, structureProject, javadocDestDir );
                     }
                 }
                 else
                 {
-                    location = getJavadocDir().getAbsolutePath();
+                    location = getJavadocDir().toPath();
                 }
             }
 
diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/DirectoryIndexer.java b/maven-jxr/src/main/java/org/apache/maven/jxr/DirectoryIndexer.java
index 217a5cc..7628a59 100644
--- a/maven-jxr/src/main/java/org/apache/maven/jxr/DirectoryIndexer.java
+++ b/maven-jxr/src/main/java/org/apache/maven/jxr/DirectoryIndexer.java
@@ -19,27 +19,29 @@ package org.apache.maven.jxr;
  * under the License.
  */
 
-import org.apache.commons.io.IOUtils;
-import org.apache.maven.jxr.pacman.ClassType;
-import org.apache.maven.jxr.pacman.PackageManager;
-import org.apache.maven.jxr.pacman.PackageType;
-import org.apache.maven.jxr.log.VelocityLogger;
-import org.apache.maven.jxr.log.Log;
-import org.apache.oro.text.perl.Perl5Util;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.TreeMap;
 
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.jxr.log.Log;
+import org.apache.maven.jxr.log.VelocityLogger;
+import org.apache.maven.jxr.pacman.ClassType;
+import org.apache.maven.jxr.pacman.PackageManager;
+import org.apache.maven.jxr.pacman.PackageType;
+import org.apache.oro.text.perl.Perl5Util;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+
 /**
  * This class creates the navigational pages for jxr's cross-referenced source
  * files. The navigation is inspired by javadoc, so it should have a familiar feel.
@@ -259,7 +261,7 @@ public class DirectoryIndexer
      */
     private void setProperties( VelocityEngine engine, Log log )
     {
-        File templateDirFile = new File( getTemplateDir() );
+        Path templateDirFile = Paths.get( getTemplateDir() );
         if ( templateDirFile.isAbsolute() )
         {
             // the property has been overridden: need to use a FileResourceLoader
diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/JXR.java b/maven-jxr/src/main/java/org/apache/maven/jxr/JXR.java
index 9b8362b..5b06700 100644
--- a/maven-jxr/src/main/java/org/apache/maven/jxr/JXR.java
+++ b/maven-jxr/src/main/java/org/apache/maven/jxr/JXR.java
@@ -24,12 +24,9 @@ import org.apache.maven.jxr.log.Log;
 import org.apache.maven.jxr.pacman.FileManager;
 import org.apache.maven.jxr.pacman.PackageManager;
 
-import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 
@@ -54,7 +51,7 @@ public class JXR
     /**
      * Path to destination.
      */
-    private String dest = "";
+    private Path destDir;
 
     private Locale locale;
 
@@ -65,7 +62,7 @@ public class JXR
     /**
      * Relative path to javadocs, suitable for hyperlinking.
      */
-    private String javadocLinkDir;
+    private Path javadocLinkDir;
 
     /**
      * Handles taking .java files and changing them into html. "More than meets
@@ -115,15 +112,16 @@ public class JXR
 
         String[] files = ds.getIncludedFiles();
 
-        for ( int i = 0; i < files.length; ++i )
+        for ( String file : files )
         {
-            String src = sourceDir.resolve( files[i] ).toString();
+            Path sourceFile = sourceDir.resolve( file );
 
-            if ( isJavaFile( src ) )
+            if ( isJavaFile( sourceFile.toString() ) )
             {
-                transform( src, getDestination( sourceDir.toString(), src ), bottom );
+                String newFileName = file.replaceFirst( ".java$", ".html" );
+                
+                transform( sourceFile, this.destDir.resolve( newFileName ), bottom );
             }
-
         }
     }
 
@@ -150,21 +148,11 @@ public class JXR
     }
 
     /**
-     * Get the path to the destination files.
-     *
-     * @return The path to the destination files
-     */
-    public String getDest()
-    {
-        return this.dest;
-    }
-
-    /**
      * @param dest
      */
-    public void setDest( String dest )
+    public void setDest( Path dest )
     {
-        this.dest = dest;
+        this.destDir = dest;
     }
 
     /**
@@ -194,7 +182,7 @@ public class JXR
     /**
      * @param javadocLinkDir
      */
-    public void setJavadocLinkDir( String javadocLinkDir )
+    public void setJavadocLinkDir( Path javadocLinkDir )
     {
         // get a relative link to the javadocs
         this.javadocLinkDir = javadocLinkDir;
@@ -255,7 +243,7 @@ public class JXR
         }
 
         // once we have all the source files xref'd, create the index pages
-        DirectoryIndexer indexer = new DirectoryIndexer( pkgmgr, dest );
+        DirectoryIndexer indexer = new DirectoryIndexer( pkgmgr, destDir.toString() );
         indexer.setOutputEncoding( outputEncoding );
         indexer.setTemplateDir( templateDir );
         indexer.setWindowTitle( windowTitle );
@@ -267,57 +255,23 @@ public class JXR
     // ----------------------------------------------------------------------
     // private methods
     // ----------------------------------------------------------------------
-
-    /**
-     * Given a filename get the destination on the filesystem of where to store
-     * the to be generated HTML file. Pay attention to the package name.
-     *
-     * @param source
-     * @param filename
-     * @return A String with the store destination.
-     */
-    private String getDestination( String source, String filename )
-    {
-        //remove the source directory from the filename.
-
-        String dest = filename.substring( source.length(), filename.length() );
-
-        int start = 0;
-        int end = dest.indexOf( ".java" );
-
-        if ( end != -1 )
-        {
-            //remove the .java from the filename
-            dest = dest.substring( start, end );
-        }
-
-        //add the destination directory to the filename.
-        dest = this.getDest() + dest;
-
-        //add .html to the filename
-
-        dest = dest + ".html";
-
-        return dest;
-    }
-
     /**
      * Given a source file transform it into HTML and write it to the
      * destination (dest) file.
      *
      * @param source The java source file
-     * @param dest The directory to put the HTML into
+     * @param destDir The directory to put the HTML into
      * @param bottom The bottom footer text just as in the package pages
      * @throws IOException Thrown if the transform can't happen for some reason.
      */
-    private void transform( String source, String dest, String bottom )
+    private void transform( Path sourceFile, Path destFile, String bottom )
         throws IOException
     {
-        log.debug( source + " -> " + dest );
+        log.debug( sourceFile + " -> " + destFile );
 
         // get a relative link to the javadocs
-        String javadoc = javadocLinkDir != null ? getRelativeLink( dest, javadocLinkDir ) : null;
-        transformer.transform( source, dest, locale, inputEncoding, outputEncoding, javadoc,
+        Path javadoc = javadocLinkDir != null ? getRelativeLink( destFile.getParent(), javadocLinkDir ) : null;
+        transformer.transform( sourceFile, destFile, locale, inputEncoding, outputEncoding, javadoc,
             this.revision, bottom );
     }
 
@@ -335,60 +289,10 @@ public class JXR
      * @return a String of format <code>"../../schmoo/"</code>
      * @throws java.io.IOException If a problem is encountered while navigating through the directories.
      */
-    private static String getRelativeLink( String fromDir, String toDir )
+    private static Path getRelativeLink( Path fromDir, Path toDir )
         throws IOException
     {
-        StringBuilder toLink = new StringBuilder();   // up from fromDir
-        StringBuilder fromLink = new StringBuilder(); // down into toDir
-
-        // create a List of toDir's parent directories
-        List<File> parents = new LinkedList<File>();
-        File f = new File( toDir );
-        f = f.getCanonicalFile();
-        while ( f != null )
-        {
-            parents.add( f );
-            f = f.getParentFile();
-        }
-
-        // walk up fromDir to find the common parent
-        f = new File( fromDir );
-        if ( !f.isDirectory() )
-        {
-            // Passed in a fromDir with a filename on the end - strip it
-            f = f.getParentFile();
-        }
-        f = f.getCanonicalFile();
-        f = f.getParentFile();
-        boolean found = false;
-        while ( f != null && !found )
-        {
-            for ( int i = 0; i < parents.size(); ++i )
-            {
-                File parent = parents.get( i );
-                if ( f.equals( parent ) )
-                {
-                    // when we find the common parent, add the subdirectories
-                    // down to toDir itself
-                    for ( int j = 0; j < i; ++j )
-                    {
-                        File p = parents.get( j );
-                        toLink.insert( 0, p.getName() + '/' );
-                    }
-                    found = true;
-                    break;
-                }
-            }
-            f = f.getParentFile();
-            fromLink.append( "../" );
-        }
-
-        if ( !found )
-        {
-            throw new FileNotFoundException( fromDir + " and " + toDir + " have no common parent." );
-        }
-
-        return fromLink.append( toLink.toString() ).toString();
+        return fromDir.relativize( toDir );
     }
 
     public void setExcludes( String[] excludes )
diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java b/maven-jxr/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java
index 5b900dc..e4b9004 100644
--- a/maven-jxr/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java
+++ b/maven-jxr/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java
@@ -56,7 +56,6 @@ import java.io.Serializable;
 import java.io.Writer;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.List;
@@ -189,21 +188,6 @@ public class JavaCodeTransform
     private String revision = null;
 
     /**
-     * The currently being transformed source file
-     */
-    private String sourcefile = null;
-
-    /**
-     * The currently being written destination file
-     */
-    private String destfile = null;
-
-    /**
-     * The virtual source directory that is being read from: <code>src/java</code>
-     */
-    private String sourcedir = null;
-
-    /**
      * The input encoding
      */
     private String inputEncoding = null;
@@ -221,7 +205,7 @@ public class JavaCodeTransform
     /**
      * Relative path to javadocs, suitable for hyperlinking
      */
-    private String javadocLinkDir;
+    private Path javadocLinkDir;
 
     /**
      * Package Manager for this project.
@@ -362,7 +346,7 @@ public class JavaCodeTransform
      * @throws IOException
      */
     public final void transform( Reader sourceReader, Writer destWriter, Locale locale, String inputEncoding,
-                                 String outputEncoding, String javadocLinkDir, String revision, String bottom )
+                                 String outputEncoding, Path javadocLinkDir, String revision, String bottom )
         throws IOException
     {
         this.locale = locale;
@@ -411,17 +395,14 @@ public class JavaCodeTransform
      * @param bottom TODO
      * @throws IOException
      */
-    public final void transform( String sourcefile, String destfile, Locale locale, String inputEncoding,
-                                 String outputEncoding, String javadocLinkDir, String revision, String bottom )
+    public final void transform( Path sourcefile, Path destfile, Locale locale, String inputEncoding,
+                                 String outputEncoding, Path javadocLinkDir, String revision, String bottom )
         throws IOException
     {
-        this.setCurrentFilename( Paths.get( sourcefile ) );
-
-        this.sourcefile = sourcefile;
-        this.destfile = destfile;
+        this.setCurrentFilename( sourcefile );
 
         // make sure that the parent directories exist...
-        Files.createDirectories( Paths.get( destfile ).getParent() );
+        Files.createDirectories( destfile.getParent() );
 
         try ( Reader fr = getReader( sourcefile, inputEncoding ); Writer fw = getWriter( destfile, outputEncoding ) )
         {
@@ -434,32 +415,32 @@ public class JavaCodeTransform
         }
     }
 
-    private Writer getWriter( String destfile, String outputEncoding )
+    private Writer getWriter( Path destfile, String outputEncoding )
         throws IOException
     {
         Writer fw;
         if ( outputEncoding != null )
         {
-            fw = new OutputStreamWriter( new FileOutputStream( destfile ), outputEncoding );
+            fw = new OutputStreamWriter( new FileOutputStream( destfile.toFile() ), outputEncoding );
         }
         else
         {
-            fw = new FileWriter( destfile );
+            fw = new FileWriter( destfile.toFile() );
         }
         return fw;
     }
 
-    private Reader getReader( String sourcefile, String inputEncoding )
+    private Reader getReader( Path sourcefile, String inputEncoding )
         throws IOException
     {
         Reader fr;
         if ( inputEncoding != null )
         {
-            fr = new InputStreamReader( new FileInputStream( sourcefile ), inputEncoding );
+            fr = new InputStreamReader( new FileInputStream( sourcefile.toFile() ), inputEncoding );
         }
         else
         {
-            fr = new FileReader( sourcefile );
+            fr = new FileReader( sourcefile.toFile() );
         }
         return fr;
     }
@@ -583,36 +564,6 @@ public class JavaCodeTransform
     }
 
     /**
-     * The current source file being read
-     *
-     * @return source file name
-     */
-    public final String getSourcefile()
-    {
-        return this.sourcefile;
-    }
-
-    /**
-     * The current destination file being written
-     *
-     * @return destination file name
-     */
-    public final String getDestfile()
-    {
-        return this.destfile;
-    }
-
-    /**
-     * The current source directory being read from.
-     *
-     * @return source directory
-     */
-    public final String getSourceDirectory()
-    {
-        return this.sourcedir;
-    }
-
-    /**
      * Cross Reference the given line with JXR returning the new content.
      *
      * @param line String
@@ -1067,36 +1018,30 @@ public class JavaCodeTransform
         {
             overview.append( "<div id=\"overview\">" );
             // get the URI to get Javadoc info.
-            StringBuilder javadocURI = new StringBuilder().append( javadocLinkDir );
+            Path javadocURI = javadocLinkDir;
 
             try
             {
                 JavaFile jf = fileManager.getFile( this.getCurrentFilename() );
 
-                javadocURI.append( jf.getPackageType().getName().replace( '.', '/' ) );
-                javadocURI.append( '/' );
+                javadocURI = javadocLinkDir.resolve( jf.getPackageType().getName().replace( '.', '/' ) )
+                                ;
                 // Use the name of the file instead of the class to handle inner classes properly
                 if ( jf.getClassType() != null && jf.getClassType().getFilename() != null )
                 {
-                    javadocURI.append( jf.getClassType().getFilename() );
-                }
-                else
-                {
-                    return "";
+                    javadocURI = javadocURI.resolve( jf.getClassType().getFilename() + ".html" );
                 }
-                javadocURI.append( ".html" );
 
+                String javadocHREF = "<a href=\"" + javadocURI.toString().replace( '\\', '/' ) + "\">View Javadoc</a>";
+
+                // get the generation time...
+                overview.append( javadocHREF );
             }
             catch ( IOException e )
             {
                 e.printStackTrace();
             }
 
-            String javadocHREF = "<a href=\"" + javadocURI + "\">View Javadoc</a>";
-
-            // get the generation time...
-            overview.append( javadocHREF );
-
             overview.append( "</div>" );
         }
 
diff --git a/maven-jxr/src/test/java/org/apache/maven/jxr/IncludeExcludeTest.java b/maven-jxr/src/test/java/org/apache/maven/jxr/IncludeExcludeTest.java
index bca2807..5a19cbd 100644
--- a/maven-jxr/src/test/java/org/apache/maven/jxr/IncludeExcludeTest.java
+++ b/maven-jxr/src/test/java/org/apache/maven/jxr/IncludeExcludeTest.java
@@ -21,7 +21,9 @@ package org.apache.maven.jxr;
 
 import junit.framework.TestCase;
 
-import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Collections;
 
 /**
@@ -39,10 +41,10 @@ public class IncludeExcludeTest extends TestCase
     {
         super.setUp();
         jxr = new JXR();
-        jxr.setDest( "target" );
+        jxr.setDest( Paths.get( "target" ) );
         jxr.setInputEncoding( "ISO-8859-1" );
         jxr.setOutputEncoding( "ISO-8859-1" );
-        jxr.setJavadocLinkDir( "" );
+        jxr.setJavadocLinkDir( Paths.get( "." ) );
         jxr.setLog( new DummyLog() );
     }
 
@@ -55,11 +57,11 @@ public class IncludeExcludeTest extends TestCase
         jxr.setIncludes( includes );
         jxr.xref( Collections.singletonList( "src/test/resources" ), "templates",
                   "title", "title", "copyright" );
-        File excludedFile = new File( "target/exclude/ExcludedClass.html" );
-        assertFalse( excludedFile.exists() );
-        File includedFile = new File( "target/include/IncludedClass.html" );
-        assertTrue( includedFile.exists() );
-        File notIncludedFile = new File( "target/include/NotIncludedClass.html" );
-        assertFalse( notIncludedFile.exists() );
+        Path excludedFile = Paths.get( "target/exclude/ExcludedClass.html" );
+        assertFalse( Files.exists( excludedFile ) );
+        Path includedFile = Paths.get( "target/include/IncludedClass.html" );
+        assertTrue( Files.exists( includedFile ) );
+        Path notIncludedFile = Paths.get( "target/include/NotIncludedClass.html" );
+        assertFalse( Files.exists( notIncludedFile ) );
     }
 }
diff --git a/maven-jxr/src/test/java/org/apache/maven/jxr/JavaCodeTransformTest.java b/maven-jxr/src/test/java/org/apache/maven/jxr/JavaCodeTransformTest.java
index c5e9b46..c27942e 100644
--- a/maven-jxr/src/test/java/org/apache/maven/jxr/JavaCodeTransformTest.java
+++ b/maven-jxr/src/test/java/org/apache/maven/jxr/JavaCodeTransformTest.java
@@ -23,7 +23,9 @@ import junit.framework.TestCase;
 import org.apache.maven.jxr.pacman.PackageManager;
 import org.apache.maven.jxr.pacman.FileManager;
 
-import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Locale;
 
 /**
@@ -57,15 +59,14 @@ public class JavaCodeTransformTest
         //test transforms its own sourcefile, so add some comments
         throws Exception // single line despite /*
     {
-        File sourceFile = new File( System.getProperty( "user.dir" )
-            + "/src/test/java/org/apache/maven/jxr/JavaCodeTransformTest.java" );
-        assertTrue( /* mid-line comment */ sourceFile.exists() ); /*
+        Path sourceFile = Paths.get( "src/test/java/org/apache/maven/jxr/JavaCodeTransformTest.java" );
+        assertTrue( /* mid-line comment */ Files.exists( sourceFile ) ); /*
 
         multiline comment text
 
-        */ codeTransform.transform( sourceFile.getAbsolutePath(), System.getProperty( "user.dir" ) // additional comment
-            + "/target/JavaCodeTransformTest.html", Locale.ENGLISH, "ISO-8859-1", "ISO-8859-1", "", "", "" );
-        assertTrue( /**/ new File( System.getProperty( "user.dir" ), "/target/JavaCodeTransformTest.html" ).exists() );
+        */ codeTransform.transform( sourceFile, Paths.get( "target/JavaCodeTransformTest.html" ) // additional comment
+           , Locale.ENGLISH, "ISO-8859-1", "ISO-8859-1", Paths.get( "." ), "", "" );
+        assertTrue( /**/ Files.exists( Paths.get( "target/JavaCodeTransformTest.html" ) ) );
     }
 
     /**
@@ -74,12 +75,12 @@ public class JavaCodeTransformTest
     public void testTransformWithEmptyClassFile()
         throws Exception
     {
-        File sourceFile = new File( System.getProperty( "user.dir" ) + "/src/test/resources/EmptyClass.java" );
-        assertTrue( sourceFile.exists() );
+        Path sourceFile = Paths.get( "src/test/resources/EmptyClass.java" );
+        assertTrue( Files.exists( sourceFile ) );
 
-        codeTransform.transform( sourceFile.getAbsolutePath(), System.getProperty( "user.dir" )
-            + "/target/EmptyClass.html", Locale.ENGLISH, "ISO-8859-1", "ISO-8859-1", "", "", "" );
-        assertTrue( new File( System.getProperty( "user.dir" ), "/target/EmptyClass.html" ).exists() );
+        codeTransform.transform( sourceFile, Paths.get( "target/EmptyClass.html" )
+            , Locale.ENGLISH, "ISO-8859-1", "ISO-8859-1", Paths.get( "." ), "", "" );
+        assertTrue( Files.exists( Paths.get( "target/EmptyClass.html" ) ) );
     }
 
 }
diff --git a/maven-jxr/src/test/java/org/apache/maven/jxr/JxrBeanTest.java b/maven-jxr/src/test/java/org/apache/maven/jxr/JxrBeanTest.java
index 5de3999..1f19822 100644
--- a/maven-jxr/src/test/java/org/apache/maven/jxr/JxrBeanTest.java
+++ b/maven-jxr/src/test/java/org/apache/maven/jxr/JxrBeanTest.java
@@ -21,6 +21,7 @@ package org.apache.maven.jxr;
 
 import junit.framework.TestCase;
 
+import java.nio.file.Paths;
 import java.util.Collections;
 
 public class JxrBeanTest
@@ -34,10 +35,10 @@ public class JxrBeanTest
     {
         super.setUp();
         jxrBean = new JXR();
-        jxrBean.setDest( "target" );
+        jxrBean.setDest( Paths.get( "target" ) );
         jxrBean.setInputEncoding( "ISO-8859-1" );
         jxrBean.setOutputEncoding( "ISO-8859-1" );
-        jxrBean.setJavadocLinkDir( "" );
+        jxrBean.setJavadocLinkDir( Paths.get( "." ) );
         jxrBean.setLog( new DummyLog() );
     }