private void removeUITests() { File existingFile = new File(installedDirectory + "/src/test/resources/web-tests.xml"); if (existingFile.exists()) { parseXMLFile(existingFile, pojoName); // Remove tests in run-all-tests target Replace replace = (Replace) antProject.createTask("replace"); replace.setFile(existingFile); replace.setToken("," + pojoName + "Tests"); replace.execute(); } }
/** * Replace a token in the file. * @param fileName the file name to edit * @param token the token to replace * @param value the new token value */ public static void replace(final String fileName, final String token, final String value) { Replace replace = new Replace(); replace.setFile(new File(fileName)); replace.setToken(token); replace.setValue(value); replace.execute(); }
Replace replace = (Replace) antProject.createTask("replace"); replace.setFile(new File(hibernateCfgLocation)); replace.setToken(" <mapping class=\"" + className + "\"/>"); replace.execute();
private void parseXMLFile(File existingFile, String beanName) { String nameInComment = beanName; if (beanName == null) { nameInComment = pojoName; } Replace replace1 = (Replace) antProject.createTask("replace"); replace1.setFile(existingFile); replace1.setToken("<!--" + nameInComment + "-START-->"); replace1.setValue("REGULAR-START"); replace1.execute(); Replace replace2 = (Replace) antProject.createTask("replace"); replace2.setFile(existingFile); replace2.setToken("<!--" + nameInComment + "-END-->"); replace2.setValue("REGULAR-END"); replace2.execute(); ReplaceRegExp regExpTask = (ReplaceRegExp) antProject.createTask("replaceregexp"); regExpTask.setFile(existingFile); regExpTask.setMatch("REGULAR-START(?s:.)*REGULAR-END"); regExpTask.setReplace(""); regExpTask.setFlags("g"); regExpTask.execute(); }
private void parseXMLFile(File existingFile, String beanName, String tokenToReplace, String fileVariable) { String nameInComment = beanName; if (beanName == null) { nameInComment = pojoName; } Replace replace1 = (Replace) antProject.createTask("replace"); replace1.setFile(existingFile); replace1.setToken("<!--" + nameInComment + "-START-->"); replace1.setValue("REGULAR-START"); replace1.execute(); Replace replace2 = (Replace) antProject.createTask("replace"); replace2.setFile(existingFile); replace2.setToken("<!--" + nameInComment + "-END-->"); replace2.setValue("REGULAR-END"); replace2.execute(); ReplaceRegExp regExpTask = (ReplaceRegExp) antProject.createTask("replaceregexp"); regExpTask.setFile(existingFile); regExpTask.setMatch("REGULAR-START(?s:.)*REGULAR-END"); regExpTask.setReplace(""); regExpTask.setFlags("g"); regExpTask.execute(); Replace replaceData = (Replace) antProject.createTask("replace"); replaceData.setFile(existingFile); replaceData.setToken(tokenToReplace); String stringWithProperLineEndings = adjustLineEndingsForOS(antProject.getProperty(fileVariable)); replaceData.setValue(stringWithProperLineEndings); replaceData.execute(); }
/** * This file is the same as the method above, except for different comment placeholder formats. * Yeah, I know, it's ugly. * * @param existingFile file to merge with in project * @param beanName name of placeholder string that goes in comment */ private void parsePropertiesFile(File existingFile, String beanName) { String nameInComment = beanName; if (beanName == null) { nameInComment = pojoName; } Replace replace1 = (Replace) antProject.createTask("replace"); replace1.setFile(existingFile); replace1.setToken("# -- " + nameInComment + "-START"); replace1.setValue("REGULAR-START"); replace1.execute(); Replace replace2 = (Replace) antProject.createTask("replace"); replace2.setFile(existingFile); replace2.setToken("# -- " + nameInComment + "-END"); replace2.setValue("REGULAR-END"); replace2.execute(); ReplaceRegExp regExpTask = (ReplaceRegExp) antProject.createTask("replaceregexp"); regExpTask.setFile(existingFile); regExpTask.setMatch("REGULAR-START(?s:.)*REGULAR-END"); regExpTask.setReplace(""); regExpTask.setFlags("g"); regExpTask.execute(); }
/** * This file is the same as the method above, except for different comment placeholder formats. * Yeah, I know, it's ugly. * * @param existingFile file to merge with in project * @param beanName name of placeholder string that goes in comment */ private void parsePropertiesFile(File existingFile, String beanName) { String nameInComment = beanName; if (beanName == null) { nameInComment = pojoName; } Replace replace1 = (Replace) antProject.createTask("replace"); replace1.setFile(existingFile); replace1.setToken("# -- " + nameInComment + "-START"); replace1.setValue("REGULAR-START"); replace1.execute(); Replace replace2 = (Replace) antProject.createTask("replace"); replace2.setFile(existingFile); replace2.setToken("# -- " + nameInComment + "-END"); replace2.setValue("REGULAR-END"); replace2.execute(); ReplaceRegExp regExpTask = (ReplaceRegExp) antProject.createTask("replaceregexp"); regExpTask.setFile(existingFile); regExpTask.setMatch("REGULAR-START(?s:.)*REGULAR-END"); regExpTask.setReplace(""); regExpTask.setFlags("g"); regExpTask.execute(); }