ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 39295] New: - white spaces in path
Date Thu, 13 Apr 2006 09:18:06 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295

           Summary: white spaces in path
           Product: Ant
           Version: 1.6.5
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Keywords: PatchAvailable
          Severity: enhancement
          Priority: P2
         Component: Core
        AssignedTo: dev@ant.apache.org
        ReportedBy: wherka@o2.pl


A couple of weeks ago I found that sometimes there is problem with launching ant
when the path which is utilized to lookup the "jars" contains some blanks. I
investigated it and changed the code of ant-launcher a little bit. Now the path
is converted to URI and then back to URL, so we can forget about white spaces
and any other error-prone characters. It works perfectly for me - I think it can
be useful for others too.

*************************************************************
Changes in file org.apache.tools.ant.launch.Launcher.java:
1)
import java.net.URLEncoder;
2)
    private void run(String[] args) throws LaunchException, MalformedURLException {
//..
        // now update the class.path property
        StringBuffer baseClassPath
            = new StringBuffer(System.getProperty("java.class.path"));
        if (baseClassPath.charAt(baseClassPath.length() - 1)
                == File.pathSeparatorChar) {
            baseClassPath.setLength(baseClassPath.length() - 1);
        }
//--------------- my modifications -------------------
        URL[] tempJars = new URL[numJars] ;
        int count = 0;
        for(URL _url: jars)
        {        	         	
        	File _file = null;        	
        	_file = new File(_url.getFile());
            tempJars[count++] = _file.toURI().toURL();        	
        }                
        
        
        System.arraycopy(tempJars, 0, jars, 0, tempJars.length);        
//----------------- end of modifications ------------------------        
        for (int i = 0; i < jars.length; ++i) {
            baseClassPath.append(File.pathSeparatorChar);
            baseClassPath.append(Locator.fromURI(jars[i].toString()));
        }

//..
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message