On 6 Nov 07, at 2:04 AM 6 Nov 07, Milos Kleint wrote:

Additionally when running 2 instances of the IDE (or different IDEs at the same time or running command line maven and embedded one) concurrently,
they can clash and reuse the same dir/file?

Can't we do a more predictable cleanup than deleteOnExit()?


I will clean up the artifact code so that I don't have to do that at all. You're right that two embedded instances won't work with the hack. Just running the ITs and I'll check in something nicer before I rip some more of maven-artifact apart.

Milos



On 11/6/07, Brett Porter <[EMAIL PROTECTED]> wrote:

This wouldn't be thread safe in an embedded environment, would it?
Couldn't File.createTempFile be used?

- Brett

On 06/11/2007, at 8:12 PM, [EMAIL PROTECTED] wrote:

Author: jvanzyl
Date: Tue Nov  6 01:12:35 2007
New Revision: 592346

URL: http://svn.apache.org/viewvc?rev=592346&view=rev
Log:
o a fix for running in an embedded environment, the m2eclipse tests
bombed with the changes.

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=592346&r1=592345&r2=592346&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 01:12:35 2007
@@ -125,6 +125,8 @@
        }
    }

+    private static int i;
+
    private boolean artifactHasBeenDeployed( Artifact artifact,
ArtifactRepository remoteRepository  )
        throws ArtifactDeploymentException
    {
@@ -132,9 +134,16 @@
        {
            // 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.
-
-            ArtifactRepository localRepository = new
DefaultArtifactRepository( "", "", defaultLayout );
+            // 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.
@@ -153,7 +162,6 @@
                ArtifactRepositoryPolicy releasesPolicy = new
ArtifactRepositoryPolicy();

                releasesPolicy.setEnabled( true );
-
                ((DefaultArtifactRepository )
remoteRepository).setReleases( releasesPolicy );
            }




--
Brett Porter - [EMAIL PROTECTED]
Blog: http://www.devzuz.org/blogs/bporter/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
jason at sonatype dot com
----------------------------------------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to