ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xav...@apache.org
Subject svn commit: r778769 - in /ant/ivy/core/trunk: ./ doc/settings/ src/java/org/apache/ivy/core/event/retrieve/ src/java/org/apache/ivy/core/retrieve/ test/java/org/apache/ivy/core/retrieve/
Date Tue, 26 May 2009 15:50:42 GMT
Author: xavier
Date: Tue May 26 15:50:41 2009
New Revision: 778769

URL: http://svn.apache.org/viewvc?rev=778769&view=rev
Log:
IMPROVEMENT: Pre and post retrieve artifact events (IVY-1084)

Added:
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/EndRetrieveArtifactEvent.java
  (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/RetrieveArtifactEvent.java
  (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/StartRetrieveArtifactEvent.java
  (with props)
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/doc/settings/triggers.html
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=778769&r1=778768&r2=778769&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Tue May 26 15:50:41 2009
@@ -87,6 +87,8 @@
 	
    trunk
 =====================================
+- IMPROVEMENT: Pre and post retrieve artifact events (IVY-1084)
+
 - FIX: Ibiblio resolver throws IndexOutOfBoundsException when using snapshot versions with
usepoms='false' (IVY-1028)
 - FIX: Wrong BuildException messages (findmodules) (IVY-1056)
 - FIX: PomModuleDescriptorBuilder does not resolve ejb type dependencies to jar extension
(IVY-1058) (thanks to Andrey Lomakin)

Modified: ant/ivy/core/trunk/doc/settings/triggers.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/settings/triggers.html?rev=778769&r1=778768&r2=778769&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/settings/triggers.html (original)
+++ ant/ivy/core/trunk/doc/settings/triggers.html Tue May 26 15:50:41 2009
@@ -171,6 +171,40 @@
         </td>
         <td>Fired at the end of the retrieve process.</td>
     </tr>
+    <tr><td>pre-retrieve-artifact <br/><span class="since">since
2.1</span></td>
+        <td>
+          <ul>
+            <li>organisation</li>the organisation of the artifact which is about
to be retrieved
+            <li>module</li>the name of the module of the artifact which is about
to be retrieved
+            <li>revision</li>the revision of the the artifact which is about
to be retrieved
+            <li>artifact</li>the name of the the artifact which is about to be
retrieved
+            <li>type</li>the type of the the artifact which is about to be retrieved
+            <li>ext</li>the extension of the the artifact which is about to be
retrieved
+            <li>metadata</li>true if the retrieved artifact is a metadata artifact,
false for published artifacts 
+            <li>size</li>the size in bytes of the retrieved artifact
+            <li>from</li>the absolute path from which it will be retrieved (usually
a location in cache)
+            <li>to</li>the absolute path to which it will be retrieved
+          </ul>
+        </td>
+        <td>Fired before an artifact is retrieved from cache to a local location</td>
+    </tr>
+    <tr><td>post-retrieve-artifact <br/><span class="since">since
2.1</span></td>
+        <td>
+          <ul>
+            <li>organisation</li>the organisation of the artifact which has just
been retrieved
+            <li>module</li>the name of the module of the artifact which has just
been retrieved
+            <li>revision</li>the revision of the the artifact which has just
been retrieved
+            <li>artifact</li>the name of the the artifact which has just been
retrieved
+            <li>type</li>the type of the the artifact which has just been retrieved
+            <li>ext</li>the extension of the the artifact which has just been
retrieved
+            <li>metadata</li>true if the retrieved artifact is a metadata artifact,
false for published artifacts 
+            <li>size</li>the size in bytes of the retrieved artifact
+            <li>from</li>the absolute path from which it has just been retrieved
(usually a location in cache)
+            <li>to</li>the absolute path to which it has just been retrieved
+          </ul>
+        </td>
+        <td>Fired after an artifact is retrieved from cache to a local location</td>
+    </tr>
     <tr><td>pre-publish-artifact <br/><span class="since">since 2.0</span></td>
         <td>
           <ul>

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/EndRetrieveArtifactEvent.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/EndRetrieveArtifactEvent.java?rev=778769&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/EndRetrieveArtifactEvent.java
(added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/EndRetrieveArtifactEvent.java
Tue May 26 15:50:41 2009
@@ -0,0 +1,31 @@
+/*
+ *  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.ivy.core.event.retrieve;
+
+import java.io.File;
+
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+
+public class EndRetrieveArtifactEvent extends RetrieveArtifactEvent {
+    public static final String NAME = "pre-retrieve-artifact";
+
+    public EndRetrieveArtifactEvent(
+            ArtifactDownloadReport report, File destFile) {
+        super(NAME, report, destFile);
+    }
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/EndRetrieveArtifactEvent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/RetrieveArtifactEvent.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/RetrieveArtifactEvent.java?rev=778769&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/RetrieveArtifactEvent.java
(added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/RetrieveArtifactEvent.java
Tue May 26 15:50:41 2009
@@ -0,0 +1,57 @@
+/*
+ *  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.ivy.core.event.retrieve;
+
+import java.io.File;
+
+import org.apache.ivy.core.event.IvyEvent;
+import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+
+public class RetrieveArtifactEvent extends IvyEvent {
+    private ArtifactDownloadReport report;
+
+    private File destFile;
+
+    public RetrieveArtifactEvent(
+            String name,
+            ArtifactDownloadReport report, File destFile) {
+        super(name);
+        addArtifactAttributes(report.getArtifact());
+        
+        this.report = report;
+        this.destFile = destFile;
+        addAttribute("from", report.getLocalFile().getAbsolutePath());
+        addAttribute("to", destFile.getAbsolutePath());
+        addAttribute("size", String.valueOf(destFile.length()));        
+    }
+
+    protected void addArtifactAttributes(Artifact artifact) {
+        addMridAttributes(artifact.getModuleRevisionId());
+        addAttributes(artifact.getAttributes());
+        addAttribute("metadata", String.valueOf(artifact.isMetadata()));
+    }
+    
+    public File getDestFile() {
+        return destFile;
+    }
+    
+    public ArtifactDownloadReport getReport() {
+        return report;
+    }
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/RetrieveArtifactEvent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/StartRetrieveArtifactEvent.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/StartRetrieveArtifactEvent.java?rev=778769&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/StartRetrieveArtifactEvent.java
(added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/StartRetrieveArtifactEvent.java
Tue May 26 15:50:41 2009
@@ -0,0 +1,31 @@
+/*
+ *  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.ivy.core.event.retrieve;
+
+import java.io.File;
+
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+
+public class StartRetrieveArtifactEvent extends RetrieveArtifactEvent {
+    public static final String NAME = "pre-retrieve-artifact";
+
+    public StartRetrieveArtifactEvent(
+            ArtifactDownloadReport report, File destFile) {
+        super(NAME, report, destFile);
+    }
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/retrieve/StartRetrieveArtifactEvent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java?rev=778769&r1=778768&r2=778769&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java Tue May 26
15:50:41 2009
@@ -38,7 +38,9 @@
 import org.apache.ivy.core.LogOptions;
 import org.apache.ivy.core.cache.ResolutionCacheManager;
 import org.apache.ivy.core.event.EventManager;
+import org.apache.ivy.core.event.retrieve.EndRetrieveArtifactEvent;
 import org.apache.ivy.core.event.retrieve.EndRetrieveEvent;
+import org.apache.ivy.core.event.retrieve.StartRetrieveArtifactEvent;
 import org.apache.ivy.core.event.retrieve.StartRetrieveEvent;
 import org.apache.ivy.core.module.descriptor.Artifact;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
@@ -128,11 +130,19 @@
                     File destFile = settings.resolveFile((String) it2.next());
                     if (!settings.isCheckUpToDate() || !upToDate(archive, destFile)) {
                         Message.verbose("\t\tto " + destFile);
+                        if (this.eventManager != null) {
+                            this.eventManager.fireIvyEvent(
+                                new StartRetrieveArtifactEvent(artifact, destFile));
+                        }
                         if (options.isMakeSymlinks()) {
                             FileUtil.symlink(archive, destFile, null, true);
                         } else {
                             FileUtil.copy(archive, destFile, null, true);
                         }
+                        if (this.eventManager != null) {
+                            this.eventManager.fireIvyEvent(
+                                new EndRetrieveArtifactEvent(artifact, destFile));
+                        }
                         totalCopiedSize += destFile.length();
                         targetsCopied++;
                     } else {

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java?rev=778769&r1=778768&r2=778769&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java Tue May 26
15:50:41 2009
@@ -28,7 +28,9 @@
 import org.apache.ivy.core.IvyPatternHelper;
 import org.apache.ivy.core.event.IvyEvent;
 import org.apache.ivy.core.event.IvyListener;
+import org.apache.ivy.core.event.retrieve.EndRetrieveArtifactEvent;
 import org.apache.ivy.core.event.retrieve.EndRetrieveEvent;
+import org.apache.ivy.core.event.retrieve.StartRetrieveArtifactEvent;
 import org.apache.ivy.core.event.retrieve.StartRetrieveEvent;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.report.ResolveReport;
@@ -141,10 +143,12 @@
         ModuleDescriptor md = report.getModuleDescriptor();
         String pattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]";
         ivy.retrieve(md.getModuleRevisionId(), pattern, getRetrieveOptions());
-        assertEquals(2, events.size());
+        assertEquals(4, events.size());
         assertTrue(events.get(0) instanceof StartRetrieveEvent);
-        assertTrue(events.get(1) instanceof EndRetrieveEvent);
-        EndRetrieveEvent ev = (EndRetrieveEvent) events.get(1);
+        assertTrue(events.get(1) instanceof StartRetrieveArtifactEvent);
+        assertTrue(events.get(2) instanceof EndRetrieveArtifactEvent);
+        assertTrue(events.get(3) instanceof EndRetrieveEvent);
+        EndRetrieveEvent ev = (EndRetrieveEvent) events.get(3);
         assertEquals(1, ev.getNbCopied());
         assertEquals(0, ev.getNbUpToDate());
 



Mime
View raw message