Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce multi release jar #575

Merged
merged 8 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
cache-id: "jdk8"
java: 8
dist: temurin
flags: "-DdisableStaticAnalysis"
flags: ""
- title: "Supported JDK 11"
continue-on-error: false
cache-id: "jdk11"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pitest-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 11
java-version: 17
- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pitest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ jobs:
path: ~/.m2/repository
key: ${{ runner.os }}-mvn-pitest-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-mvn-pitest
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 11
java-version: 17
- name: run pitest
# pitest has been bound to a profile called pitest for normal running
# we add config to analyse only changes made within a PR and treat surviving mutants as check errors
Expand Down
117 changes: 0 additions & 117 deletions .mvn/wrapper/MavenWrapperDownloader.java

This file was deleted.

Binary file removed .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 0 additions & 2 deletions .mvn/wrapper/maven-wrapper.properties

This file was deleted.

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<a name="3.x"/>

## [Unreleased]
### Changed
- EqualsVerifier is now released as a multi-release JAR file, in two variants: `equalsverifier` and `equalsverifier-nodep`. `equalsverifier-nodep` has all its dependencies shaded into a fat jar file; `equalsverifier` has dependencies. Note that until now, `equalsverifier` was the only artifact, and it was a shaded fat jar. ([Issue 575](https://github.com/jqno/equalsverifier/issues/575))

## [3.8.3] - 2022-01-25
### Added
Expand Down
49 changes: 36 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# EqualsVerifier

[![Apache License 2.0](https://img.shields.io/:license-Apache%20License%202.0-blue.svg?style=shield)](https://github.com/jqno/equalsverifier/blob/master/LICENSE.md)
[![Maven Central](https://img.shields.io/maven-central/v/nl.jqno.equalsverifier/equalsverifier.svg?style=shield)](https://maven-badges.herokuapp.com/maven-central/nl.jqno.equalsverifier/equalsverifier/)
[![Javadoc](https://javadoc.io/badge/nl.jqno.equalsverifier/equalsverifier.svg?color=blue)](https://javadoc.io/doc/nl.jqno.equalsverifier/equalsverifier)
Expand All @@ -18,48 +20,69 @@ The Maven coordinates are:
</dependency>
```


# Documentation

Please see the [project's website](https://www.jqno.nl/equalsverifier).


# Contribution

Pull requests are welcome! If you open one, please also [register an issue](https://code.google.com/p/equalsverifier/issues/list) or [send a message to the Google Group](https://groups.google.com/forum/?fromgroups#!forum/equalsverifier), so we can discuss it.

Pull requests are welcome! If you plan to open one, please also [register an issue](https://code.google.com/p/equalsverifier/issues/list) or [send a message to the Google Group](https://groups.google.com/forum/?fromgroups#!forum/equalsverifier), so we can discuss it first. It would be a shame to put in a lot of work on something that isn't a good fit for the project. Also, I can help you by giving pointers on where to find certain things.

# Development

## Build

To build EqualsVerifier, you need [Maven](https://maven.apache.org/). Just call `mvn` from the command-line, without any parameters, and you're done. Alternatively, you can use any IDE with Maven support.

There are several Maven profiles that can be enabled or disabled:

| profile | activation | purpose |
|-|-|-|
| `modules-jdk8` | JDK 8 up to but not including 11 | Build only the modules that are compatible with Java 8 and up. |
| `modules-jdk11` | JDK 11 up to but not including 16 | Build only the modules that are compatible with Java 11 and up. |
| `modules-jdk16` | JDK 16 | Build only the modules that are compatible with Java 16 and up. |
| `modules-jdk17` | JDK 17 and up | Build all modules and build releaseable artifacts. |
| `static-analysis` | JDK 17 and up, _and_ `disableStaticAnalysis` property must be off | Run static analysis checks. This only happens on a recent JDK. Can be disabled by running `mvn verify -DdisableStaticAnalysis` |
| `argline-preview` | `preview` property must be on | Enable Java preview features. Can be activated by running `mvn verify -Dpreview` |
| `argline-experimental` | `experimental` property must be on | Enables ByteBuddy experimental features; useful for testing EqualsVerifier on Early Access JDK builds. Can be activated by running `mvn verify -Dexperimental` |
| `pitest` | manual | Used by PITest integration on GitHub. Can be activated by running `mvn verify -Ppitest` |

## Formatting

EqualsVerifier uses [Prettier-Java](https://github.com/jhipster/prettier-java) through [Spotless](https://github.com/diffplug/spotless) to format Java files. You can call it using `mvn` (without any parameters), which will also run the tests and all the other static analysis. Or run `mvn spotless:apply` to only run the formatter.

## Modules

## Conditional tests
This project is a multi-module project to make it easier to deal with shading and multi-release jar files. See [this question on StackOverflow](https://stackoverflow.com/q/70541340/127863) for the rationale behind it.

The `src/test` folder contains, apart from the regular `java` folder, some version-specific `javaXX` folders that target specific JDKs. For instance, the `src/test/java16` folder contains unit tests that test things related to records. A Maven profile automatically picks up these folders if the JDK that runs the tests has at least that version. `nl.jqno.equalsverifier.internal.architecture.TestPresenceTest` checks that the tests are indeed picked up when the JDK version matches.
Here's a description of the modules:

| module | purpose |
|-|-|
| docs | project's Jekyll website |
| equalsverifier-core | the actual EqualsVerifier code |
| equalsverifier-11 | tests for Java 11 and up |
| equalsverifier-16 | logic for records, and corresponding tests |
| equalsverifier-17 | logic for sealed classes, and corresponding tests |
| equalsverifier-test-core | tests for the core code |
| equalsverifier-test-plumbing | helpers for tests that are used by multiple projects |
| equalsverifier-aggregator | generic release assembly description, and shared jacoco configuration |
| equalsverifier-release-main | release assembly for jar with dependencies |
| equalsverifier-release-nodep | release assembly for fat jar (with dependencies shaded in) |

## Signed JAR

The `lib/` folder contains a local Maven repository containing a signed JAR, used to test potential ClassLoader issues
<br/>
Here's how to install a JAR into it:<br>
<pre>
The `lib/` folder in the `equalsverifier-test-core` module contains a local Maven repository containing a signed JAR, used to test potential ClassLoader issues. Here's how to install a JAR into it:

```
mvn org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file \
-Dfile=&lt;path-to-file> -DgroupId=&lt;myGroup> \
-DartifactId=&lt;myArtifactId> -Dversion=&lt;myVersion> \
-Dpackaging=&lt;myPackaging> -DcreateChecksum=true \
-DlocalRepositoryPath=lib
</pre>
-DlocalRepositoryPath=equalsverifier-test-core/lib
```
The signed JAR itself can be found in [this repo](https://github.com/jqno/equalsverifier-signedjar-test).

# Disclaimer

Copyright 2009-2020 Jan Ouwens
Copyright 2009-2022 Jan Ouwens
File renamed without changes.
43 changes: 43 additions & 0 deletions equalsverifier-11/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier-parent</artifactId>
<version>3.8.4-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>

<artifactId>equalsverifier-11</artifactId>
<name>EqualsVerifier | JDK 11</name>

<properties>
<maven.compiler.release>11</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier-test-plumbing</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${version.junit-jupiter}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>${version.openjfx}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

37 changes: 37 additions & 0 deletions equalsverifier-16/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier-parent</artifactId>
<version>3.8.4-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>

<artifactId>equalsverifier-16</artifactId>
<name>EqualsVerifier | JDK 16</name>

<properties>
<maven.compiler.release>16</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier-test-plumbing</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${version.junit-jupiter}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package nl.jqno.equalsverifier.internal.reflection;

public final class RecordsHelper {

private RecordsHelper() {}

public static boolean isRecord(Class<?> type) {
return type.isRecord();
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package nl.jqno.equalsverifier.integration.extended_contract;

import static nl.jqno.equalsverifier.testhelpers.Util.defaultEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.internal.reflection.RecordsHelper;
import nl.jqno.equalsverifier.testhelpers.ExpectedException;
import org.junit.jupiter.api.Test;

public class RecordsTest {

@Test
public void sanityCheckForRecordsHelper() {
assertTrue(RecordsHelper.isRecord(SimpleRecord.class));
assertFalse(RecordsHelper.isRecord(String.class));
}

@Test
public void succeed_whenClassIsARecord() {
EqualsVerifier.forClass(SimpleRecord.class).verify();
Expand Down
Loading