How to call ant and show logs
Answered
I want idea call an ant target after vcs commit suc so I override CheckinHandler#checkinSuccessful method.Here is my code:
final String projectPath = myProject.getBaseDir().getPath();
ApplicationManager.getApplication().invokeAndWait(()->{
int result = Messages.showYesNoDialog("xx", "xx", Messages.getQuestionIcon());
if (result == Messages.YES) {
try {
Process p =
Runtime.getRuntime().exec("cmd /c cmd.exe /c ant -f " + projectPath + File.pathSeparator + "build-test-servers.xml 打包");
p.waitFor();
final int exitValue = p.exitValue();
if (exitValue == 0) {
Messages.showInfoMessage("xx","xx");
}else{
Messages.showInfoMessage("xx","xx");
}
}
catch (IOException e) {
e.printStackTrace();
}
catch (InterruptedException e) {
e.printStackTrace();
}
}else{
System.out.println();
}
}, ModalityState.NON_MODAL);
}
but there is no logs,so how can I let idea show logs in "Messages windows"?
Please sign in to leave a comment.
Please try java.lang.ProcessBuilder instead of Runtime.getRuntime().exec(...) to get ant output.
As for messaging you can at least use com.intellij.notification.Notification to show OK/Warning/Error message.
Is it not possible to use the bundled ant plugin in intellij.
If yes, how do I access it. ?
Some plugins do it (For example "Eclipser", https://github.com/kukido/eclipser). You have to add dependency in plugin.xml like this:
Doesn't seem to work. I just simple have to add <depends>AntSupport</depends>

or am I missing some other configuration
EDIT:: It works if I add the following line in build.gradle