Changeset 78
- Timestamp:
- 06/16/06 13:49:48 (2 years ago)
- Files:
-
- branches/2.2/classes/phing/tasks/system/PhingTask.php (modified) (2 diffs)
- trunk/classes/phing/tasks/system/PhingTask.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.2/classes/phing/tasks/system/PhingTask.php
r59 r78 205 205 $savedTarget = $this->newTarget; 206 206 207 $savedBasedirAbsPath = null; // this is used to save the basedir *if* we change it 208 207 209 try { 210 208 211 if ($this->newProject === null) { 209 212 $this->reinit(); 210 213 } 211 214 212 if (($this->dir === null) && ($this->inheritAll)) {213 $this->dir = $this->getProject()->getBaseDir();214 }215 215 $this->initializeProject(); 216 216 217 if ($this->dir !== null) { 217 $this->newProject->setBaseDir($this->dir); 218 219 $dirAbsPath = $this->dir->getAbsolutePath(); 220 221 // BE CAREFUL! -- when the basedir is changed for a project, 222 // all calls to getAbsolutePath() on a relative-path dir will 223 // be made relative to the project's basedir! This means 224 // that subsequent calls to $this->dir->getAbsolutePath() will be WRONG! 225 226 // We need to save the current project's basedir first. 227 $savedBasedirAbsPath = $this->getProject()->getBasedir()->getAbsolutePath(); 228 229 $this->newProject->setBasedir($this->dir); 230 231 // Now we must reset $this->dir so that it continues to resolve to the same 232 // path. 233 $this->dir = new PhingFile($dirAbsPath); 234 218 235 if ($savedDir !== null) { // has been set explicitly 219 236 $this->newProject->setInheritedProperty("project.basedir", $this->dir->getAbsolutePath()); 220 } 237 } 238 221 239 } else { 222 $this->dir = $this->getProject()->getBaseDir(); 240 241 // Since we're not changing the basedir here (for file resolution), 242 // we don't need to worry about any side-effects in this scanrio. 243 $this->dir = $this->getProject()->getBasedir(); 223 244 } 224 245 … … 258 279 $this->log($e->getMessage(), PROJECT_MSG_ERR); 259 280 260 // important!!! continue on to perform cleanup 261 // tasks. 262 } 263 264 // } finally { 265 // restore values (prevent side-effects) 266 // !this must match code in catch () {} block! 281 // important!!! continue on to perform cleanup tasks. 282 } 283 284 285 // reset environment values to prevent side-effects. 286 267 287 $this->newProject = null; 268 288 $pkeys = array_keys($this->properties); 269 289 foreach($pkeys as $k) { 270 290 $this->properties[$k]->setProject(null); 271 } 291 } 292 272 293 $this->dir = $savedDir; 273 294 $this->phingFile = $savedPhingFile; 274 295 $this->newTarget = $savedTarget; 275 296 276 // [HL] change back to correct dir 277 if ($this->dir !== null) { 278 chdir($this->dir->getAbsolutePath()); 279 } 280 281 if ($this->haltOnFailure == true && $buildFailed == true) 282 throw new BuildException("Execution of the target buildfile failed. Aborting."); 297 // If the basedir for any project was changed, we need to set that back here. 298 if ($savedBasedirAbsPath !== null) { 299 chdir($savedBasedirAbsPath); 300 } 301 302 if ($this->haltOnFailure && $buildFailed) { 303 throw new BuildException("Execution of the target buildfile failed. Aborting."); 304 } 283 305 } 284 306 trunk/classes/phing/tasks/system/PhingTask.php
r55 r78 205 205 $savedTarget = $this->newTarget; 206 206 207 $savedBasedirAbsPath = null; // this is used to save the basedir *if* we change it 208 207 209 try { 210 208 211 if ($this->newProject === null) { 209 212 $this->reinit(); 210 213 } 211 214 212 if (($this->dir === null) && ($this->inheritAll)) {213 $this->dir = $this->getProject()->getBaseDir();214 }215 215 $this->initializeProject(); 216 216 217 if ($this->dir !== null) { 217 $this->newProject->setBaseDir($this->dir); 218 219 $dirAbsPath = $this->dir->getAbsolutePath(); 220 221 // BE CAREFUL! -- when the basedir is changed for a project, 222 // all calls to getAbsolutePath() on a relative-path dir will 223 // be made relative to the project's basedir! This means 224 // that subsequent calls to $this->dir->getAbsolutePath() will be WRONG! 225 226 // We need to save the current project's basedir first. 227 $savedBasedirAbsPath = $this->getProject()->getBasedir()->getAbsolutePath(); 228 229 $this->newProject->setBasedir($this->dir); 230 231 // Now we must reset $this->dir so that it continues to resolve to the same 232 // path. 233 $this->dir = new PhingFile($dirAbsPath); 234 218 235 if ($savedDir !== null) { // has been set explicitly 219 236 $this->newProject->setInheritedProperty("project.basedir", $this->dir->getAbsolutePath()); 220 } 237 } 238 221 239 } else { 222 $this->dir = $this->getProject()->getBaseDir(); 240 241 // Since we're not changing the basedir here (for file resolution), 242 // we don't need to worry about any side-effects in this scanrio. 243 $this->dir = $this->getProject()->getBasedir(); 223 244 } 224 245 … … 258 279 $this->log($e->getMessage(), PROJECT_MSG_ERR); 259 280 260 // important!!! continue on to perform cleanup 261 // tasks. 262 } 263 264 // } finally { 265 // restore values (prevent side-effects) 266 // !this must match code in catch () {} block! 281 // important!!! continue on to perform cleanup tasks. 282 } 283 284 285 // reset environment values to prevent side-effects. 286 267 287 $this->newProject = null; 268 288 $pkeys = array_keys($this->properties); 269 289 foreach($pkeys as $k) { 270 290 $this->properties[$k]->setProject(null); 271 } 291 } 292 272 293 $this->dir = $savedDir; 273 294 $this->phingFile = $savedPhingFile; 274 295 $this->newTarget = $savedTarget; 275 296 276 // [HL] change back to correct dir 277 if ($this->dir !== null) { 278 chdir($this->dir->getAbsolutePath()); 279 } 280 281 if ($this->haltOnFailure == true && $buildFailed == true) 282 throw new BuildException("Execution of the target buildfile failed. Aborting."); 297 // If the basedir for any project was changed, we need to set that back here. 298 if ($savedBasedirAbsPath !== null) { 299 chdir($savedBasedirAbsPath); 300 } 301 302 if ($this->haltOnFailure && $buildFailed) { 303 throw new BuildException("Execution of the target buildfile failed. Aborting."); 304 } 283 305 } 284 306
