FELIX-457: remove PathFile class and use URIs instead

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@615757 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/OBRInstall.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/OBRInstall.java
index 5b9109a..2b5d764 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/OBRInstall.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/OBRInstall.java
@@ -19,13 +19,11 @@
 package org.apache.felix.bundleplugin;
 
 
-import java.io.File;
 import java.net.URI;
 
 import org.apache.felix.obr.plugin.Config;
 import org.apache.felix.obr.plugin.ObrUpdate;
 import org.apache.felix.obr.plugin.ObrUtils;
-import org.apache.felix.obr.plugin.PathFile;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -82,17 +80,14 @@
         try
         {
             String mavenRepository = localRepository.getBasedir();
-            String artifactPath = localRepository.pathOf( project.getArtifact() );
-            String bundlePath = mavenRepository + File.separator + artifactPath;
-            bundlePath = bundlePath.replace( '\\', '/' );
 
-            URI repositoryXml = ObrUtils.findRepositoryXml( project.getBasedir(), mavenRepository, obrRepository );
+            URI repositoryXml = ObrUtils.findRepositoryXml( mavenRepository, obrRepository );
             URI obrXml = ObrUtils.findObrXml( project.getResources() );
+            URI bundleJar = ObrUtils.findBundleJar( localRepository, project.getArtifact() );
 
             Config userConfig = new Config();
 
-            update = new ObrUpdate( new PathFile( repositoryXml.getPath() ), obrXml, project, bundlePath,
-                mavenRepository, userConfig, log );
+            update = new ObrUpdate( repositoryXml, obrXml, project, bundleJar, mavenRepository, userConfig, log );
 
             update.updateRepository();
         }
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrCleanRepo.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrCleanRepo.java
index 8cc9163..f17aed1 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrCleanRepo.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrCleanRepo.java
@@ -55,7 +55,7 @@
  * Clean an OBR repository by finding and removing missing resources.
  * 
  * @goal clean
- * @phase install
+ * @phase clean
  * 
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
@@ -75,14 +75,7 @@
      * @required
      * @readonly
      */
-    private ArtifactRepository localRepository;
-
-    /**
-     * @parameter expression="${project.basedir}"
-     * @required
-     * @readonly
-     */
-    private File basedir;
+    private ArtifactRepository m_localRepo;
 
 
     public void execute() throws MojoExecutionException
@@ -96,7 +89,7 @@
         try
         {
             // Compute local repository location
-            URI repositoryXml = ObrUtils.findRepositoryXml( basedir, localRepository.getBasedir(), obrRepository );
+            URI repositoryXml = ObrUtils.findRepositoryXml( m_localRepo.getBasedir(), obrRepository );
             if ( !"file".equals( repositoryXml.getScheme() ) )
             {
                 getLog().error( "The repository URI " + repositoryXml + " is not a local file" );
@@ -141,7 +134,7 @@
      */
     private Element cleanDocument( Element elem )
     {
-        String localRepoPath = localRepository.getBasedir();
+        String localRepoPath = m_localRepo.getBasedir();
         NodeList nodes = elem.getElementsByTagName( "resource" );
         List toRemove = new ArrayList();
 
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeploy.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeploy.java
index ec76b6d..3e017a2 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeploy.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeploy.java
@@ -41,7 +41,7 @@
 /**
  * deploy the bundle to a remote site.
  * this goal is used when you compile a project with a pom file
- * @goal deployment
+ * @goal deploy
  * @phase deploy
  * @requiresDependencyResolution compile
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
@@ -49,9 +49,8 @@
 
 public class ObrDeploy extends AbstractMojo
 {
-
     /**
-     * setting of maven.
+     * Maven settings.
      * 
      * @parameter expression="${settings}"
      * @require
@@ -70,6 +69,7 @@
      * 
      * @parameter expression="${localRepository}"
      * @required
+     * @readonly
      */
     private ArtifactRepository m_localRepo;
 
@@ -88,25 +88,12 @@
     private WagonManager m_wagonManager;
 
     /**
-     * obr file define by the user.
+     * When true, ignore remote locking.
      * 
      * @parameter expression="${ignore-lock}"
-     * 
      */
     private boolean m_ignoreLock;
 
-    /**
-     * used to store pathfile in local repo.
-     */
-    private String m_fileInLocalRepo;
-
-    /**
-     * Enable/Disable this goal
-     * @description If true evrything the goal do nothing, the goal just skip over 
-     * @parameter expression="${maven.obr.installToRemoteOBR}" default-value="false"
-     */
-    private boolean installToRemoteOBR;
-
 
     /**
      * main method for this goal.
@@ -116,20 +103,10 @@
      */
     public void execute() throws MojoExecutionException, MojoFailureException
     {
-        getLog().info( "Obr-deploy start:" );
-        if ( !installToRemoteOBR )
-        {
-            getLog().info( "maven-obr-plugin:deploy goal is disable due to one of the following reason:" );
-            getLog().info( " - 'installToRemoteOBR' configuration set to false" );
-            getLog().info( " - JVM property maven.obr.installToRemoteOBR set to false" );
-            return;
-        }
         ArtifactRepository ar = m_project.getDistributionManagementArtifactRepository();
 
         // locate the obr.xml file
         URI obrXml = ObrUtils.findObrXml( m_project.getResources() );
-
-        // the obr.xml file is not present
         if ( null == obrXml )
         {
             getLog().info( "obr.xml is not present, use default" );
@@ -232,32 +209,13 @@
 
         try
         {
-            repoDescriptorFile = remoteFile.get( m_repositoryName );
+            repoDescriptorFile = remoteFile.get( m_repositoryName, ".xml" );
         }
         catch ( TransferFailedException e )
         {
             getLog().error( "Transfer failed" );
             e.printStackTrace();
             throw new MojoFailureException( "TransferFailedException" );
-
-        }
-        catch ( ResourceDoesNotExistException e )
-        {
-            // file doesn't exist! create a new one
-            getLog().warn( "file specified does not exist: " + m_repositoryName );
-            getLog().warn( "Create a new repository descriptor file " + m_repositoryName );
-            try
-            {
-                File f = File.createTempFile( String.valueOf( System.currentTimeMillis() ), null );
-                repoDescriptorFile = new File( f.getParent() + File.separator
-                    + String.valueOf( System.currentTimeMillis() ) + ".xml" );
-            }
-            catch ( IOException e1 )
-            {
-                getLog().error( "canno't create temporary file" );
-                e1.printStackTrace();
-                return;
-            }
         }
         catch ( AuthorizationException e )
         {
@@ -271,33 +229,25 @@
             throw new MojoFailureException( "IOException" );
         }
 
+        // get the path to local maven repository
+        String mavenRepository = m_localRepo.getBasedir();
+
+        URI repoXml = repoDescriptorFile.toURI();
+        URI bundleJar = ObrUtils.findBundleJar( m_localRepo, m_project.getArtifact() );
+
+        if ( !new File( bundleJar ).exists() )
+        {
+            getLog().error( "file not found in local repository: " + bundleJar );
+            return;
+        }
+
         Config userConfig = new Config();
         userConfig.setPathRelative( true );
         userConfig.setRemotely( true );
 
-        PathFile file = null;
+        ObrUpdate update = new ObrUpdate( repoXml, obrXml, m_project, bundleJar, mavenRepository, userConfig, getLog() );
 
-        // get the path to local maven repository
-        file = new PathFile( PathFile.uniformSeparator( m_settings.getLocalRepository() ) + File.separator
-            + PathFile.uniformSeparator( m_localRepo.pathOf( m_project.getArtifact() ) ) );
-        if ( file.isExists() )
-        {
-            m_fileInLocalRepo = file.getOnlyAbsoluteFilename();
-        }
-        else
-        {
-            getLog().error(
-                "file not found in local repository: " + m_settings.getLocalRepository() + File.separator
-                    + m_localRepo.pathOf( m_project.getArtifact() ) );
-            return;
-        }
-
-        file = new PathFile( "file:/" + repoDescriptorFile.getAbsolutePath() );
-
-        ObrUpdate obrUpdate = new ObrUpdate( file, obrXml, m_project, m_fileInLocalRepo, PathFile
-            .uniformSeparator( m_settings.getLocalRepository() ), userConfig, getLog() );
-
-        obrUpdate.updateRepository();
+        update.updateRepository();
 
         // the reposiroty descriptor file is modified, we upload it on the remote repository
         try
@@ -323,6 +273,7 @@
             throw new MojoFailureException( "AuthorizationException" );
         }
         repoDescriptorFile.delete();
+        lockFile.delete();
 
         // we remove lockFile activation
         lockFile = null;
@@ -358,6 +309,6 @@
         }
 
         remoteFile.disconnect();
+        lockFile.delete();
     }
-
 }
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeployFile.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeployFile.java
index 31dd639..88de437 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeployFile.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeployFile.java
@@ -47,14 +47,12 @@
  */
 public class ObrDeployFile extends AbstractMojo
 {
-
     /**
-     * setting of maven.
+     * Maven settings.
      * 
      * @parameter expression="${settings}"
      * @require
      */
-
     private Settings m_settings;
 
     /**
@@ -69,6 +67,7 @@
      * 
      * @parameter expression="${localRepository}"
      * @required
+     * @readonly
      */
     private ArtifactRepository m_localRepo;
 
@@ -95,18 +94,12 @@
     private String m_obrFile;
 
     /**
-     * obr file define by the user.
+     * When true, ignore remote locking.
      * 
      * @parameter expression="${ignore-lock}"
-     * 
      */
     private boolean m_ignoreLock;
 
-    /**
-     * used to store pathfile in local repo.
-     */
-    private String m_fileInLocalRepo;
-
 
     /**
      * main method for this goal.
@@ -116,8 +109,6 @@
      */
     public void execute() throws MojoExecutionException, MojoFailureException
     {
-        getLog().info( "Obr-deploy-file start:" );
-
         ArtifactRepository ar = m_project.getDistributionManagementArtifactRepository();
 
         // locate the obr.xml file
@@ -224,32 +215,13 @@
 
         try
         {
-            repoDescriptorFile = remoteFile.get( m_repositoryName );
+            repoDescriptorFile = remoteFile.get( m_repositoryName, ".xml" );
         }
         catch ( TransferFailedException e )
         {
             getLog().error( "Transfer failed" );
             e.printStackTrace();
             throw new MojoFailureException( "TransferFailedException" );
-
-        }
-        catch ( ResourceDoesNotExistException e )
-        {
-            // file doesn't exist! create a new one
-            getLog().warn( "file specified does not exist: " + m_repositoryName );
-            getLog().warn( "Create a new repository descriptor file " + m_repositoryName );
-            try
-            {
-                File f = File.createTempFile( String.valueOf( System.currentTimeMillis() ), null );
-                repoDescriptorFile = new File( f.getParent() + File.separator
-                    + String.valueOf( System.currentTimeMillis() ) + ".xml" );
-            }
-            catch ( IOException e1 )
-            {
-                getLog().error( "canno't create temporary file" );
-                e1.printStackTrace();
-                return;
-            }
         }
         catch ( AuthorizationException e )
         {
@@ -263,33 +235,25 @@
             throw new MojoFailureException( "IOException" );
         }
 
+        // get the path to local maven repository
+        String mavenRepository = m_localRepo.getBasedir();
+
+        URI repoXml = repoDescriptorFile.toURI();
+        URI bundleJar = ObrUtils.findBundleJar( m_localRepo, m_project.getArtifact() );
+
+        if ( !new File( bundleJar ).exists() )
+        {
+            getLog().error( "file not found in local repository: " + bundleJar );
+            return;
+        }
+
         Config userConfig = new Config();
         userConfig.setPathRelative( true );
         userConfig.setRemotely( true );
 
-        PathFile file = null;
+        ObrUpdate update = new ObrUpdate( repoXml, obrXml, m_project, bundleJar, mavenRepository, userConfig, getLog() );
 
-        // get the path to local maven repository
-        file = new PathFile( PathFile.uniformSeparator( m_settings.getLocalRepository() ) + File.separator
-            + PathFile.uniformSeparator( m_localRepo.pathOf( m_project.getArtifact() ) ) );
-        if ( file.isExists() )
-        {
-            m_fileInLocalRepo = file.getOnlyAbsoluteFilename();
-        }
-        else
-        {
-            getLog().error(
-                "file not found in local repository: " + m_settings.getLocalRepository() + File.separator
-                    + m_localRepo.pathOf( m_project.getArtifact() ) );
-            return;
-        }
-
-        file = new PathFile( "file:/" + repoDescriptorFile.getAbsolutePath() );
-
-        ObrUpdate obrUpdate = new ObrUpdate( file, obrXml, m_project, m_fileInLocalRepo, PathFile
-            .uniformSeparator( m_settings.getLocalRepository() ), userConfig, getLog() );
-
-        obrUpdate.updateRepository();
+        update.updateRepository();
 
         // the reposiroty descriptor file is modified, we upload it on the remote repository
         try
@@ -315,6 +279,7 @@
             throw new MojoFailureException( "AuthorizationException" );
         }
         repoDescriptorFile.delete();
+        lockFile.delete();
 
         // we remove lockFile activation
         lockFile = null;
@@ -349,5 +314,6 @@
             throw new MojoFailureException( "AuthorizationException" );
         }
         remoteFile.disconnect();
+        lockFile.delete();
     }
 }
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstall.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstall.java
index f31855d..94ec296 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstall.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstall.java
@@ -26,13 +26,12 @@
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.settings.Settings;
 
 
 /**
  * construct the repository.xml with a project Maven compiled
  *
- * @goal repository
+ * @goal install
  * @phase install
  * @requiresDependencyResolution compile
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
@@ -44,6 +43,7 @@
      * 
      * @parameter expression="${localRepository}"
      * @required
+     * @readonly
      */
     private ArtifactRepository m_localRepo;
 
@@ -51,7 +51,6 @@
      * path to the repository.xml.
      * 
      * @parameter expression="${repository-path}"
-     * @require
      */
     private String m_repositoryPath;
 
@@ -64,27 +63,6 @@
 
     private MavenProject m_project;
 
-    /**
-     * setting of maven.
-     * 
-     * @parameter expression="${settings}"
-     * @require
-     */
-
-    private Settings m_settings;
-
-    /**
-     * Enable/Disable this goal
-     * @description If true evrything the goal do nothing, the goal just skip over 
-     * @parameter expression="${maven.obr.installToLocalOBR}" default-value="true"
-     */
-    private boolean installToLocalOBR;
-
-    /**
-     * path to file in the maven local repository.
-     */
-    private String m_fileInLocalRepo;
-
 
     /**
      * main method for this goal.
@@ -93,89 +71,30 @@
      */
     public void execute() throws MojoExecutionException
     {
-        getLog().info( "Obr Plugin starts:" );
-        if ( !installToLocalOBR )
-        {
-            getLog().info( "maven-obr-plugin:repository goal is disable due to one of the following reason:" );
-            getLog().info( " - 'installToLocalOBR' configuration set to false" );
-            getLog().info( " - JVM property maven.obr.installToLocalOBR set to false" );
-            return;
-        }
-
-        if ( m_repositoryPath == null )
-        {
-            m_repositoryPath = "file:/" + m_localRepo.getBasedir() + File.separator + "repository.xml";
-            getLog().info( "-Drepository-path is not set, using default repository: " + m_repositoryPath );
-        }
-
-        PathFile file = new PathFile( m_repositoryPath );
-        if ( file.isExists() )
-        {
-            if ( !m_repositoryPath.startsWith( "file:/" ) )
-            {
-                m_repositoryPath = "file:/" + m_repositoryPath;
-            }
-        }
-
         // locate the obr.xml file
         URI obrXml = ObrUtils.findObrXml( m_project.getResources() );
-
-        // the obr.xml file is not present
         if ( null == obrXml )
         {
             getLog().info( "obr.xml is not present, use default" );
         }
 
         // get the path to local maven repository
-        file = new PathFile( PathFile.uniformSeparator( m_settings.getLocalRepository() ) + File.separator
-            + PathFile.uniformSeparator( m_localRepo.pathOf( m_project.getArtifact() ) ) );
+        String mavenRepository = m_localRepo.getBasedir();
 
-        if ( file.isExists() )
+        URI repoXml = ObrUtils.findRepositoryXml( mavenRepository, m_repositoryPath );
+        URI bundleJar = ObrUtils.findBundleJar( m_localRepo, m_project.getArtifact() );
+
+        if ( !new File( bundleJar ).exists() )
         {
-            m_fileInLocalRepo = file.getOnlyAbsoluteFilename();
-        }
-        else
-        {
-            getLog().error(
-                "file not found in local repository: " + m_settings.getLocalRepository() + File.separator
-                    + m_localRepo.pathOf( m_project.getArtifact() ) );
-            getLog().error(
-                "file not found in local repository: " + m_localRepo.getBasedir() + File.separator
-                    + m_localRepo.pathOf( m_project.getArtifact() ) );
+            getLog().error( "file not found in local repository: " + bundleJar );
             return;
         }
 
-        // verify the repository.xml
-        PathFile fileRepo = new PathFile( m_repositoryPath );
-        if ( fileRepo.isRelative() )
-        {
-            fileRepo.setBaseDir( m_settings.getLocalRepository() );
-        }
+        // use default configuration
+        Config userConfig = new Config();
 
-        // create the folder to the repository
-        PathFile repoExist = new PathFile( fileRepo.getAbsolutePath() );
-        if ( !repoExist.isExists() )
-        {
-            fileRepo.createPath();
-        }
+        ObrUpdate update = new ObrUpdate( repoXml, obrXml, m_project, bundleJar, null, userConfig, getLog() );
 
-        // build the user configuration (use default)
-        Config user = new Config();
-
-        getLog().debug( "Maven2 Local File repository = " + fileRepo.getAbsoluteFilename() );
-        getLog().debug( "OBR repository = " + obrXml );
-
-        ObrUpdate obrUpdate = new ObrUpdate( fileRepo, obrXml, m_project, m_fileInLocalRepo, PathFile
-            .uniformSeparator( m_settings.getLocalRepository() ), user, getLog() );
-        try
-        {
-            obrUpdate.updateRepository();
-        }
-        catch ( MojoExecutionException e )
-        {
-            e.printStackTrace();
-            throw new MojoExecutionException( "MojoFailureException" );
-        }
+        update.updateRepository();
     }
-
 }
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstallFile.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstallFile.java
index 4d1638a..4811db9 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstallFile.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstallFile.java
@@ -22,12 +22,13 @@
 import java.io.File;
 import java.net.URI;
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.settings.Settings;
 
 
 /**
@@ -41,10 +42,18 @@
 public class ObrInstallFile extends AbstractMojo
 {
     /**
+     * Component factory for Maven artifacts
+     * 
+     * @component
+     */
+    private ArtifactFactory m_factory;
+
+    /**
      * The local Maven repository.
      * 
      * @parameter expression="${localRepository}"
      * @required
+     * @readonly
      */
     private ArtifactRepository m_localRepo;
 
@@ -52,19 +61,10 @@
      * path to the repository.xml.
      * 
      * @parameter expression="${repository-path}"
-     * @require
      */
     private String m_repositoryPath;
 
     /**
-     * setting of maven.
-     * 
-     * @parameter expression="${settings}"
-     * @require
-     */
-    private Settings m_settings;
-
-    /**
      * Artifact Id.
      * @description symbolic name define by the user
      * @parameter expression="${artifactId}"
@@ -119,8 +119,6 @@
         m_project.setVersion( m_version );
         m_project.setPackaging( m_packaging );
 
-        PathFile fileOut;
-
         if ( m_groupId == null )
         {
             getLog().error( "-DgroupId=VALUE is required" );
@@ -142,56 +140,32 @@
             return;
         }
 
-        // copy the file to the local repository
-        PathFile repoLocal = new PathFile( m_localRepo.getBasedir() );
-
-        // get the target file in mvn repo
-        fileOut = new PathFile( PathFile.uniformSeparator( m_settings.getLocalRepository() ) + File.separator
-            + m_groupId.replace( '.', File.separatorChar ) + File.separator + m_artifactId + File.separator + m_version
-            + File.separator + m_artifactId + "-" + m_version + "." + m_packaging );
-
-        if ( !fileOut.isExists() )
-        {
-            getLog().error( "file doesn't exist: " + fileOut.getAbsoluteFilename() );
-            return;
-        }
-        else
-        {
-            getLog().info( "Target file: " + fileOut.getAbsoluteFilename() );
-        }
-
-        if ( m_repositoryPath == null )
-        {
-            m_repositoryPath = "file:" + repoLocal.getOnlyAbsoluteFilename() + "repository.xml";
-            getLog().info( "-Drepository-path is not set, using default repository: " + m_repositoryPath );
-        }
-
-        PathFile fileRepo = new PathFile( m_repositoryPath );
-        if ( fileRepo.isRelative() )
-        {
-            fileRepo.setBaseDir( m_settings.getLocalRepository() );
-        }
-
-        // create the folder to the repository
-        PathFile repoExist = new PathFile( fileRepo.getAbsolutePath() );
-        if ( !repoExist.isExists() )
-        {
-            fileRepo.createPath();
-        }
-
+        // locate the obr.xml file
         URI obrXml = ObrUtils.toFileURI( m_obrFile );
         if ( null == obrXml )
         {
             getLog().info( "obr.xml is not present, use default" );
         }
 
-        // build the user config
+        Artifact bundleArtifact = m_factory.createBuildArtifact( m_groupId, m_artifactId, m_version, m_packaging );
+
+        // get the path to local maven repository
+        String mavenRepository = m_localRepo.getBasedir();
+
+        URI repoXml = ObrUtils.findRepositoryXml( mavenRepository, m_repositoryPath );
+        URI bundleJar = ObrUtils.findBundleJar( m_localRepo, bundleArtifact );
+
+        if ( !new File( bundleJar ).exists() )
+        {
+            getLog().error( "file doesn't exist: " + bundleJar );
+            return;
+        }
+
+        // use default configuration
         Config userConfig = new Config();
 
-        ObrUpdate obrUpdate = new ObrUpdate( fileRepo, obrXml, m_project, fileOut.getOnlyAbsoluteFilename(),
-            m_localRepo.getBasedir(), userConfig, getLog() );
-        obrUpdate.updateRepository();
+        ObrUpdate update = new ObrUpdate( repoXml, obrXml, m_project, bundleJar, null, userConfig, getLog() );
 
+        update.updateRepository();
     }
-
 }
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUpdate.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUpdate.java
index 468b956..cfbce3f 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUpdate.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUpdate.java
@@ -79,7 +79,7 @@
     /**
      * name and path to the bundle jar file.
      */
-    private URI m_bundlePath;
+    private URI m_bundleJar;
 
     /**
      * maven project description.
@@ -117,17 +117,16 @@
      * @param repositoryXml path to the repository descriptor file
      * @param obrXml path and filename to the obr.xml file
      * @param project maven project description
-     * @param bundlePath path to the bundle jar file
+     * @param bundleJar path to the bundle jar file
      * @param mavenRepositoryPath path to the local maven repository
      * @param userConfig user information
      * @param logger plugin logger
      */
-    public ObrUpdate( PathFile repositoryXml, URI obrXml, MavenProject project, String bundlePath,
-        String mavenRepositoryPath, Config userConfig, Log logger )
+    public ObrUpdate( URI repositoryXml, URI obrXml, MavenProject project, URI bundleJar, String mavenRepositoryPath,
+        Config userConfig, Log logger )
     {
-        // m_localRepo = localRepo;
-        m_bundlePath = ObrUtils.toFileURI( bundlePath );
-        m_repositoryXml = repositoryXml.getFile().toURI(); // FIXME: remove when PathFile is gone
+        m_bundleJar = bundleJar;
+        m_repositoryXml = repositoryXml;
         m_obrXml = obrXml;
         m_project = project;
         m_logger = logger;
@@ -153,10 +152,9 @@
      */
     public void updateRepository() throws MojoExecutionException
     {
-
-        m_logger.debug( " (f) m_obrXml = " + m_obrXml );
-        m_logger.debug( " (f) m_bundlePath = " + m_bundlePath );
-        m_logger.debug( " (f) m_repositoryXml = " + m_repositoryXml );
+        m_logger.debug( " (f) repositoryXml = " + m_repositoryXml );
+        m_logger.debug( " (f) bundleJar = " + m_bundleJar );
+        m_logger.debug( " (f) obrXml = " + m_obrXml );
 
         m_documentBuilder = initDocumentBuilder();
 
@@ -166,21 +164,21 @@
         }
 
         // get the file size
-        File bundleFile = new File( m_bundlePath );
+        File bundleFile = new File( m_bundleJar );
         if ( bundleFile.exists() )
         {
-            URI bundleURI = m_bundlePath;
+            URI resourceURI = m_bundleJar;
             if ( m_userConfig.isPathRelative() )
             {
-                bundleURI = ObrUtils.getRelativeURI( m_baseURI, bundleURI );
+                resourceURI = ObrUtils.getRelativeURI( m_baseURI, resourceURI );
             }
 
             m_resourceBundle.setSize( String.valueOf( bundleFile.length() ) );
-            m_resourceBundle.setUri( bundleURI.toASCIIString() );
+            m_resourceBundle.setUri( resourceURI.toASCIIString() );
         }
         else
         {
-            m_logger.error( "file doesn't exist: " + m_bundlePath );
+            m_logger.error( "file doesn't exist: " + m_bundleJar );
             return;
         }
 
@@ -210,7 +208,7 @@
         try
         {
             // use bindex to extract bundle information
-            bindexExtractor = new ExtractBindexInfo( m_repositoryXml, m_bundlePath.getPath() );
+            bindexExtractor = new ExtractBindexInfo( m_repositoryXml, m_bundleJar.getPath() );
         }
         catch ( MojoExecutionException e )
         {
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUtils.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUtils.java
index 50b99a9..cc9c144 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUtils.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUtils.java
@@ -24,6 +24,8 @@
 import java.util.Collection;
 import java.util.Iterator;
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.model.Resource;
 
 
@@ -40,12 +42,11 @@
 
 
     /**
-     * @param baseDir current base directory
      * @param mavenRepository path to local maven repository
      * @param obrRepository path to specific repository.xml
      * @return URI pointing to correct repository.xml
      */
-    public static URI findRepositoryXml( File baseDir, String mavenRepository, String obrRepository )
+    public static URI findRepositoryXml( String mavenRepository, String obrRepository )
     {
         // Combine location settings into a single repository location
         if ( null == obrRepository || obrRepository.trim().length() == 0 )
@@ -71,13 +72,7 @@
         // fall-back to file-system approach
         if ( null == uri || !uri.isAbsolute() )
         {
-            File file = new File( obrRepository );
-            if ( !file.isAbsolute() )
-            {
-                file = new File( baseDir, obrRepository );
-            }
-
-            uri = file.toURI();
+            uri = new File( obrRepository ).toURI();
         }
 
         return uri;
@@ -104,6 +99,20 @@
 
 
     /**
+     * @param repository maven repository
+     * @param artifact maven artifact
+     * @return file URI pointing to artifact in repository
+     */
+    public static URI findBundleJar( ArtifactRepository repository, Artifact artifact )
+    {
+        String baseDir = repository.getBasedir();
+        String artifactPath = repository.pathOf( artifact );
+
+        return toFileURI( baseDir + '/' + artifactPath );
+    }
+
+
+    /**
      * @param path filesystem path
      * @return file URI for the path
      */
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/PathFile.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/PathFile.java
deleted file mode 100644
index 62c8b88..0000000
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/PathFile.java
+++ /dev/null
@@ -1,739 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.obr.plugin;
-
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.channels.FileChannel;
-
-
-/**
- * this class provide some functions to simplify file manipulation.
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class PathFile
-{
-
-    /**
-     * full filename.
-     */
-    private String m_fullFilename;
-
-    /**
-     * store only the filename of the file.
-     */
-    private String m_fileName;
-
-    /**
-     * store only the path of this file.
-     */
-    private String m_pathFile;
-
-    /**
-     * store the base Directory in case of relative path.
-     */
-    private String m_baseDir;
-
-    /**
-     * store the protocol used (ie:file, http...).
-     */
-    private String m_protocol;
-
-    /**
-     * if the path is relative or absolute.
-     */
-    private boolean m_relative;
-
-    /**
-     * if this file is a folder.
-     */
-    private boolean m_folder;
-
-    /**
-     * if the file exist or not.
-     */
-    private boolean m_exist;
-
-    /**
-     * if this file is a file (not a folder).
-     */
-    private boolean m_file;
-
-    /**
-     * if this filename is valid or incomplete.
-     */
-    private boolean m_valid;
-
-
-    /**
-     * build all the attribute information.
-     * @param filename path to the file
-     */
-    public PathFile( String filename )
-    {
-
-        m_fullFilename = filename;
-        if ( filename == null )
-        {
-            m_valid = false;
-            return;
-        }
-        m_valid = true;
-        m_protocol = extractProtocol( filename );
-        m_pathFile = extractPathFile( filename );
-        if ( m_pathFile.startsWith( "//" ) )
-        {
-            // avoid problems on Unix like system
-            m_pathFile = m_pathFile.substring( 1 );
-        }
-        m_fileName = extractFileName( filename );
-        m_relative = extractRelative();
-        if ( !m_relative && ( getProtocol().compareTo( "file" ) == 0 || getProtocol().compareTo( "" ) == 0 ) )
-        {
-            File f = new File( getOnlyAbsoluteFilename() );
-            m_file = f.isFile();
-            m_folder = f.isDirectory();
-            m_exist = f.exists();
-            if ( m_folder )
-            {
-                m_pathFile = m_pathFile + m_fileName + File.separator;
-                m_fileName = "";
-            }
-        }
-        if ( m_exist )
-        {
-            m_protocol = "file";
-        }
-        else
-        {
-            if ( m_fileName.compareTo( "" ) == 0 )
-            {
-                m_folder = true;
-                m_file = false;
-            }
-            else
-            {
-                m_folder = false;
-                m_file = true;
-            }
-
-        }
-
-        // add the '/' before the complete path if it is absolute path
-        if ( !isRelative() && !m_pathFile.startsWith( "/" ) )
-        {
-            m_pathFile = "/".concat( m_pathFile );
-        }
-
-    }
-
-
-    /**
-     * get if the filename is relative or absolute.
-     * @return true if the path is relative, else false
-     */
-    private boolean extractRelative()
-    {
-        if ( m_pathFile.startsWith( "." + File.separator, 1 ) || m_pathFile.startsWith( ".." + File.separator, 1 ) )
-        {
-            m_pathFile = m_pathFile.substring( 1 );
-            m_valid = false;
-            return true;
-        }
-
-        return false;
-    }
-
-
-    /**
-     * get only the name from the filename.
-     * @param fullFilename full filename
-     * @return the name of the file or folder
-     */
-    private String extractFileName( String fullFilename )
-    {
-        int index = fullFilename.lastIndexOf( '/' ); // Given path 
-        return fullFilename.substring( index + 1, fullFilename.length() );
-    }
-
-
-    /**
-     * get the path from the filename.
-     * @param fullFilename full filename
-     * @return the path of the file
-     */
-    private String extractPathFile( String fullFilename )
-    {
-        String substring;
-        if ( extractFileName( fullFilename ).compareTo( "" ) == 0 )
-        {
-            // it is a folder
-            substring = fullFilename;
-        }
-        else
-        {
-            substring = fullFilename.substring( 0, fullFilename.indexOf( extractFileName( fullFilename ) ) );
-        }
-
-        if ( getProtocol().compareTo( "" ) != 0 )
-        {
-            substring = substring.substring( 5 );
-        }
-
-        return substring;
-    }
-
-
-    /**
-     * determine which protocol is used.
-     * @param filename the full fileneme
-     * @return "file" or "http" or ""
-     */
-    private String extractProtocol( String filename )
-    {
-        if ( filename.startsWith( "file:" ) )
-        {
-            return "file";
-        }
-        if ( filename.startsWith( "http:" ) )
-        {
-            return "http";
-        }
-        return "";
-    }
-
-
-    /**
-     * set the base directory.
-     * @param baseDir new value for the base directory
-     */
-    public void setBaseDir( String baseDir )
-    {
-        m_baseDir = baseDir;
-        if ( isRelative() && m_fullFilename != null )
-        {
-            m_valid = true;
-            if ( getProtocol().compareTo( "file" ) == 0 || getProtocol().compareTo( "" ) == 0 )
-            {
-                File f = new File( getOnlyAbsoluteFilename() );
-                m_file = f.isFile();
-                m_folder = f.isDirectory();
-                m_exist = f.exists();
-            }
-            if ( m_exist )
-            {
-                m_protocol = "file";
-            }
-        }
-
-    }
-
-
-    /**
-     * get the base directory.
-     * @return base directory
-     */
-    public String getBaseDir()
-    {
-        return m_baseDir;
-    }
-
-
-    public boolean isValid()
-    {
-        return m_valid;
-    }
-
-
-    public boolean isRelative()
-    {
-        return m_relative;
-    }
-
-
-    public boolean isExists()
-    {
-        return m_exist;
-    }
-
-
-    public boolean isFile()
-    {
-        return m_file;
-    }
-
-
-    public boolean isFolder()
-    {
-        return m_folder;
-    }
-
-
-    /**
-     * get a File which points on the same file.
-     * @return a File object
-     */
-    public File getFile()
-    {
-        if ( !isValid() )
-        {
-            return null;
-        }
-        String path = PathFile.uniformSeparator( getOnlyAbsoluteFilename() );
-        if ( File.separatorChar == '\\' )
-        {
-            path = path.replace( '\\', '/' );
-        }
-        File f = new File( path );
-        return f;
-    }
-
-
-    /**
-     * get an URI which points on the same file.
-     * @return an URI object
-     */
-    public URI getUri()
-    {
-        if ( !isValid() )
-        {
-            return null;
-        }
-        String path = PathFile.uniformSeparator( getAbsoluteFilename() );
-        if ( File.separatorChar == '\\' )
-        {
-            path = path.replace( '\\', '/' );
-        }
-
-        path = path.replaceAll( " ", "%20" );
-
-        URI uri = null;
-        try
-        {
-            uri = new URI( path );
-        }
-        catch ( URISyntaxException e )
-        {
-            System.err.println( "Malformed URI: " + path );
-            System.err.println( e.getMessage() );
-            return null;
-        }
-        return uri;
-    }
-
-
-    /**
-     * get protocol + relative path of this file.
-     * @return the relative path or null if it is not valid
-     */
-    public String getRelativePath()
-    {
-        if ( !isValid() )
-        {
-            return null;
-        }
-
-        return getProtocol() + ":/" + getOnlyRelativePath();
-    }
-
-
-    /**
-     * get only (without protocol) relative path of this file.
-     * @return the relative path or null if it is not valid
-     */
-    public String getOnlyRelativePath()
-    {
-        if ( !isValid() )
-        {
-            return null;
-        }
-        if ( isRelative() )
-        {
-            return m_pathFile;
-
-        }
-        else
-        {
-            if ( m_baseDir != null )
-            {
-                // System.err.println(m_pathFile);
-                // System.err.println(m_baseDir);
-                if ( m_pathFile.startsWith( m_baseDir ) )
-                {
-                    /*
-                     * String ch1 = m_pathFile; String ch2 = m_baseDir; System.err.println(ch1); System.err.println(ch2); System.err.println("."+File.separator+ch1.substring(ch2.length()));
-                     */
-                    return "." + File.separator + m_pathFile.substring( m_baseDir.length() );
-                }
-            }
-            return m_pathFile;
-        }
-    }
-
-
-    /**
-     * calcul absolute path from relative path.
-     * @param baseDir base directory
-     * @param path path to convert
-     * @return the absolute path or null
-     */
-    private String calculAbsolutePath( String baseDir, String path )
-    {
-        if ( path.startsWith( ".." + File.separatorChar ) )
-        {
-            String base = baseDir;
-            int lastIndex;
-            lastIndex = base.lastIndexOf( File.separator );
-            if ( lastIndex == base.length() )
-            {
-                base = base.substring( 0, base.length() - 1 );
-                lastIndex = base.lastIndexOf( File.separator );
-            }
-            if ( lastIndex < base.length() )
-            {
-                return calculAbsolutePath( base.substring( 0, lastIndex + 1 ), path.substring( 3 ) );
-            }
-            else
-            {
-                return null;
-            }
-        }
-        else if ( path.startsWith( "." + File.separatorChar ) )
-        {
-            String res;
-            if ( File.separatorChar == '\\' )
-            {
-                res = path.replaceFirst( ".", baseDir.replace( '\\', '/' ) );
-            }
-            else
-            {
-                res = path.replaceFirst( ".", baseDir );
-            }
-
-            return PathFile.uniformSeparator( res );
-        }
-        else
-        {
-            return PathFile.uniformSeparator( baseDir + path );
-        }
-    }
-
-
-    /**
-     * get only (without protocol) absolute path (without filename).
-     * @return absolute path
-     */
-    public String getOnlyAbsolutePath()
-    {
-        if ( !isValid() )
-        {
-            return null;
-        }
-        if ( isRelative() )
-        {
-            return calculAbsolutePath( m_baseDir, m_pathFile );
-        }
-        else
-        {
-            return m_pathFile;
-        }
-    }
-
-
-    /**
-     * get protocol + absolute path (without filename).
-     * @return absolute path
-     */
-    public String getAbsolutePath()
-    {
-
-        if ( isRelative() )
-        {
-            return getProtocol() + ":/" + calculAbsolutePath( m_baseDir, m_pathFile );
-        }
-        else
-        {
-            if ( getProtocol().compareTo( "" ) == 0 || m_pathFile == null )
-            {
-                return m_pathFile;
-            }
-            else
-            {
-                return getProtocol() + ":" + m_pathFile;
-            }
-        }
-    }
-
-
-    /**
-     * get only (without protocol) absolute path + filename.
-     * @return absolute filename
-     */
-    public String getOnlyAbsoluteFilename()
-    {
-        if ( getOnlyAbsolutePath() != null && getFilename() != null )
-        {
-            return getOnlyAbsolutePath() + getFilename();
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-
-    /**
-     * get protocol + absolute path + filename.
-     * @return absolute filenama
-     */
-    public String getAbsoluteFilename()
-    {
-        if ( getAbsolutePath() != null && getFilename() != null )
-        {
-            return getAbsolutePath() + getFilename();
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-
-    /**
-     * get only (without protocol) relative path + filename.
-     * @return relative filename
-     */
-    public String getOnlyRelativeFilename()
-    {
-        if ( !isValid() )
-        {
-            return "";
-        }
-
-        return getOnlyRelativePath() + getFilename();
-
-    }
-
-
-    /**
-     * get protocol + relative path + filename.
-     * @return relative filename
-     */
-    public String getRelativeFilename()
-    {
-        if ( !isValid() )
-        {
-            return "";
-        }
-
-        if ( isRelative() )
-        {
-            return getRelativePath() + getFilename();
-        }
-        else
-        {
-            return getAbsoluteFilename();
-        }
-    }
-
-
-    public String getFilename()
-    {
-        return m_fileName;
-    }
-
-
-    public String getProtocol()
-    {
-        return m_protocol;
-    }
-
-
-    /**
-     * create all the directories not also present in the current path.
-     * @return true if all directories was created, else false
-     */
-    public boolean createPath()
-    {
-        File path = new File( getOnlyAbsolutePath() );
-        if ( path.exists() )
-        {
-            return true;
-        }
-        return path.mkdirs();
-    }
-
-
-    /**
-     * create all the directories not also present in the current path and the file.
-     * @return true it was created, else false
-     */
-    public boolean createFile()
-    {
-        File path = new File( getOnlyAbsolutePath() );
-        if ( !path.exists() )
-        {
-            if ( !createPath() )
-            {
-                return false;
-            }
-        }
-        path = new File( getOnlyAbsoluteFilename() );
-        try
-        {
-            return path.createNewFile();
-        }
-        catch ( IOException e )
-        {
-            return false;
-        }
-
-    }
-
-
-    /**
-     * delete the current file.
-     * @return true if it was deleted, else false
-     */
-    public boolean delete()
-    {
-        File path = new File( getAbsoluteFilename() );
-        if ( path.exists() )
-        {
-            return path.delete();
-        }
-        else
-        {
-            return true;
-        }
-
-    }
-
-    private static final String REGEXP_BACKSLASH = "\\\\";
-
-
-    /**
-     * replace all '\' by '\\' in the given string.
-     * @param path string where replace the search pattern
-     * @return string replaced
-     */
-    public static String doubleSeparator( String path )
-    {
-        // double the '\' in the path
-        if ( path != null && File.separatorChar == '\\' )
-        {
-            return path.replaceAll( REGEXP_BACKSLASH, REGEXP_BACKSLASH + REGEXP_BACKSLASH );
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-
-    /**
-     * file separator('\' or '/') by the one of the current system.
-     * @param path string where replace the search pattern
-     * @return string replaced
-     */
-    public static String uniformSeparator( String path )
-    {
-        if ( File.separatorChar == '\\' )
-        {
-            if ( path.startsWith( "/" ) )
-            {
-                return path.substring( 1 ).replace( '/', File.separatorChar );
-            }
-            else
-            {
-                return path.replace( '/', File.separatorChar );
-            }
-        }
-        else
-        {
-            return path.replace( '\\', File.separatorChar );
-        }
-    }
-
-
-    /**
-     * copy file from src to dest.
-     * @param src source file
-     * @param dest destination file
-     * @return true if the file was correctly copied, else false
-     */
-    public static boolean copyFile( PathFile src, PathFile dest )
-    {
-        FileChannel in = null;
-        FileChannel out = null;
-
-        if ( !src.isExists() )
-        {
-            System.err.println( "src file must exist: " + src.getAbsoluteFilename() );
-            return false;
-        }
-        if ( !dest.isExists() )
-        {
-            dest.createFile();
-        }
-        try
-        {
-            in = new FileInputStream( src.getOnlyAbsoluteFilename() ).getChannel();
-            out = new FileOutputStream( dest.getOnlyAbsoluteFilename() ).getChannel();
-
-            in.transferTo( 0, in.size(), out );
-        }
-        catch ( Exception e )
-        {
-            e.printStackTrace();
-        }
-        finally
-        {
-            if ( in != null )
-            {
-                try
-                {
-                    in.close();
-                }
-                catch ( IOException e )
-                {
-                    return false;
-                }
-            }
-            if ( out != null )
-            {
-                try
-                {
-                    out.close();
-                }
-                catch ( IOException e )
-                {
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
-
-}
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/RemoteFileManager.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/RemoteFileManager.java
index 44702bd..a0f3cb4 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/RemoteFileManager.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/RemoteFileManager.java
@@ -169,14 +169,13 @@
     /**
      * get a file from the current repository connected.
      * @param url url to the targeted file
+     * @param suffix suggested file suffix
      * @return  get a file descriptor on the requiered resource
      * @throws IOException if an IO error occurs
-     * @throws TransferFailedException  if the transfer failed 
-     * @throws ResourceDoesNotExistException if the targeted resource doesn't exist
+     * @throws TransferFailedException  if the transfer failed
      * @throws AuthorizationException if the connection authorization failed
      */
-    public File get( String url ) throws IOException, TransferFailedException, ResourceDoesNotExistException,
-        AuthorizationException
+    public File get( String url, String suffix ) throws IOException, TransferFailedException, AuthorizationException
     {
 
         if ( m_wagon == null )
@@ -185,8 +184,26 @@
             return null;
         }
 
-        File file = File.createTempFile( String.valueOf( System.currentTimeMillis() ), "tmp" );
-        m_wagon.get( url, file );
+        File file = File.createTempFile( String.valueOf( System.currentTimeMillis() ), suffix );
+        try
+        {
+            m_wagon.get( url, file );
+        }
+        catch ( TransferFailedException e )
+        {
+            file.delete();
+            throw e;
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            file.delete();
+        }
+        catch ( AuthorizationException e )
+        {
+            file.delete();
+            throw e;
+        }
+
         return file;
     }
 
@@ -240,7 +257,7 @@
      * this method indicates if the targeted file is locked or not.
      * @param remote connection manager
      * @param fileName name targeted
-     * @return  true if thr reuiered file is locked, else false
+     * @return  true if the required file is locked, else false
      * @throws MojoFailureException if the plugin failed
      */
     public boolean isLockedFile( RemoteFileManager remote, String fileName ) throws MojoFailureException
@@ -248,17 +265,17 @@
         File file = null;
         try
         {
-            file = remote.get( fileName + ".lock" );
+            file = remote.get( fileName + ".lock", ".lock" );
+            if ( null != file && file.length() == 0 )
+            {
+                return false;
+            }
+            return true;
         }
         catch ( TransferFailedException e )
         {
             e.printStackTrace();
             throw new MojoFailureException( "TransferFailedException" );
-
-        }
-        catch ( ResourceDoesNotExistException e )
-        {
-            return false;
         }
         catch ( AuthorizationException e )
         {
@@ -270,11 +287,13 @@
             e.printStackTrace();
             throw new MojoFailureException( "IOException" );
         }
-        if ( file != null && file.length() == 0 )
+        finally
         {
-            return false;
+            if ( null != file )
+            {
+                file.delete();
+            }
         }
-        return true;
     }
 
 }