You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2007/11/06 11:33:32 UTC
svn commit: r592366 -
/maven/artifact/trunk/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
Author: jvanzyl
Date: Tue Nov 6 02:33:31 2007
New Revision: 592366
URL: http://svn.apache.org/viewvc?rev=592366&view=rev
Log:
o slightly better local repository fake out
Modified:
maven/artifact/trunk/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
Modified: maven/artifact/trunk/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java?rev=592366&r1=592365&r2=592366&view=diff
==============================================================================
--- maven/artifact/trunk/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java (original)
+++ maven/artifact/trunk/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java Tue Nov 6 02:33:31 2007
@@ -125,26 +125,11 @@
}
}
- private static int i;
-
private boolean artifactHasBeenDeployed( Artifact artifact, ArtifactRepository remoteRepository )
throws ArtifactDeploymentException
{
try
{
- // We have to fake out the tools underneath as they always expect a local repository.
- // This makes sure that we are checking for remote deployments not things cached locally
- // as we don't care about things cached locally. In an embedded environment we have to
- // deal with multiple deployments, and the same deployment by the same project so we
- // just need to make sure we have a detached local repository each time as not to
- // get contaminated results.
-
- File detachedLocalRepository = new File( System.getProperty( "java.io.tmpdir" ), "repo" + i++ );
-
- ArtifactRepository localRepository = new DefaultArtifactRepository( "id", "file://" + detachedLocalRepository, defaultLayout );
-
- detachedLocalRepository.deleteOnExit();
-
// We will just let people deploy snapshots over and over again even if they want
// to deploy something different with the same name.
@@ -167,9 +152,22 @@
ArtifactVersion artifactVersion = new DefaultArtifactVersion( artifact.getVersion() );
+ // We have to fake out the tools underneath as they always expect a local repository.
+ // This makes sure that we are checking for remote deployments not things cached locally
+ // as we don't care about things cached locally. In an embedded environment we have to
+ // deal with multiple deployments, and the same deployment by the same project so we
+ // just need to make sure we have a detached local repository each time as not to
+ // get contaminated results.
+
+ File detachedLocalRepository = File.createTempFile( "maven", "repo" );
+
+ ArtifactRepository localRepository = new DefaultArtifactRepository( "id", "file://" + detachedLocalRepository, defaultLayout );
+
List versions = metadataSource.retrieveAvailableVersions( artifact, localRepository,
Arrays.asList( new ArtifactRepository[]{remoteRepository} ) );
+ detachedLocalRepository.delete();
+
for ( Iterator i = versions.iterator(); i.hasNext(); )
{
ArtifactVersion deployedArtifactVersion = (ArtifactVersion) i.next();
@@ -181,6 +179,12 @@
return true;
}
}
+ }
+ catch ( IOException e )
+ {
+ getLogger().warn( "We cannot retrieve the artifact metadata, or it does not exist. We will assume this artifact needs to be deployed." );
+
+ return false;
}
catch ( ArtifactMetadataRetrievalException e )
{
Re: svn commit: r592366 - /maven/artifact/trunk/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
Posted by Brett Porter <br...@apache.org>.
If I may be a nuisance... :) I think the delete should be in a
finally block so it doesn't get skipped for exceptions (which I think
retrieveAvailableVersions can throw from memory). I'm just
particularly watchful of these guys - I've seen Maven fill up /tmp
pretty fast recently :)
Also, could the discarded exception be logged at debug level to help
diagnosis?
Thanks!
On 06/11/2007, at 9:33 PM, jvanzyl@apache.org wrote:
> Author: jvanzyl
> Date: Tue Nov 6 02:33:31 2007
> New Revision: 592366
>
> URL: http://svn.apache.org/viewvc?rev=592366&view=rev
> Log:
> o slightly better local repository fake out
>
> Modified:
> maven/artifact/trunk/src/main/java/org/apache/maven/artifact/
> deployer/DefaultArtifactDeployer.java
>
> Modified: maven/artifact/trunk/src/main/java/org/apache/maven/
> artifact/deployer/DefaultArtifactDeployer.java
> URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/main/
> java/org/apache/maven/artifact/deployer/
> DefaultArtifactDeployer.java?rev=592366&r1=592365&r2=592366&view=diff
> ======================================================================
> ========
> --- maven/artifact/trunk/src/main/java/org/apache/maven/artifact/
> deployer/DefaultArtifactDeployer.java (original)
> +++ maven/artifact/trunk/src/main/java/org/apache/maven/artifact/
> deployer/DefaultArtifactDeployer.java Tue Nov 6 02:33:31 2007
> @@ -125,26 +125,11 @@
> }
> }
>
> - private static int i;
> -
> private boolean artifactHasBeenDeployed( Artifact artifact,
> ArtifactRepository remoteRepository )
> throws ArtifactDeploymentException
> {
> try
> {
> - // We have to fake out the tools underneath as they
> always expect a local repository.
> - // This makes sure that we are checking for remote
> deployments not things cached locally
> - // as we don't care about things cached locally. In an
> embedded environment we have to
> - // deal with multiple deployments, and the same
> deployment by the same project so we
> - // just need to make sure we have a detached local
> repository each time as not to
> - // get contaminated results.
> -
> - File detachedLocalRepository = new File
> ( System.getProperty( "java.io.tmpdir" ), "repo" + i++ );
> -
> - ArtifactRepository localRepository = new
> DefaultArtifactRepository( "id", "file://" +
> detachedLocalRepository, defaultLayout );
> -
> - detachedLocalRepository.deleteOnExit();
> -
> // We will just let people deploy snapshots over and
> over again even if they want
> // to deploy something different with the same name.
>
> @@ -167,9 +152,22 @@
>
> ArtifactVersion artifactVersion = new
> DefaultArtifactVersion( artifact.getVersion() );
>
> + // We have to fake out the tools underneath as they
> always expect a local repository.
> + // This makes sure that we are checking for remote
> deployments not things cached locally
> + // as we don't care about things cached locally. In an
> embedded environment we have to
> + // deal with multiple deployments, and the same
> deployment by the same project so we
> + // just need to make sure we have a detached local
> repository each time as not to
> + // get contaminated results.
> +
> + File detachedLocalRepository = File.createTempFile
> ( "maven", "repo" );
> +
> + ArtifactRepository localRepository = new
> DefaultArtifactRepository( "id", "file://" +
> detachedLocalRepository, defaultLayout );
> +
> List versions =
> metadataSource.retrieveAvailableVersions( artifact, localRepository,
> Arrays.asList( new ArtifactRepository[]
> {remoteRepository} ) );
>
> + detachedLocalRepository.delete();
> +
> for ( Iterator i = versions.iterator(); i.hasNext(); )
> {
> ArtifactVersion deployedArtifactVersion =
> (ArtifactVersion) i.next();
> @@ -181,6 +179,12 @@
> return true;
> }
> }
> + }
> + catch ( IOException e )
> + {
> + getLogger().warn( "We cannot retrieve the artifact
> metadata, or it does not exist. We will assume this artifact needs
> to be deployed." );
> +
> + return false;
> }
> catch ( ArtifactMetadataRetrievalException e )
> {
>
>
--
Brett Porter - brett@apache.org
Blog: http://www.devzuz.org/blogs/bporter/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org