Merge branch '2.7.x' into 3.0.x

3.0.x
Phillip Webb 1 year ago
commit 9b5062e5bb

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

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

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

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

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

Loading…
Cancel
Save