incubator-ivy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xav...@apache.org
Subject svn commit: r536990 - in /incubator/ivy/core/trunk: ./ src/java/org/apache/ivy/ant/ src/java/org/apache/ivy/core/ test/java/org/apache/ivy/ant/
Date Thu, 10 May 2007 20:44:34 GMT
Author: xavier
Date: Thu May 10 13:44:32 2007
New Revision: 536990

URL: http://svn.apache.org/viewvc?view=rev&rev=536990
Log:
FIX: Ant project reference lost from context on multiple ant calls in single thread (IVY-497)
(thanks to Jaroslaw Wypychowski)

Modified:
    incubator/ivy/core/trunk/CHANGES.txt
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntBuildTrigger.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntCallTrigger.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCheck.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConfigure.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConvertPom.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyExtractFromSources.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyFindRevision.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyListModules.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyContext.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java

Modified: incubator/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/CHANGES.txt?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/CHANGES.txt (original)
+++ incubator/ivy/core/trunk/CHANGES.txt Thu May 10 13:44:32 2007
@@ -43,6 +43,7 @@
 	John Shields
 	Johan Stuyts
 	John Williams
+	Jaroslaw Wypychowski
 
    version in SVN
 =====================================
@@ -50,6 +51,7 @@
 
 - IMPROVEMENT: Allow "main" parameters to be passed directly (instead of using -args flag)
(IVY-480) (thanks to Archie Cobbs)
 
+- FIX: Ant project reference lost from context on multiple ant calls in single thread (IVY-497)
(thanks to Jaroslaw Wypychowski)
 - FIX: EOL in the doc pages (IVY-470)
 - FIX: Cache is storing ArtifactOrigin properties with no guarantee of unicity and types
telescope during resolve. (IVY-430) (thanks to Stephane Bailliez)
 - FIX: ivy:install ant task does not fail on error (IVY-475) (thanks to Jeffrey Blatttman)

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntBuildTrigger.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntBuildTrigger.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntBuildTrigger.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntBuildTrigger.java Thu May 10 13:44:32
2007
@@ -64,7 +64,7 @@
 				Message.verbose("target build file already built, skipping: "+f);
 			} else {
 				Ant ant = new Ant();
-				Project project = (Project)IvyContext.getContext().get(IvyTask.ANT_PROJECT_CONTEXT_KEY);
+				Project project = (Project)IvyContext.getContext().peek(IvyTask.ANT_PROJECT_CONTEXT_KEY);
 				if (project == null) {
 					project = new Project();
 					project.init();

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntCallTrigger.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntCallTrigger.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntCallTrigger.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntCallTrigger.java Thu May 10 13:44:32
2007
@@ -57,7 +57,7 @@
 	private String _prefix;
 
 	public void progress(IvyEvent event) {
-		Project project = (Project)IvyContext.getContext().get(IvyTask.ANT_PROJECT_CONTEXT_KEY);
+		Project project = (Project)IvyContext.getContext().peek(IvyTask.ANT_PROJECT_CONTEXT_KEY);
 		if (project == null) {
 			Message.info("ant call trigger can only be used from an ant build. Ignoring.");
 			return;

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java Thu May
10 13:44:32 2007
@@ -49,7 +49,7 @@
         _value = value;
     }
 
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
     	prepareAndCheck();
 
         try {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java Thu May 10
13:44:32 2007
@@ -68,7 +68,7 @@
         _pattern = pattern;
     }
 
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
     	prepareAndCheck();
         if (_tofile == null) {
             throw new BuildException("no destination file name: please provide it through
parameter 'tofile'");

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java Thu May 10 13:44:32
2007
@@ -116,7 +116,7 @@
 		_delimiter = delimiter;
 	}
 	
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         if (_reference == null) {
             throw new BuildException("reference should be provided in ivy build list");
         }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java Thu May 10 13:44:32
2007
@@ -91,7 +91,7 @@
 		_prefix = prefix;
 	}
 
-	public void execute() throws BuildException {
+	public void doExecute() throws BuildException {
         if (_organisation == null) {
             throw new BuildException("no organisation provided for ivy findmodules");
         }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java Thu May 10 13:44:32
2007
@@ -49,7 +49,7 @@
     	}
     }
 
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         prepareAndCheck();
         if (_setid == null) {
             throw new BuildException("setid is required in ivy cachefileset");

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java Thu May 10 13:44:32
2007
@@ -50,7 +50,7 @@
         _id = id;
     }
 
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         prepareAndCheck();
         if (_pathid == null) {
         	if (_id != null) {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCheck.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCheck.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCheck.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCheck.java Thu May 10 13:44:32
2007
@@ -64,7 +64,7 @@
     }
     
 
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         try {
         Ivy ivy = getIvyInstance();
         if (_file != null) {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConfigure.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConfigure.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConfigure.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConfigure.java Thu May 10 13:44:32
2007
@@ -125,7 +125,7 @@
     	CredentialsStore.INSTANCE.addCredentials(c.getRealm(), c.getHost(), c.getUsername(),
c.getPasswd());
     }
 
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         try {
 	        loadDefaultProperties();
         } catch (Exception ex) {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConvertPom.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConvertPom.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConvertPom.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConvertPom.java Thu May 10 13:44:32
2007
@@ -53,7 +53,7 @@
     }
     
     
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         try {
             if (_pomFile == null) {
                 throw new BuildException("source pom file is required for convertpom task");

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java Thu May 10 13:44:32
2007
@@ -314,7 +314,7 @@
     	_conf = confs;
     }
 
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
     	Ivy ivy = getIvyInstance();
         IvySettings settings = ivy.getSettings();
         

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyExtractFromSources.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyExtractFromSources.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyExtractFromSources.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyExtractFromSources.java Thu May
10 13:44:32 2007
@@ -109,7 +109,7 @@
         _concat.addFileset(fileSet);
     }
     
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         configureConcat();
         Writer out = new StringWriter();
         _concat.setWriter(out);

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyFindRevision.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyFindRevision.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyFindRevision.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyFindRevision.java Thu May 10 13:44:32
2007
@@ -81,7 +81,7 @@
 	}
 
 
-	public void execute() throws BuildException {
+	public void doExecute() throws BuildException {
         if (_organisation == null) {
             throw new BuildException("no organisation provided for ivy findmodules");
         }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java Thu May 10 13:44:32
2007
@@ -49,7 +49,7 @@
         _file = file;
     }
 
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         Ivy ivy = getIvyInstance();
         IvySettings settings = ivy.getSettings();
         if (_file == null) {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java Thu May 10 13:44:32
2007
@@ -21,12 +21,11 @@
 
 import org.apache.ivy.Ivy;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.ResolveReport;
 import org.apache.ivy.core.settings.IvySettings;
 import org.apache.ivy.plugins.matcher.PatternMatcher;
 import org.apache.ivy.util.filter.FilterHelper;
 import org.apache.tools.ant.BuildException;
-import org.apache.ivy.core.report.ResolveReport;
-import org.apache.tools.ant.BuildException;
 
 /**
  * Allow to install a module or a set of module from repository to another one.
@@ -48,7 +47,7 @@
     private String _matcher = PatternMatcher.EXACT;
     private boolean _haltOnFailure = true;
     
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         Ivy ivy = getIvyInstance();
         IvySettings settings = ivy.getSettings();
         if (_cache == null) {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyListModules.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyListModules.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyListModules.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyListModules.java Thu May 10 13:44:32
2007
@@ -97,7 +97,7 @@
 		_branch = branch;
 	}
 
-	public void execute() throws BuildException {
+	public void doExecute() throws BuildException {
         if (_organisation == null) {
             throw new BuildException("no organisation provided for ivy findmodules");
         }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java Thu May 10
13:44:32 2007
@@ -26,7 +26,6 @@
 import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.report.ResolveReport;
-import org.apache.ivy.core.resolve.ResolveOptions;
 import org.apache.ivy.core.settings.IvySettings;
 import org.apache.ivy.util.Message;
 import org.apache.ivy.util.StringUtils;

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java Thu May 10 13:44:32
2007
@@ -165,7 +165,7 @@
         _replacedynamicrev = replacedynamicrev;
     }
     
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         Ivy ivy = getIvyInstance();
         IvySettings settings = ivy.getSettings();
 

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java Thu May 10 13:44:32
2007
@@ -119,7 +119,7 @@
     	_resolveId = resolveId;
     }
 
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         Ivy ivy = getIvyInstance();
         IvySettings settings = ivy.getSettings();
         

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java Thu May
10 13:44:32 2007
@@ -64,7 +64,7 @@
     private String _xslext = "html";
     private List _params = new ArrayList();
     
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         Ivy ivy = getIvyInstance();
         IvySettings settings = ivy.getSettings();
         if (_cache == null) {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java Thu May 10 13:44:32
2007
@@ -133,7 +133,7 @@
     	return _failureProperty;
     }
     
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         Ivy ivy = getIvyInstance();
         IvySettings settings = ivy.getSettings();
         try {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java Thu May 10 13:44:32
2007
@@ -42,7 +42,7 @@
         _pattern = pattern;
     }
     
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
     	prepareAndCheck();
 
         _pattern = getProperty(_pattern, getSettings(), "ivy.retrieve.pattern");

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java Thu May 10 13:44:32
2007
@@ -31,7 +31,6 @@
 import org.apache.ivy.util.Message;
 import org.apache.ivy.util.StringUtils;
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
 
 
@@ -41,7 +40,7 @@
  * @author Xavier Hanin
  *
  */
-public class IvyTask extends Task {
+public abstract class IvyTask extends Task {
     public static final String ANT_PROJECT_CONTEXT_KEY = "ant-project";
 	private Boolean _validate = null; 
 
@@ -252,9 +251,42 @@
         return val;
     }
     
-    public void setProject(Project project) {
-    	super.setProject(project);
-    	IvyContext.getContext().set(ANT_PROJECT_CONTEXT_KEY, project);
+    /**
+     * Called when task starts its execution.
+     */
+    protected void prepareTask(){
+    	//push current project on the stack in context
+		IvyContext.getContext().push(ANT_PROJECT_CONTEXT_KEY, getProject());
+    }
+    
+    /**
+     * Called when task is about to finish
+     * Should clean up all state related information (stacks for example)
+     */
+    protected void finalizeTask(){
+		if(!IvyContext.getContext().pop(ANT_PROJECT_CONTEXT_KEY,getProject())){
+			Message.error("ANT project poped from stack not equals current !. Ignoring");
+		}
     }
+    
+    /**
+     * Ant task execute. 
+     * Calls prepareTask, doExecute, finalzeTask
+     */
+    public final void execute() throws BuildException{
+    	try{
+    		prepareTask();
+    		doExecute();
+    	} finally {
+    		finalizeTask();
+    	}
+    }
+
+    /**
+     * The real logic of task execution after project has been set in the context.
+     * MUST be implemented by subclasses
+     * @throws BuildException
+     */
+    public abstract void doExecute() throws BuildException;
     
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java Thu May 10 13:44:32 2007
@@ -92,7 +92,7 @@
         _value = value;
     }
     
-    public void execute() throws BuildException {
+    public void doExecute() throws BuildException {
         Ivy ivy = getIvyInstance();
         IvySettings settings = ivy.getSettings();
         if (getName() != null) {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyContext.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyContext.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyContext.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyContext.java Thu May 10 13:44:32
2007
@@ -20,6 +20,8 @@
 import java.io.File;
 import java.lang.ref.WeakReference;
 import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 import java.util.Stack;
 
@@ -129,7 +131,89 @@
 	public void set(String key, Object value) {
 		_contextMap.put(key, new WeakReference(value));
 	}
+	
+	/**
+	 * Reads the first object from the list saved under given key in the context.
+	 * If value under key represents non List object then a RuntimeException is thrown.
+	 * @param key context key for the string
+	 * @return top object from the list (index 0) or null if no key or list empty
+	 */
+	public Object peek(String key){
+		synchronized(_contextMap){
+			Object o=_contextMap.get(key);
+			if(o==null) return null;
+			if(o instanceof List){
+				if(((List)o).size()==0) return null;
+				Object ret=((List)o).get(0);
+				return ret;
+			} else {
+				throw new RuntimeException("Cannot top from non List object "+o);
+			}
+		}
+	}
+	
+	/**
+	 * Removes and returns first object from the list saved under given key in the context.
+	 * If value under key represents non List object then a RuntimeException is thrown.
+	 * @param key context key for the string
+	 * @return top object from the list (index 0) or null if no key or list empty
+	 */
+	public Object pop(String key){
+		synchronized(_contextMap){
+			Object o=_contextMap.get(key);
+			if(o==null) return null;
+			if(o instanceof List){
+				if(((List)o).size()==0) return null;
+				Object ret=((List)o).remove(0);
+				return ret;
+			} else {
+				throw new RuntimeException("Cannot pop from non List object "+o);
+			}
+		}
+	}
 
+	/**
+	 * Removes and returns first object from the list saved under given key in the context
+	 * but only if it equals the given expectedValue - if not a false value is returned.
+	 * If value under key represents non List object then a RuntimeException is thrown.
+	 * @param key context key for the string
+	 * @return true if the r
+	 */
+	public boolean pop(String key, Object expectedValue){
+		synchronized(_contextMap){
+			Object o=_contextMap.get(key);
+			if(o==null) return false;
+			if(!o.equals(expectedValue)) return false;
+			if(o instanceof List){
+				if(((List)o).size()==0) return false;
+				((List)o).remove(0);
+				return true;
+			} else {
+				throw new RuntimeException("Cannot pop from non List object "+o);
+			}
+		}
+	}
+
+	/**
+	 * Puts a new object at the start of the list saved under given key in the context.
+	 * If value under key represents non List object then a RuntimeException is thrown.
+	 * If no list exists under given key a new LinkedList is created. This is kept
+	 * without WeakReference in opposite to the put() results.
+	 * @param key key context key for the string
+	 * @param value value to be saved under the key
+	 */
+	public void push(String key, Object value){
+		synchronized(_contextMap){
+			if(!_contextMap.containsKey(key)) _contextMap.put(key, new LinkedList());
+			Object o=_contextMap.get(key);
+			if(o instanceof List){
+				((List)o).add(0,value);
+			} else {
+				throw new RuntimeException("Cannot push to non List object "+o);
+			}
+		}
+	}
+	
 	public Thread getOperatingThread() {
 		return _operatingThread;
 	}

Modified: incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java?view=diff&rev=536990&r1=536989&r2=536990
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java (original)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java Thu
May 10 13:44:32 2007
@@ -42,7 +42,7 @@
         _project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
 
         _task = new IvyPostResolveTask() {
-        	public void execute() throws BuildException {
+        	public void doExecute() throws BuildException {
         		prepareAndCheck();
         	}
         };



Mime
View raw message