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 ) {