AntBuildTarget (@Nullable Project project, String fileUrl, String targetName) { if (fileUrl == null || targetName == null || project == null) { return null; } final VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(fileUrl); if (vFile == null) { return null; } final AntConfigurationImpl antConfiguration = (AntConfigurationImpl)AntConfiguration.getInstance(project); for (AntBuildFile buildFile : antConfiguration.getBuildFileList()) { if (vFile.equals(buildFile.getVirtualFile())) { final AntBuildTarget target = buildFile.getModel().findTarget(targetName); if (target != null) { return target; } for (AntBuildTarget metaTarget : antConfiguration.getMetaTargets(buildFile)) { if (targetName.equals(metaTarget.getName())) { return metaTarget; } } return null; } } return null; }