void (Description d) { final TargetVersions targetVersions = d.getAnnotation(TargetVersions.class); if (targetVersions == null) return; myMatcher = new CustomMatcher<String>("Gradle version '" + Arrays.toString(targetVersions.value()) + "'") { @Override public boolean matches(Object item) { return item instanceof String && new VersionMatcher(GradleVersion.version(item.toString())).isVersionMatch(targetVersions); } }; }