我已经设法scriptdef
在JavaScript中破解了它。
任何想法如何做得更好?
<scriptdef name="localization-regen" language="javascript">
<attribute name="input.file.path"/>
<attribute name="output.file.category"/>
<attribute name="output.file.package"/>
<attribute name="output.file.dir"/>
<attribute name="output.property"/>
<![CDATA[
importPackage(java.io);
inputFilePath = attributes.get("input.file.path");
outputFileCategory = attributes.get("output.file.category");
outputFilePackage = attributes.get("output.file.package");
outputFileDir = attributes.get("output.file.dir");
outputFileClass = "LocalizationKeys" + outputFileCategory.substring(0, 1).toUpperCase() + outputFileCategory.substring(1, outputFileCategory.length());
inputFile = new File(inputFilePath);
inputStream = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile)));
outputLines = "";
for(line = inputStream.readLine(); line != null; line = inputStream.readLine())
{
vars = line.split("=");
c = vars[0];
if(c.substring(0, 1) == "#") continue;
outputLines += "\t\tpublic static const " + c + ":String = \"" + c + "\";\n";
}
output = "";
output = "package " + outputFilePackage + "\n"
+ "{\n"
+ "\tpublic final class " + outputFileClass + "\n"
+ "\t{\n"
+ outputLines
+ "\t}\n"
+ "}";
outputFilePath = outputFileDir + "/" + outputFileClass+ ".as";
out = new BufferedWriter(new FileWriter(outputFilePath));
out.write(output, 0, output.length);
out.flush();
out.close();
]]>
</scriptdef>