Skip to content

Commit

Permalink
feat(compat): Provide JDK11 compatibilty through Multi-Release JAR
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseLion committed Sep 13, 2023
1 parent 544dba6 commit c7e4c57
Show file tree
Hide file tree
Showing 9 changed files with 908 additions and 66 deletions.
82 changes: 57 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@ buildscript {
}

plugins {
id 'checkstyle'
id 'jacoco'
id 'java-library'
id 'maven-publish'
id 'signing'
id('checkstyle')
id('jacoco')
id('java-library')
id('maven-publish')
id('signing')

id 'io.github.joselion.pretty-jupiter' version '3.0.1'
id 'io.github.joselion.strict-null-check' version '3.0.0'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0-rc-1'
id 'se.solrike.sonarlint' version '1.0.0-beta.15'
id('io.github.joselion.pretty-jupiter') version '3.0.1'
id('io.github.joselion.strict-null-check') version '3.0.0'
id('io.github.gradle-nexus.publish-plugin') version '2.0.0-rc-1'
id('me.champeau.mrjar') version '0.1.1'
id('name.remal.sonarlint') version '3.3.8'
}

group = 'io.github.joselion'

multiRelease {
targetVersions(11, 17, 20)
}

java {
sourceCompatibility = JavaLanguageVersion.of(17)
toolchain {
languageVersion = JavaLanguageVersion.of(20)
vendor = JvmVendorSpec.ORACLE
}
withJavadocJar()
Expand All @@ -42,21 +45,32 @@ jar {
from(sourceSets.main.allSource)
manifest {
attributes(
'Build-Jdk': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Build-Jdk-Spec': java.sourceCompatibility,
'Build-Timestamp': LocalDateTime.now().toString(),
'Created-By': "Gradle ${gradle.gradleVersion}",
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Package': "${project.group}.${project.name}",
)
}
}

sonarlint {
excludeRules = [
'java:S107', // Allow constructors with more than 7 parameters
'java:S3776', // Allow methods with more than 15 lines
'java:S4032', // Allow packages only containing `package-info.java`
]
includeRules = [
'java:S4266', // "Stream.collect()" calls should not be redundant
]
sonarLint {
setToolVersion('9.2.0.74516')
languages {
include('java')
}
rules {
enable(
'java:S4266', // "Stream.collect()" calls should not be redundant
)
disable(
'java:S107', // Allow constructors with more than 7 parameters
'java:S3776', // Allow methods with more than 15 lines
'java:S4032', // Allow packages only containing `package-info.java`
)
}
}

strictNullCheck {
Expand All @@ -83,20 +97,38 @@ repositories {
}

dependencies {
sonarlintPlugins('org.sonarsource.java:sonar-java-plugin:7.20.0.31692')

testImplementation('org.assertj:assertj-core:3.24.2')
testImplementation('org.mockito:mockito-core:5.5.0')
sonarlintCorePlugins('org.sonarsource.java:sonar-java-plugin:7.24.0.32100')
}

testing {
suites {
test {
configureEach {
useJUnitJupiter('5.10.0')

dependencies {
implementation('org.assertj:assertj-core:3.24.2')
implementation('org.mockito:mockito-core:5.5.0')
}

targets {
all {
testTask.configure {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(20)
}
}
}
}
}
}
}

tasks.withType(JavaCompile).matching { it.name.contains('Test') }.configureEach {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(20)
}
}

prettyJupiter {
duration.threshold = 150
}
Expand Down
11 changes: 4 additions & 7 deletions buildscript-gradle.lockfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
io.github.furstenheim:copy_down:1.1=classpath
io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin:2.0.0-rc-1=classpath
io.github.gradle-nexus:publish-plugin:2.0.0-rc-1=classpath
io.github.joselion.pretty-jupiter:io.github.joselion.pretty-jupiter.gradle.plugin:3.0.1=classpath
io.github.joselion.strict-null-check:io.github.joselion.strict-null-check.gradle.plugin:3.0.0=classpath
io.github.joselion:maybe:3.2.0=classpath
io.github.joselion:pretty-jupiter:3.0.1=classpath
io.github.joselion:strict-null-check:3.0.0=classpath
org.apache.commons:commons-lang3:3.11=classpath
org.apache.commons:commons-text:1.9=classpath
org.jsoup:jsoup:1.15.2=classpath
org.sonarsource.sonarlint.core:sonarlint-core:8.0.2.42487=classpath
se.solrike.sonarlint:se.solrike.sonarlint.gradle.plugin:1.0.0-beta.15=classpath
se.solrike.sonarlint:sonarlint-gradle-plugin:1.0.0-beta.15=classpath
me.champeau.gradle.mrjar:plugin:0.1.1=classpath
me.champeau.mrjar:me.champeau.mrjar.gradle.plugin:0.1.1=classpath
name.remal.gradle-plugins.sonarlint:sonarlint:3.3.8=classpath
name.remal.sonarlint:name.remal.sonarlint.gradle.plugin:3.3.8=classpath
empty=
18 changes: 18 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,25 @@
<module name="RedundantModifier" />

<!-- Naming Conventions -->
<module name="ClassTypeParameterName" />
<module name="ConstantName" />
<module name="IllegalIdentifierName" />
<module name="InterfaceTypeParameterName" />
<module name="LambdaParameterName" />
<module name="LocalFinalVariableName" />
<module name="LocalVariableName" />
<module name="MemberName" />
<module name="MethodName" />
<module name="MethodTypeParameterName" />
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$" />
</module>
<module name="ParameterName" />
<module name="PatternVariableName" />
<module name="RecordComponentName" />
<module name="RecordTypeParameterName" />
<module name="StaticVariableName" />
<module name="TypeName" />

<!-- Whitespace -->
<module name="EmptyLineSeparator">
Expand Down
5 changes: 4 additions & 1 deletion config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@

<suppressions>
<!-- Tests -->
<suppress checks="InnerTypeLast" files=".*[\\/]src[\\/]test[\\/]" />
<suppress
checks="InnerTypeLast|MethodName|TypeName"
files=".*[\\/]src[\\/]test[\\/]"
/>
</suppressions>
84 changes: 66 additions & 18 deletions gradle.lockfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.google.code.findbugs:jsr305:3.0.2=checkstyle
com.fasterxml.staxmate:staxmate:2.4.0=sonarlintCoreClasspath
com.fasterxml.woodstox:woodstox-core:6.4.0=sonarlintCoreClasspath
com.google.code.findbugs:jsr305:3.0.2=checkstyle,sonarlintCoreClasspath
com.google.code.gson:gson:2.8.9=sonarlintCoreClasspath
com.google.collections:google-collections:1.0=checkstyle
com.google.errorprone:error_prone_annotations:2.18.0=checkstyle
com.google.guava:failureaccess:1.0.1=checkstyle
Expand All @@ -12,11 +15,14 @@ com.puppycrawl.tools:checkstyle:10.12.3=checkstyle
commons-beanutils:commons-beanutils:1.9.4=checkstyle
commons-codec:commons-codec:1.15=checkstyle
commons-collections:commons-collections:3.2.2=checkstyle
commons-io:commons-io:2.11.0=sonarlintCoreClasspath
info.picocli:picocli:4.7.4=checkstyle
net.bytebuddy:byte-buddy-agent:1.14.6=testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.14.6=testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy-agent:1.14.6=java17TestCompileClasspath,java17TestRuntimeClasspath,java20TestCompileClasspath,java20TestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.14.6=java17TestCompileClasspath,java17TestRuntimeClasspath,java20TestCompileClasspath,java20TestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
net.sf.saxon:Saxon-HE:12.3=checkstyle
org.antlr:antlr4-runtime:4.11.1=checkstyle
org.apache.commons:commons-compress:1.21=sonarlintCoreClasspath
org.apache.commons:commons-lang3:3.12.0=sonarlintCoreClasspath
org.apache.commons:commons-lang3:3.8.1=checkstyle
org.apache.commons:commons-text:1.3=checkstyle
org.apache.httpcomponents.client5:httpclient5:5.1.3=checkstyle
Expand All @@ -28,35 +34,77 @@ org.apache.maven.doxia:doxia-core:1.12.0=checkstyle
org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle
org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle
org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle
org.apache.tomcat.embed:tomcat-embed-core:9.0.75=sonarlintCoreClasspath
org.apache.tomcat.embed:tomcat-embed-el:9.0.75=sonarlintCoreClasspath
org.apache.tomcat.embed:tomcat-embed-jasper:9.0.75=sonarlintCoreClasspath
org.apache.tomcat:tomcat-annotations-api:9.0.75=sonarlintCoreClasspath
org.apache.xbean:xbean-reflect:3.7=checkstyle
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
org.assertj:assertj-core:3.24.2=testCompileClasspath,testRuntimeClasspath
org.apiguardian:apiguardian-api:1.1.2=java17TestCompileClasspath,java20TestCompileClasspath,testCompileClasspath
org.assertj:assertj-core:3.24.2=java17TestCompileClasspath,java17TestRuntimeClasspath,java20TestCompileClasspath,java20TestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.checkerframework:checker-qual:3.27.0=checkstyle
org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle
org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle
org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle
org.codehaus.plexus:plexus-utils:3.3.0=checkstyle
org.eclipse.jdt:org.eclipse.jdt.annotation:2.2.700=compileClasspath,testCompileClasspath
org.codehaus.woodstox:stax2-api:4.2.1=sonarlintCoreClasspath
org.eclipse.jdt:ecj:3.33.0=sonarlintCoreClasspath
org.eclipse.jdt:org.eclipse.jdt.annotation:2.2.700=compileClasspath,java17CompileClasspath,java17TestCompileClasspath,java20CompileClasspath,java20TestCompileClasspath,testCompileClasspath
org.eclipse.jdt:org.eclipse.jdt.core:3.33.0=sonarlintCoreClasspath
org.eclipse.platform:org.eclipse.core.commands:3.10.300=sonarlintCoreClasspath
org.eclipse.platform:org.eclipse.core.contenttype:3.8.100=sonarlintCoreClasspath
org.eclipse.platform:org.eclipse.core.jobs:3.13.200=sonarlintCoreClasspath
org.eclipse.platform:org.eclipse.core.resources:3.18.200=sonarlintCoreClasspath
org.eclipse.platform:org.eclipse.core.runtime:3.26.100=sonarlintCoreClasspath
org.eclipse.platform:org.eclipse.equinox.common:3.17.100=sonarlintCoreClasspath
org.eclipse.platform:org.eclipse.equinox.preferences:3.10.200=sonarlintCoreClasspath
org.eclipse.platform:org.eclipse.osgi:3.18.300=sonarlintCoreClasspath
org.eclipse.platform:org.eclipse.text:3.12.300=sonarlintCoreClasspath
org.jacoco:org.jacoco.agent:0.8.10=jacocoAgent,jacocoAnt
org.jacoco:org.jacoco.ant:0.8.10=jacocoAnt
org.jacoco:org.jacoco.core:0.8.10=jacocoAnt
org.jacoco:org.jacoco.report:0.8.10=jacocoAnt
org.javassist:javassist:3.28.0-GA=checkstyle
org.junit.jupiter:junit-jupiter-api:5.10.0=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-engine:5.10.0=testRuntimeClasspath
org.junit.jupiter:junit-jupiter-params:5.10.0=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter:5.10.0=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-commons:1.10.0=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:1.10.0=testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.10.0=java17TestCompileClasspath,java17TestRuntimeClasspath,java20TestCompileClasspath,java20TestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-engine:5.10.0=java17TestRuntimeClasspath,java20TestRuntimeClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-params:5.10.0=java17TestCompileClasspath,java17TestRuntimeClasspath,java20TestCompileClasspath,java20TestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter:5.10.0=java17TestCompileClasspath,java17TestRuntimeClasspath,java20TestCompileClasspath,java20TestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-commons:1.10.0=java17TestCompileClasspath,java17TestRuntimeClasspath,java20TestCompileClasspath,java20TestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:1.10.0=java17TestRuntimeClasspath,java20TestRuntimeClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-launcher:1.10.0=testRuntimeClasspath
org.junit:junit-bom:5.10.0=testCompileClasspath,testRuntimeClasspath
org.mockito:mockito-core:5.5.0=testCompileClasspath,testRuntimeClasspath
org.objenesis:objenesis:3.3=testRuntimeClasspath
org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath
org.junit:junit-bom:5.10.0=java17TestCompileClasspath,java17TestRuntimeClasspath,java20TestCompileClasspath,java20TestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.mockito:mockito-core:5.5.0=java17TestCompileClasspath,java17TestRuntimeClasspath,java20TestCompileClasspath,java20TestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.objenesis:objenesis:3.3=java17TestRuntimeClasspath,java20TestRuntimeClasspath,testRuntimeClasspath
org.opentest4j:opentest4j:1.3.0=java17TestCompileClasspath,java17TestRuntimeClasspath,java20TestCompileClasspath,java20TestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.osgi:org.osgi.service.prefs:1.1.2=sonarlintCoreClasspath
org.osgi:osgi.annotation:8.0.1=sonarlintCoreClasspath
org.ow2.asm:asm-commons:9.5=jacocoAnt
org.ow2.asm:asm-tree:9.5=jacocoAnt
org.ow2.asm:asm:9.0=sonarlintCoreClasspath
org.ow2.asm:asm:9.5=jacocoAnt
org.reflections:reflections:0.10.2=checkstyle
org.sonarsource.java:sonar-java-plugin:7.20.0.31692=sonarlintPlugins
org.sonarsource.analyzer-commons:sonar-analyzer-commons:2.7.0.1482=sonarlintCoreClasspath
org.sonarsource.analyzer-commons:sonar-analyzer-recognizers:2.7.0.1482=sonarlintCoreClasspath
org.sonarsource.analyzer-commons:sonar-performance-measure:2.7.0.1482=sonarlintCoreClasspath
org.sonarsource.analyzer-commons:sonar-regex-parsing:2.7.0.1482=sonarlintCoreClasspath
org.sonarsource.analyzer-commons:sonar-xml-parsing:2.7.0.1482=sonarlintCoreClasspath
org.sonarsource.java:external-reports:7.24.0.32100=sonarlintCoreClasspath
org.sonarsource.java:java-checks:7.24.0.32100=sonarlintCoreClasspath
org.sonarsource.java:java-frontend:7.24.0.32100=sonarlintCoreClasspath
org.sonarsource.java:java-jsp:7.24.0.32100=sonarlintCoreClasspath
org.sonarsource.java:java-surefire:7.24.0.32100=sonarlintCoreClasspath
org.sonarsource.java:java-symbolic-execution:7.24.0.32100=sonarlintCoreClasspath
org.sonarsource.java:jdt:7.24.0.32100=sonarlintCoreClasspath
org.sonarsource.java:sonar-java-plugin:7.24.0.32100=sonarlintCoreClasspath
org.sonarsource.javascript:css:10.5.1.22382=sonarlintCoreClasspath
org.sonarsource.javascript:javascript-checks:10.5.1.22382=sonarlintCoreClasspath
org.sonarsource.javascript:sonar-javascript-plugin:10.5.1.22382=sonarlintCoreClasspath
org.sonarsource.kotlin:sonar-kotlin-plugin:2.17.0.2902=sonarlintCoreClasspath
org.sonarsource.slang:sonar-ruby-plugin:1.14.0.4481=sonarlintCoreClasspath
org.sonarsource.slang:sonar-scala-plugin:1.14.0.4481=sonarlintCoreClasspath
org.sonarsource.sonarlint.core:sonarlint-core:9.2.0.74516=sonarlintCore,sonarlintCoreClasspath
org.sonarsource.sslr:sslr-core:1.24.0.633=sonarlintCoreClasspath
org.sonarsource.xml:sonar-xml-plugin:2.10.0.4108=sonarlintCoreClasspath
org.xmlresolver:xmlresolver:5.2.0=checkstyle
empty=annotationProcessor,runtimeClasspath,signatures,sonarlint,testAnnotationProcessor
xerces:xercesImpl:2.12.2=sonarlintCoreClasspath
xml-apis:xml-apis:1.4.01=sonarlintCoreClasspath
empty=annotationProcessor,java17AnnotationProcessor,java17RuntimeClasspath,java17TestAnnotationProcessor,java20AnnotationProcessor,java20RuntimeClasspath,java20TestAnnotationProcessor,runtimeClasspath,testAnnotationProcessor
9 changes: 5 additions & 4 deletions src/main/java/io/github/joselion/maybe/Maybe.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static <E extends Throwable> EffectHandler<E> fromEffect(final ThrowingRu
* In other words, the following code
* <pre>
* Optional.of(value)
* .map(str -> Maybe.fromResolver(() -> decode(str)));
* .map(str -&gt; Maybe.fromResolver(() -&gt; decode(str)));
* </pre>
* Is equivalent to
* <pre>
Expand Down Expand Up @@ -166,7 +166,7 @@ public static <S, T, E extends Throwable> Function<S, ResolveHandler<T, E>> part
* In other words, the following code
* <pre>
* Optional.of(value)
* .map(msg -> Maybe.fromEffect(() -> sendMessage(msg)));
* .map(msg -&gt; Maybe.fromEffect(() -&gt; sendMessage(msg)));
* </pre>
* Is equivalent to
* <pre>
Expand Down Expand Up @@ -341,7 +341,8 @@ public boolean equals(final Object obj) {
return true;
}

if (obj instanceof final Maybe<?> other) {
if (obj instanceof Maybe<?>) { // NOSONAR
final var other = (Maybe<?>) obj;
return other.toOptional().equals(value);
}

Expand Down Expand Up @@ -370,7 +371,7 @@ public int hashCode() {
public String toString() {
return value
.map(Object::toString)
.map("Maybe[%s]"::formatted)
.map(it -> String.format("Maybe[%s]", it))
.orElse("Maybe.nothing");
}
}
Loading

0 comments on commit c7e4c57

Please sign in to comment.