#8 the ant task doesn't take absolute path

code-gen
open
Artur Hefczyc
5
2002-06-04
2002-06-04
Anonymous
No

<unitgen update="true" input="${javasrc-dir}"
output="${testsrc-dir}">, if the javasrc-dir is absolute path,
the unitgen will no find anything, same for the setOutput
It could be easily fixed by checking if the path is absolute
like the following:

public void init()
{
/* Setting some parameters to different default values than
they are during runing unittestsgen as standalone
application */
prop.setProperty(PAR_UPDATE, "true");
prop.setProperty(PAR_QUIET, "true");
setInput(GenerateTests.INPUT_DIR);
setOutput(GenerateTests.OUTPUT_DIR);
}
public void setInput(String indir)
{
setDirProperty(PAR_INPUT, indir);
}
public void setOutput(String outdir)
{
setDirProperty(PAR_OUTPUT, outdir);
}

private void setDirProperty(String name, String value)
{
if(isAbsolutePath(value))
prop.setProperty(name, value);
else
prop.setProperty(name, project.getBaseDir()
+getSeparatorForProjectBase()+value);
}
private String getSeparatorForProjectBase()
{
if (project.getBaseDir().toString().endsWith
(File.separator))
return "";
else
return File.separator;
}
private boolean isAbsolutePath(String dirString)
{
if(dirString != null && (dirString.startsWith("/") ||
dirString.startsWith("\\") ||
dirString.startsWith(File.separator) ||
dirString.charAt(1) == ':' ))
return true;
else
return false;
}

Discussion