jsoup icon indicating copy to clipboard operation
jsoup copied to clipboard

Add Hamcrest Matchers

Open leonard84 opened this issue 7 years ago • 5 comments

Hi,

while developing a PR for Spring, it was suggested that most of the content would be a better fit for jsoup. So my question is would you be interested in integrating the hamcrest matchers into jsoup? This could be another package, or it could live in the jsoup package with a provided dependency on hamcrest.

The current Example code lives here https://github.com/leonard84/SPR-16097

This test shows how it is intended to be used: MatcherIT

This test shows the error messages that are produced MatcherTest

leonard84 avatar May 02 '18 09:05 leonard84

Hi @leonard84, this looks interesting. I think it would make most sense as an additional utility package that depends on Hamcrest / AspectJ (as appropriate) and on jsoup, and publish it through Maven under org.jsoup.hamcrest or something like that. What do you think?

jhy avatar May 03 '18 18:05 jhy

Just so I understand your answer correctly, you are saying that it should be a separate github project that publishes something like org.jsoup.hamcrest.jsoup-hamcrest?

Let me expand my suggestions from above:

  1. Make this project into a Multi-Module with two submodules
jsoup-parent
|-jsoup
\-jsoup-hamcrest
  1. Just add a org.jsoup.hamcrest package inside the normal jsoup jar and mark the hamcrest dependency as provided. This way it will not add a dependency in non test use-cases and in the test-case the hamcrest dependency will be present in most cases, e.g. provided by junit or added manually.

I would favor option 2. but could also help when you wish to implement option 1.

leonard84 avatar May 04 '18 15:05 leonard84

Thanks - both your options 1 and 2 make sense. I like the simplicity of 2. However I wonder what it will do to the jar size, and if we're adding a burden for users who won't need it. Can you take a stab at estimating the size impact? I'm not sure what would be "OK" but we can review from there. I guess we can always publish a proguard example too.

Otherwise we could take option 1.

jhy avatar May 12 '18 02:05 jhy

I noticed that jsoup is still on Java 7 compatibility, would you be willing to switch to Java 8 (7 is EOL for a long time)? The Matcher code uses lambdas and function references extensively, so it requires Java 8. If you don't want to upgrade, then we can still do it with Option 1 and have just the hamcrest module depend on Java 8.

leonard84 avatar May 14 '18 15:05 leonard84

Hi @jhy, could you please give me feedback whether you'll include this or what needs to be changed?

leonard84 avatar Jul 20 '18 19:07 leonard84