SonarQubeTaskUtils { public static int getAntLoggerLever(Project project) { try { List<BuildListener> listeners = project.getBuildListeners(); for (BuildListener listener : listeners) { if (listener instanceof DefaultLogger) { DefaultLogger logger = (DefaultLogger) listener; Field field = DefaultLogger.class.getDeclaredField("msgOutputLevel"); field.setAccessible(true); return (Integer) field.get(logger); } } return 2; } catch (Exception e) { return 2; } } private  SonarQubeTaskUtils(); static URL getJarPath(); static int getAntLoggerLever(Project project); static String getTaskVersion();  }
@Test public void shouldGetAntLoggerLever() { Project project = new Project(); DefaultLogger logger = new DefaultLogger(); logger.setMessageOutputLevel(2); project.addBuildListener(logger); assertThat(SonarQubeTaskUtils.getAntLoggerLever(project)).isEqualTo(2); }