Skip to content

Commit 8e7a0a0

Browse files
committed
Add checkClasspathForConflicts Gradle task
* The new `checkClasspathForConflicts` will fail if modules has dependencies containing the same classes. One of the dependency must be excluded to avoid target classpath pollution and possible conflicts * Make the task working as `onlyIf { isCI }` * Fix warning for illegal access in the `asciidoctorPdf` task add `--add-opens` to its JVM * Fix `DefaultHeaderChannelRegistry` for proper `MessageChannelWrapper` access and change it to `record`
1 parent 6ebdd4f commit 8e7a0a0

File tree

3 files changed

+59
-18
lines changed

3 files changed

+59
-18
lines changed

build.gradle

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
buildscript {
22
ext.kotlinVersion = '1.6.10'
3+
ext.isCI = System.getenv('GITHUB_ACTION') || System.getenv('bamboo_buildKey')
34
repositories {
45
mavenCentral()
56
gradlePluginPortal()
@@ -23,7 +24,7 @@ plugins {
2324
id 'org.asciidoctor.jvm.convert' version '3.3.2'
2425
}
2526

26-
if (System.getenv('GITHUB_ACTION') || System.getenv('bamboo_buildKey')) {
27+
if (isCI) {
2728
apply plugin: 'io.spring.nohttp'
2829

2930
nohttp {
@@ -46,7 +47,7 @@ ext {
4647
modifiedFiles =
4748
files(grgit.status().unstaged.modified).filter { f -> f.name.endsWith('.java') || f.name.endsWith('.kt') }
4849

49-
apacheSshdVersion = '2.7.0'
50+
apacheSshdVersion = '2.8.0'
5051
artemisVersion = '2.19.0'
5152
aspectjVersion = '1.9.7'
5253
assertjVersion = '3.21.0'
@@ -280,7 +281,7 @@ configure(javaProjects) { subproject ->
280281
[compileJava, compileTestJava]*.options*.compilerArgs = [xLintArg, '-parameters']
281282

282283
task updateCopyrights {
283-
onlyIf { !System.getenv('GITHUB_ACTION') && !System.getenv('bamboo_buildKey') }
284+
onlyIf { !isCI }
284285
inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) })
285286
outputs.dir('build/classes')
286287

@@ -383,7 +384,38 @@ configure(javaProjects) { subproject ->
383384
}
384385
}
385386

386-
check.dependsOn javadoc
387+
task checkClasspathForConflicts {
388+
onlyIf { isCI }
389+
inputs.files(configurations.runtimeClasspath)
390+
391+
def ignored = ['module-info.class']
392+
def errors = ['Found classpath conflicts:\n']
393+
Map<String, Set<String>> classpathContents = [:]
394+
395+
doLast {
396+
inputs.files.each { file ->
397+
new java.util.jar.JarFile(file)
398+
.stream()
399+
.filter { !it.name.startsWith('META-INF/') && it.name.endsWith('.class') && !ignored.contains(it.name) }
400+
.each { classpathContents.computeIfAbsent(it.name, { [] as Set }).add(file.absolutePath) }
401+
}
402+
403+
def conflicts = classpathContents.findAll { it.value.size() > 1 }
404+
405+
conflicts.each {
406+
errors += " $it.key\n"
407+
it.value.each {
408+
errors += " $it\n"
409+
}
410+
}
411+
412+
if (errors.size() > 1) {
413+
throw new InvalidUserDataException(errors.toString().replaceAll(~/,\s/, '') - '[' - ']')
414+
}
415+
}
416+
}
417+
418+
check.dependsOn checkClasspathForConflicts, javadoc
387419

388420
publishing {
389421
publications {
@@ -566,6 +598,14 @@ project('spring-integration-gemfire') {
566598
api project(':spring-integration-core')
567599
api('org.springframework.data:spring-data-geode') {
568600
exclude group: 'org.springframework'
601+
exclude group: 'org.apache.shiro', module: 'shiro-event'
602+
exclude group: 'org.apache.shiro', module: 'shiro-lang'
603+
exclude group: 'org.apache.shiro', module: 'shiro-crypto-hash'
604+
exclude group: 'org.apache.shiro', module: 'shiro-crypto-cipher'
605+
exclude group: 'org.apache.shiro', module: 'shiro-config-ogdl'
606+
exclude group: 'org.apache.shiro', module: 'shiro-config-core'
607+
exclude group: 'org.apache.shiro', module: 'shiro-cache'
608+
exclude group: 'commons-logging'
569609
}
570610
api "commons-io:commons-io:$commonsIoVersion"
571611

@@ -776,7 +816,9 @@ project('spring-integration-scripting') {
776816
description = 'Spring Integration Scripting Support'
777817
dependencies {
778818
api project(':spring-integration-core')
779-
optionalApi 'org.jetbrains.kotlin:kotlin-script-util'
819+
optionalApi ('org.jetbrains.kotlin:kotlin-script-util') {
820+
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-daemon-client'
821+
}
780822
optionalApi 'org.jetbrains.kotlin:kotlin-compiler-embeddable'
781823

782824
testImplementation "org.jruby:jruby-complete:$jrubyVersion"
@@ -808,7 +850,9 @@ project('spring-integration-sftp') {
808850
api project(':spring-integration-file')
809851
api "com.jcraft:jsch:$jschVersion"
810852
api 'org.springframework:spring-context-support'
811-
optionalApi "org.apache.sshd:sshd-sftp:$apacheSshdVersion"
853+
optionalApi ("org.apache.sshd:sshd-sftp:$apacheSshdVersion") {
854+
exclude group: 'org.slf4j', module: 'jcl-over-slf4j'
855+
}
812856

813857
testImplementation "org.apache.sshd:sshd-core:$apacheSshdVersion"
814858
testImplementation project(':spring-integration-event')

gradle/docs.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ task checkAsciidocLinks {
6464

6565
asciidoctorPdf {
6666
dependsOn checkAsciidocLinks
67+
68+
inProcess = JAVA_EXEC
69+
forkOptions {
70+
jvmArgs '--add-opens', 'java.base/sun.nio.ch=ALL-UNNAMED', '--add-opens', 'java.base/java.io=ALL-UNNAMED'
71+
}
72+
6773
baseDirFollowsSourceFile()
6874
configurations 'asciidoctorExt'
6975

spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2021 the original author or authors.
2+
* Copyright 2013-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ public class DefaultHeaderChannelRegistry extends IntegrationObjectSupport
5757

5858
protected final Map<String, MessageChannelWrapper> channels = new ConcurrentHashMap<>(); // NOSONAR
5959

60-
protected final String uuid = UUID.randomUUID().toString() + ":"; // NOSONAR
60+
protected final String uuid = UUID.randomUUID() + ":"; // NOSONAR
6161

6262
private boolean removeOnGet;
6363

@@ -228,16 +228,7 @@ public synchronized void run() {
228228
}
229229

230230

231-
private static final class MessageChannelWrapper {
232-
233-
private final MessageChannel channel;
234-
235-
private final long expireAt;
236-
237-
MessageChannelWrapper(MessageChannel channel, long expireAt) {
238-
this.channel = channel;
239-
this.expireAt = expireAt;
240-
}
231+
protected record MessageChannelWrapper(MessageChannel channel, long expireAt) {
241232

242233
public long getExpireAt() {
243234
return this.expireAt;

0 commit comments

Comments
 (0)