ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 45739] New: Problems with BaseDir when the ant is started as Java library from Java Application
Date Thu, 04 Sep 2008 12:22:19 GMT

           Summary: Problems with BaseDir when the ant is started as Java
                    library from Java Application
           Product: Ant
           Version: 1.7.1
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: Core

I try to start ant script using ant as java library from Java application. The
start is realized as follow:
    File buildXmlFile = new File("C:\a\b\z.xml");
    List<String> command = new ArrayList<String>();
    Main ant = new Main();
    ant.startAnt(command.toArray(new String[command.size()]), null, null);

The content of build xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<project name="SSHAntScriptTest" default="default" basedir=".">
    <description>Build file for SSH Ant Script tests.</description>
    <scp file="test.txt" todir="${username}:${password}@${host}:/home/bc"/>

The xml build file location is different from the execution directory.
When that execution is initiated from the command prompt like that everything
is OK:
c:\somedir>ant -buildfile c:\anotherdir>buildfile.xml

When I try to start the same with the same parameters as java library the
text.txt file can not be founded. Ant looks for the file in execution directory
"c:\somedir\test.txt" instead in buildfile directory "c:\anotherdir\test.txt".

To fix this at the moment the following changes are made:
1. The user.dir is changed:
   File dir = buildXmlFile.getParentFile();
   System.getProperties().put("user.dir", dir.getAbsolutePath());
2. The method runBuild from the Main class is fixed as follow:
   private void runBuild(ClassLoader coreLoader) throws BuildException {

      // 2008-Sep-04: Bug Fix from Miro.

I try to put that fix before project.init() without result.

If you need I can send you one small project as test case.

The big problem is that I do some changes in System Properties and that the
application is multi-thread and multi-tasking and because System Properties are
global (static) for all instances in the current JVM.

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

View raw message