jcabi / jcabi/jcabi-github

jcabi-github requires Hamcrest to get a http request

Open
#1,668 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
307
Forks
144
Avg merge
1d 22h
Merged PRs (30d)
14

Description

I tried to use `jcabi-github` library in order to get some statistics from repos and during the first run get the next exception:
```java
Exception in thread "main" java.lang.NoClassDefFoundError: org/hamcrest/Matcher
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3429)
at java.base/java.lang.Class.getConstructor0(Class.java:3634)
at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2810)
at com.jcabi.http.request.DefaultResponse.as(DefaultResponse.java:161)
at com.jcabi.github.RtJson.fetch(RtJson.java:76)
at com.jcabi.github.RtRepo.json(RtRepo.java:250)
at com.jcabi.github.RepositoryStatistics.toMap(RepositoryStatistics.java:70)
at com.jcabi.github.RepositoryStatistics$Smart.integer(RepositoryStatistics.java:282)
at com.jcabi.github.RepositoryStatistics$Smart.forks(RepositoryStatistics.java:226)
at filter.statistics.GitHubMetrics.cells(GitHubMetrics.java:30)
at filter.statistics.StatisticsComposite.cells(StatisticsComposite.java:29)
at filter.statistics.StatisticsCaseLibrary.cells(StatisticsCaseLibrary.java:35)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1006)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at filter.Report.make(Report.java:28)
at filter.FilterLibraries.main(FilterLibraries.java:198)
Caused by: java.lang.ClassNotFoundException: org.hamcrest.Matcher
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 22 more
```

The reason is obvious - my app can't find `Hamcrest` classes in the classpath. It is rather confusing. Why do I need to keep a testing library in runtime? Of course, adding the next library helped me (pay attention to the `scope`):
```xml

org.hamcrest
hamcrest
2.2
compile

```
But maybe it is better to fix the plugin to avoid usage of testing libraries in runtime?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.