Release of Hamcrest 2.1

Overview

Hamcrest 2.1 was released on 12/20/2018. It seems that what was previously divided into multiple jars has been integrated into one jar. The procedure for upgrading from version 1.x is also available on the official website.

Hamcrest official website

Major changes

--As mentioned above, the method of providing the jar has changed. --The org.hamcrest.Factory annotation has been removed.

Release Note hamcrest-2.1

How to write pom.xml

It's simple because there is only one.

<dependency>
    <groupId>org.hamcrest</groupId>
    <artifactId>hamcrest</artifactId>
    <version>2.1</version>
    <scope>test</scope>
</dependency>

How to write build.gradle

It's simple because there is only one.

apply plugin: 'java'

dependencies {
    testImplementation 'org.hamcrest:hamcrest:2.1'
}

Precautions when upgrading

Since JUnit4 depends on hamcrest-core-1.3.jar, it is not possible to resolve the dependency well with maven etc. as it is. Therefore, hamcrest seems to solve this problem by releasing the empty hamcrest-core and hamcrest-library.

If there are other libraries that also depend on hamcrest-core-1.3, the following measures will be taken.

In build.gradle, write as follows.

apply plugin: 'java'

dependencies {
    testImplementation 'org.hamcrest:hamcrest:2.1'
    testImplementation 'org.hamcrest:hamcrest-library:2.1'
    testImplementation 'junit:junit:4.12'
}

In pom.xml, write as follows.

The official website explains that if you do not list hamcrest-library before other dependencies, versions older than hamcrest-library 2.1 will be used.

<dependencies>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest</artifactId>
        <version>2.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-library</artifactId>
        <version>2.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
</dependencies>

Recommended Posts

Release of Hamcrest 2.1
12 of Array