aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-06-18 07:34:12 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-06-18 07:34:12 +0000
commit0c8b44743920959d428111a09b3fb2b7d458857b (patch)
tree3c674f3b504791a3d4175b9d1b484481e61576c1
parent5c9e5a2b16c813bcdb8a501b418579b8ec03a2b5 (diff)
parent612756b6f243e250a93104aae170545dce9b8d49 (diff)
downloadjacoco-0c8b44743920959d428111a09b3fb2b7d458857b.tar.gz
release-request-c9e3b153-009d-4386-b83e-337752602795-for-git_oc-mr1-release-4111654 snap-temp-L22900000075285650
Change-Id: Id2895c30a099a3f2eed63a6898e34667c07e8e8b
-rw-r--r--Android.mk58
-rw-r--r--README.android1
-rw-r--r--org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java10
-rw-r--r--org.jacoco.cli/src/MANIFEST.MF2
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/matcher/IncludeExcludeMatcherTest.java75
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/matcher/WildcardMatcherTest.java72
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/runtime/WildcardMatcherTest.java72
-rw-r--r--org.jacoco.core/src/org/jacoco/core/jacoco.properties9
-rw-r--r--org.jacoco.core/src/org/jacoco/core/matcher/ClassnameMatcher.java80
-rw-r--r--org.jacoco.core/src/org/jacoco/core/matcher/IncludeExcludeMatcher.java67
-rw-r--r--org.jacoco.core/src/org/jacoco/core/matcher/Predicate.java24
-rw-r--r--org.jacoco.core/src/org/jacoco/core/matcher/WildcardMatcher.java (renamed from org.jacoco.core/src/org/jacoco/core/runtime/WildcardMatcher.java)7
-rw-r--r--org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java1
-rw-r--r--org.jacoco.report/src/org/jacoco/report/check/Rule.java4
14 files changed, 384 insertions, 98 deletions
diff --git a/Android.mk b/Android.mk
index b55fb273..1804e6df 100644
--- a/Android.mk
+++ b/Android.mk
@@ -15,16 +15,6 @@
#
LOCAL_PATH := $(call my-dir)
-# Build jacoco from sources for the platform
-#
-# Note: this is only intended to be used for the platform development. This is *not* intended
-# to be used in the SDK where apps can use the official jacoco release.
-include $(CLEAR_VARS)
-
-jacoco_src_files := $(call all-java-files-under,org.jacoco.core/src)
-jacoco_src_files += $(call all-java-files-under,org.jacoco.agent/src)
-jacoco_src_files += $(call all-java-files-under,org.jacoco.agent.rt/src)
-
# Some Jacoco source files depend on classes that do not exist in Android. While these classes are
# not executed at runtime (because we use offline instrumentation), they will cause issues when
# compiling them with ART during dex pre-opting. Therefore, it would prevent from applying code
@@ -36,7 +26,18 @@ jacoco_android_exclude_list := \
%org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java \
%org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java
-LOCAL_SRC_FILES := $(filter-out $(jacoco_android_exclude_list),$(jacoco_src_files))
+
+# Build jacoco-agent from sources for the platform
+#
+# Note: this is only intended to be used for the platform development. This is *not* intended
+# to be used in the SDK where apps can use the official jacoco release.
+include $(CLEAR_VARS)
+
+jacocoagent_src_files := $(call all-java-files-under,org.jacoco.core/src)
+jacocoagent_src_files += $(call all-java-files-under,org.jacoco.agent/src)
+jacocoagent_src_files += $(call all-java-files-under,org.jacoco.agent.rt/src)
+
+LOCAL_SRC_FILES := $(filter-out $(jacoco_android_exclude_list),$(jacocoagent_src_files))
# In order to include Jacoco in core libraries, we cannot depend on anything in the
# bootclasspath (or we would create dependency cycle). Therefore we compile against
@@ -48,8 +49,28 @@ LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_JAVA_LIBRARIES := jacoco-asm
include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# Build jacoco-cli from sources for the platform
+include $(CLEAR_VARS)
+
+# TODO(jeffrygaston) it'd be nice to keep the build process and/or list of source files in sync with
+# what is defined in the pom.xml files, although it's probably much more trouble than it's worth
+jacococli_src_files += $(call all-java-files-under,org.jacoco.core/src)
+jacococli_src_files += $(call all-java-files-under,org.jacoco.report/src)
+jacococli_src_files += $(call all-java-files-under,org.jacoco.cli/src)
+LOCAL_JAVA_RESOURCE_DIRS := org.jacoco.core/src org.jacoco.report/src
+LOCAL_JAR_MANIFEST := org.jacoco.cli/src/MANIFEST.MF
+
+LOCAL_SRC_FILES := $(jacococli_src_files)
+
+LOCAL_MODULE := jacoco-cli
+LOCAL_STATIC_JAVA_LIBRARIES := jacoco-asm-host args4j-2.0.28
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+
#
-# Build asm-5.0.1 as a static library.
+# Build asm-5.0.1 as a static library for the device
#
include $(CLEAR_VARS)
@@ -62,3 +83,16 @@ LOCAL_JACK_FLAGS := -D jack.import.jar.debug-info=false
LOCAL_UNINSTALLABLE_MODULE := true
include $(BUILD_PREBUILT)
+
+
+#
+# Build asm-5.0.1 as a static library for the host
+#
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := jacoco-asm-host
+LOCAL_IS_HOST_MODULE := true
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+LOCAL_SRC_FILES := asm-debug-all-5.0.1$(COMMON_JAVA_PACKAGE_SUFFIX)
+
+include $(BUILD_PREBUILT)
diff --git a/README.android b/README.android
index 1e6118ab..21adf4d9 100644
--- a/README.android
+++ b/README.android
@@ -15,3 +15,4 @@ is the list of the changes:
1) Remove the creation of JmxRegistration in org.jacoco.agent.rt.internal.Agent.
2) Change default OutputMode to none in org.jacoco.core.runtime.AgentOptions
3) Merge https://github.com/jacoco/jacoco/pull/525
+4) Update the build process to match #3: evaluate jacoco.properties, and add MANIFEST.MF
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java
index 53d12387..cbd6a62b 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java
@@ -19,7 +19,7 @@ import java.security.ProtectionDomain;
import org.jacoco.core.instr.Instrumenter;
import org.jacoco.core.runtime.AgentOptions;
import org.jacoco.core.runtime.IRuntime;
-import org.jacoco.core.runtime.WildcardMatcher;
+import org.jacoco.core.matcher.WildcardMatcher;
/**
* Class file transformer to instrument classes for code coverage analysis.
@@ -120,16 +120,14 @@ public class CoverageTransformer implements ClassFileTransformer {
if (!inclNoLocationClasses && !hasSourceLocation(protectionDomain)) {
return false;
}
- if (exclClassloader.matches(loader.getClass().getName())) {
+ if (exclClassloader.apply(loader.getClass().getName())) {
return false;
}
}
return !classname.startsWith(AGENT_PREFIX) &&
-
- includes.matches(classname) &&
-
- !excludes.matches(classname);
+ includes.apply(classname) &&
+ !excludes.apply(classname);
}
/**
diff --git a/org.jacoco.cli/src/MANIFEST.MF b/org.jacoco.cli/src/MANIFEST.MF
new file mode 100644
index 00000000..bae94d55
--- /dev/null
+++ b/org.jacoco.cli/src/MANIFEST.MF
@@ -0,0 +1,2 @@
+Main-Class: org.jacoco.cli.internal.Main
+
diff --git a/org.jacoco.core.test/src/org/jacoco/core/matcher/IncludeExcludeMatcherTest.java b/org.jacoco.core.test/src/org/jacoco/core/matcher/IncludeExcludeMatcherTest.java
new file mode 100644
index 00000000..e0268956
--- /dev/null
+++ b/org.jacoco.core.test/src/org/jacoco/core/matcher/IncludeExcludeMatcherTest.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jeffry Gaston - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.matcher;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class IncludeExcludeMatcherTest {
+
+ @Test
+ public void testEmpty() {
+ assertTrue(new IncludeExcludeMatcher<String>().apply("includeMe"));
+ }
+
+ @Test
+ public void testSingleExclude() {
+ IncludeExcludeMatcher<String> matcher = new IncludeExcludeMatcher<String>()
+ .exclude(new WildcardMatcher("excluded"));
+ assertTrue(matcher.apply("included"));
+ assertFalse(matcher.apply("excluded"));
+ }
+
+ @Test
+ public void testMultipleExcludes() {
+ IncludeExcludeMatcher<String> matcher = new IncludeExcludeMatcher<String>().exclude(
+ new WildcardMatcher("excluded"))
+ .exclude(new WildcardMatcher("excluded2"));
+ assertTrue(matcher.apply("included"));
+ assertFalse(matcher.apply("excluded"));
+ assertFalse(matcher.apply("excluded2"));
+ }
+
+ @Test
+ public void testSingleInclude() {
+ IncludeExcludeMatcher<String> matcher = new IncludeExcludeMatcher<String>()
+ .include(new WildcardMatcher("include me"));
+ assertTrue(matcher.apply("include me"));
+ assertFalse(matcher.apply("not me"));
+ }
+
+ @Test
+ public void testIncludesAndExcludes() {
+ IncludeExcludeMatcher<String> matcher = new IncludeExcludeMatcher<String>()
+ .include(new WildcardMatcher("inclusion1"))
+ .include(new WildcardMatcher("me too"))
+ .exclude(new WildcardMatcher("not me"))
+ .exclude(new WildcardMatcher("nope"));
+ assertTrue(matcher.apply("inclusion1"));
+ assertTrue(matcher.apply("me too"));
+ assertFalse(matcher.apply("not me"));
+ assertFalse(matcher.apply("nope"));
+ assertFalse(matcher.apply("other"));
+ }
+
+ @Test
+ public void testExcludedInclusion() {
+ IncludeExcludeMatcher<String> matcher = new IncludeExcludeMatcher<String>()
+ .include(new WildcardMatcher("a"))
+ .exclude(new WildcardMatcher("a"));
+ assertFalse(matcher.apply("a"));
+ assertFalse(matcher.apply("b"));
+ }
+
+}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/matcher/WildcardMatcherTest.java b/org.jacoco.core.test/src/org/jacoco/core/matcher/WildcardMatcherTest.java
new file mode 100644
index 00000000..baf1dc2b
--- /dev/null
+++ b/org.jacoco.core.test/src/org/jacoco/core/matcher/WildcardMatcherTest.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.matcher;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class WildcardMatcherTest {
+
+ @Test
+ public void testEmpty() {
+ assertTrue(new WildcardMatcher("").apply(""));
+ assertFalse(new WildcardMatcher("").apply("abc"));
+ }
+
+ @Test
+ public void testExact() {
+ assertTrue(new WildcardMatcher("abc/def.txt").apply("abc/def.txt"));
+ }
+
+ @Test
+ public void testCaseSensitive() {
+ assertFalse(new WildcardMatcher("abcdef").apply("abcDef"));
+ assertFalse(new WildcardMatcher("ABCDEF").apply("AbCDEF"));
+ }
+
+ @Test
+ public void testQuote() {
+ assertFalse(new WildcardMatcher("rst.xyz").apply("rstAxyz"));
+ assertTrue(new WildcardMatcher("(x)+").apply("(x)+"));
+ }
+
+ @Test
+ public void testWildcards() {
+ assertTrue(new WildcardMatcher("*").apply(""));
+ assertTrue(new WildcardMatcher("*").apply("java/lang/Object"));
+ assertTrue(new WildcardMatcher("*Test").apply("jacoco/MatcherTest"));
+ assertTrue(new WildcardMatcher("Matcher*").apply("Matcher"));
+ assertTrue(new WildcardMatcher("Matcher*").apply("MatcherTest"));
+ assertTrue(new WildcardMatcher("a*b*a").apply("a-b-b-a"));
+ assertFalse(new WildcardMatcher("a*b*a").apply("alaska"));
+ assertTrue(new WildcardMatcher("Hello?orld").apply("HelloWorld"));
+ assertFalse(new WildcardMatcher("Hello?orld").apply("HelloWWWorld"));
+ assertTrue(new WildcardMatcher("?aco*").apply("jacoco"));
+ }
+
+ @Test
+ public void testMultiExpression() {
+ assertTrue(new WildcardMatcher("Hello:World").apply("World"));
+ assertTrue(new WildcardMatcher("Hello:World").apply("World"));
+ assertTrue(new WildcardMatcher("*Test:*Foo").apply("UnitTest"));
+ }
+
+ @Test
+ public void testDollar() {
+ assertTrue(new WildcardMatcher("*$*").apply("java/util/Map$Entry"));
+ assertTrue(new WildcardMatcher("*$$$*")
+ .apply("org/example/Enity$$$generated123"));
+ }
+
+}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/runtime/WildcardMatcherTest.java b/org.jacoco.core.test/src/org/jacoco/core/runtime/WildcardMatcherTest.java
deleted file mode 100644
index 10e012c4..00000000
--- a/org.jacoco.core.test/src/org/jacoco/core/runtime/WildcardMatcherTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.core.runtime;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-public class WildcardMatcherTest {
-
- @Test
- public void testEmpty() {
- assertTrue(new WildcardMatcher("").matches(""));
- assertFalse(new WildcardMatcher("").matches("abc"));
- }
-
- @Test
- public void testExact() {
- assertTrue(new WildcardMatcher("abc/def.txt").matches("abc/def.txt"));
- }
-
- @Test
- public void testCaseSensitive() {
- assertFalse(new WildcardMatcher("abcdef").matches("abcDef"));
- assertFalse(new WildcardMatcher("ABCDEF").matches("AbCDEF"));
- }
-
- @Test
- public void testQuote() {
- assertFalse(new WildcardMatcher("rst.xyz").matches("rstAxyz"));
- assertTrue(new WildcardMatcher("(x)+").matches("(x)+"));
- }
-
- @Test
- public void testWildcards() {
- assertTrue(new WildcardMatcher("*").matches(""));
- assertTrue(new WildcardMatcher("*").matches("java/lang/Object"));
- assertTrue(new WildcardMatcher("*Test").matches("jacoco/MatcherTest"));
- assertTrue(new WildcardMatcher("Matcher*").matches("Matcher"));
- assertTrue(new WildcardMatcher("Matcher*").matches("MatcherTest"));
- assertTrue(new WildcardMatcher("a*b*a").matches("a-b-b-a"));
- assertFalse(new WildcardMatcher("a*b*a").matches("alaska"));
- assertTrue(new WildcardMatcher("Hello?orld").matches("HelloWorld"));
- assertFalse(new WildcardMatcher("Hello?orld").matches("HelloWWWorld"));
- assertTrue(new WildcardMatcher("?aco*").matches("jacoco"));
- }
-
- @Test
- public void testMultiExpression() {
- assertTrue(new WildcardMatcher("Hello:World").matches("World"));
- assertTrue(new WildcardMatcher("Hello:World").matches("World"));
- assertTrue(new WildcardMatcher("*Test:*Foo").matches("UnitTest"));
- }
-
- @Test
- public void testDollar() {
- assertTrue(new WildcardMatcher("*$*").matches("java/util/Map$Entry"));
- assertTrue(new WildcardMatcher("*$$$*")
- .matches("org/example/Enity$$$generated123"));
- }
-
-}
diff --git a/org.jacoco.core/src/org/jacoco/core/jacoco.properties b/org.jacoco.core/src/org/jacoco/core/jacoco.properties
index 09493370..e2f9aca6 100644
--- a/org.jacoco.core/src/org/jacoco/core/jacoco.properties
+++ b/org.jacoco.core/src/org/jacoco/core/jacoco.properties
@@ -1,3 +1,6 @@
-VERSION=$qualified.bundle.version$
-HOMEURL=$jacoco.home.url$
-RUNTIMEPACKAGE=$jacoco.runtime.package.name$ \ No newline at end of file
+#This file is supposed to be processed by Maven, but Android doesn't run Maven
+#So in Android we've filled in the resulting values below
+VERSION=0.7.10.201704181138.android
+HOMEURL=http://www.jacoco.org/jacoco
+RUNTIMEPACKAGE=org.jacoco.agent.rt.internal
+
diff --git a/org.jacoco.core/src/org/jacoco/core/matcher/ClassnameMatcher.java b/org.jacoco.core/src/org/jacoco/core/matcher/ClassnameMatcher.java
new file mode 100644
index 00000000..939bd5fe
--- /dev/null
+++ b/org.jacoco.core/src/org/jacoco/core/matcher/ClassnameMatcher.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jeffry Gaston - initial API and implementation
+ *
+ *******************************************************************************/
+
+package org.jacoco.core.matcher;
+
+import java.util.List;
+
+import org.objectweb.asm.ClassReader;
+
+/**
+ * A ClassnameMatcher matches ClassReader objects based on their class name
+ */
+public class ClassnameMatcher implements Predicate<ClassReader> {
+ private IncludeExcludeMatcher<String> matcher = new IncludeExcludeMatcher<String>();
+
+ /**
+ * Includes the given pattern from the matches of this matcher
+ * @param pattern to include
+ * @return this object (for chaining)
+ */
+ public ClassnameMatcher include(String pattern) {
+ matcher.include(new WildcardMatcher(pattern));
+ return this;
+ }
+
+ /**
+ * Adds the given patterns as inclusions for this matcher
+ * @param patterns patterns to include
+ * @return this object (for chaining)
+ */
+ public ClassnameMatcher include(List<String> patterns) {
+ for (String pattern : patterns) {
+ include(pattern);
+ }
+ return this;
+ }
+
+ /**
+ * As the given pattern as an exclusion for this matcher
+ * @param pattern pattern to exclude
+ * @return this object (for chaining)
+ */
+ public ClassnameMatcher exclude(String pattern) {
+ matcher.exclude(new WildcardMatcher(pattern));
+ return this;
+ }
+
+ /**
+ * As the given patterns as exclusions for this matcher
+ * @param patterns patterns to include
+ * @return this object (for chaining)
+ */
+ public ClassnameMatcher exclude(List<String> patterns) {
+ for (String pattern : patterns) {
+ exclude(pattern);
+ }
+ return this;
+ }
+
+
+ /**
+ * Tells whether this matcher matches this class reader
+ * @param classReader the reader to match
+ * @return whether this matcher matches
+ */
+ @Override
+ public boolean apply(ClassReader classReader) {
+ return matcher.apply(classReader.getClassName().replaceAll("/", "."));
+ }
+
+}
diff --git a/org.jacoco.core/src/org/jacoco/core/matcher/IncludeExcludeMatcher.java b/org.jacoco.core/src/org/jacoco/core/matcher/IncludeExcludeMatcher.java
new file mode 100644
index 00000000..50f1d886
--- /dev/null
+++ b/org.jacoco.core/src/org/jacoco/core/matcher/IncludeExcludeMatcher.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jeffry Gaston - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.matcher;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * An IncludeExcludeMatcher matches a given input if
+ * at least one inclusion matches and no exclusions match.
+ */
+public class IncludeExcludeMatcher<T> implements Predicate<T> {
+ private List<Predicate<T>> inclusions = new ArrayList<Predicate<T>>();
+ private List<Predicate<T>> exclusions = new ArrayList<Predicate<T>>();
+
+ /**
+ * Includes the given matcher
+ * @param inclusion new matcher to include
+ * @return this object (for chaining several calls)
+ */
+ public IncludeExcludeMatcher include(Predicate<T> inclusion) {
+ inclusions.add(inclusion);
+ return this;
+ }
+
+ /**
+ * Excludes a given matcher
+ * @param exclusion
+ * @return this object (for chaining several calls)
+ */
+ public IncludeExcludeMatcher exclude(Predicate<T> exclusion) {
+ exclusions.add(exclusion);
+ return this;
+ }
+
+ /**
+ * Tells whether this matcher matches this string
+ * @param input the string match
+ * @return whether the matcher matches
+ */
+ @Override
+ public boolean apply(T input) {
+ // doesn't match if an exclusion matches
+ for (Predicate<T> exclusion : exclusions) {
+ if (exclusion.apply(input)) {
+ return false;
+ }
+ }
+ // does match if an inclusion matches
+ for (Predicate<T> inclusion : inclusions) {
+ if (inclusion.apply(input)) {
+ return true;
+ }
+ }
+ // no match; choose a default based on whether any includes were given
+ return (inclusions.size() == 0);
+ }
+}
diff --git a/org.jacoco.core/src/org/jacoco/core/matcher/Predicate.java b/org.jacoco.core/src/org/jacoco/core/matcher/Predicate.java
new file mode 100644
index 00000000..14d084b1
--- /dev/null
+++ b/org.jacoco.core/src/org/jacoco/core/matcher/Predicate.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jeffry Gaston - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.matcher;
+
+/**
+ * A simple interface telling whether a predicate matches an input.
+ * Once the minimum supported version of Java is Java 1.8, then this can be replaced with the
+ * built-in Java predicate.
+ * While it could work to add a dependency on a library providing a similar interface, we prefer
+ * to keep the number of dependencies low, to avoid forcing other dependencies onto
+ * any builds that depend on Jacoco.
+ */
+public interface Predicate<T> {
+ boolean apply(final T s);
+}
diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/WildcardMatcher.java b/org.jacoco.core/src/org/jacoco/core/matcher/WildcardMatcher.java
index 221e6ea5..6ae20c4f 100644
--- a/org.jacoco.core/src/org/jacoco/core/runtime/WildcardMatcher.java
+++ b/org.jacoco.core/src/org/jacoco/core/matcher/WildcardMatcher.java
@@ -9,7 +9,7 @@
* Marc R. Hoffmann - initial API and implementation
*
*******************************************************************************/
-package org.jacoco.core.runtime;
+package org.jacoco.core.matcher;
import java.util.regex.Pattern;
@@ -18,7 +18,7 @@ import java.util.regex.Pattern;
* Multiple expressions can be separated with a colon (:). In this case the
* expression matches if at least one part matches.
*/
-public class WildcardMatcher {
+public class WildcardMatcher implements Predicate<String> {
private final Pattern pattern;
@@ -67,7 +67,8 @@ public class WildcardMatcher {
* string to test
* @return <code>true</code>, if the expression matches
*/
- public boolean matches(final String s) {
+ @Override
+ public boolean apply(final String s) {
return pattern.matcher(s).matches();
}
diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java b/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java
index cf575127..6b4fb0c5 100644
--- a/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java
+++ b/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java
@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Pattern;
+import org.jacoco.core.matcher.WildcardMatcher;
/**
* Utility to create and parse options for the runtime agent. Options are
diff --git a/org.jacoco.report/src/org/jacoco/report/check/Rule.java b/org.jacoco.report/src/org/jacoco/report/check/Rule.java
index f34c6cdf..f424e81f 100644
--- a/org.jacoco.report/src/org/jacoco/report/check/Rule.java
+++ b/org.jacoco.report/src/org/jacoco/report/check/Rule.java
@@ -15,7 +15,7 @@ import java.util.ArrayList;
import java.util.List;
import org.jacoco.core.analysis.ICoverageNode.ElementType;
-import org.jacoco.core.runtime.WildcardMatcher;
+import org.jacoco.core.matcher.WildcardMatcher;
/**
* A rule applies for a certain element type and can define any number of limits
@@ -116,7 +116,7 @@ public final class Rule {
}
boolean matches(final String name) {
- return includesMatcher.matches(name) && !excludesMatcher.matches(name);
+ return includesMatcher.apply(name) && !excludesMatcher.apply(name);
}
}