Merge branch '3.1.x'

This commit is contained in:
Phillip Webb 2023-09-20 17:16:13 -07:00
commit 2075f6c685
15 changed files with 44 additions and 54 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2023 the original author or authors.
* Copyright 2023-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -49,16 +49,8 @@ class StandardLibraryUpdateResolver implements LibraryUpdateResolver {
StandardLibraryUpdateResolver(VersionResolver versionResolver,
List<BiPredicate<Library, DependencyVersion>> predicates) {
this.versionResolver = versionResolver;
BiPredicate<Library, DependencyVersion> predicate = null;
for (BiPredicate<Library, DependencyVersion> p : predicates) {
if (predicate == null) {
predicate = p;
}
else {
predicate = predicate.and(p);
}
}
this.predicate = predicate;
this.predicate = (library, dependencyVersion) -> predicates.stream()
.allMatch((predicate) -> predicate.test(library, dependencyVersion));
}
@Override

View File

@ -34,6 +34,7 @@ import java.util.regex.Pattern;
import javax.inject.Inject;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.VersionRange;
import org.gradle.api.DefaultTask;
import org.gradle.api.InvalidUserDataException;
import org.gradle.api.internal.tasks.userinput.UserInputHandler;
@ -227,42 +228,37 @@ public abstract class UpgradeDependencies extends DefaultTask {
}
protected List<BiPredicate<Library, DependencyVersion>> determineUpdatePredicates(Milestone milestone) {
BiPredicate<Library, DependencyVersion> compilesWithUpgradePolicy = (library,
candidate) -> this.bom.getUpgrade().getPolicy().test(candidate, library.getVersion().getVersion());
BiPredicate<Library, DependencyVersion> isAnUpgrade = (library,
candidate) -> library.getVersion().getVersion().isUpgrade(candidate, this.movingToSnapshots);
BiPredicate<Library, DependencyVersion> isPermitted = (library, candidate) -> {
for (ProhibitedVersion prohibitedVersion : library.getProhibitedVersions()) {
String candidateString = candidate.toString();
if (prohibitedVersion.getRange() != null
&& prohibitedVersion.getRange().containsVersion(new DefaultArtifactVersion(candidateString))) {
return false;
}
for (String startsWith : prohibitedVersion.getStartsWith()) {
if (candidateString.startsWith(startsWith)) {
return false;
}
}
for (String endsWith : prohibitedVersion.getEndsWith()) {
if (candidateString.endsWith(endsWith)) {
return false;
}
}
for (String contains : prohibitedVersion.getContains()) {
if (candidateString.contains(contains)) {
return false;
}
}
}
return true;
};
List<BiPredicate<Library, DependencyVersion>> updatePredicates = new ArrayList<>();
updatePredicates.add(compilesWithUpgradePolicy);
updatePredicates.add(isAnUpgrade);
updatePredicates.add(isPermitted);
updatePredicates.add(this::compilesWithUpgradePolicy);
updatePredicates.add(this::isAnUpgrade);
updatePredicates.add(this::isNotProhibited);
return updatePredicates;
}
private boolean compilesWithUpgradePolicy(Library library, DependencyVersion candidate) {
return this.bom.getUpgrade().getPolicy().test(candidate, library.getVersion().getVersion());
}
private boolean isAnUpgrade(Library library, DependencyVersion candidate) {
return library.getVersion().getVersion().isUpgrade(candidate, this.movingToSnapshots);
}
private boolean isNotProhibited(Library library, DependencyVersion candidate) {
return !library.getProhibitedVersions()
.stream()
.anyMatch((prohibited) -> isProhibited(prohibited, candidate.toString()));
}
private boolean isProhibited(ProhibitedVersion prohibited, String candidate) {
boolean result = false;
VersionRange range = prohibited.getRange();
result = result || (range != null && range.containsVersion(new DefaultArtifactVersion(candidate)));
result = result || prohibited.getStartsWith().stream().anyMatch(candidate::startsWith);
result = result || prohibited.getStartsWith().stream().anyMatch(candidate::endsWith);
result = result || prohibited.getStartsWith().stream().anyMatch(candidate::contains);
return result;
}
private List<Library> matchingLibraries() {
List<Library> matchingLibraries = this.bom.getLibraries().stream().filter(this::eligible).toList();
if (matchingLibraries.isEmpty()) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2023 the original author or authors.
* Copyright 2023-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2023 the original author or authors.
* Copyright 2023-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -226,10 +226,12 @@ public class BraveAutoConfiguration {
@SuppressWarnings("deprecation")
private Factory createThrowAwayFactory() {
return new Factory() {
@Override
public <K> Propagation<K> create(KeyFactory<K> keyFactory) {
return null;
}
};
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -74,7 +74,7 @@ public abstract class DomainSocket extends AbstractSocket {
return new FileDescriptor(handle, this::close);
}
catch (RuntimeException ex) {
this.close(handle);
close(handle);
throw ex;
}
}