Skip to content

Commit

Permalink
Added constrainTransitivesToThisReleaseExcept (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg committed Sep 30, 2022
2 parents 75ce61e + ea45406 commit 6c18520
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
@@ -1,6 +1,8 @@
# Goomph releases

## [Unreleased]
### Added
- New method `constrainTransitivesToThisReleaseExcept('icu4j', 'someotherdep')` to limit which transitives get constrained.

## [3.38.0] - 2022-09-14
### Added
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 DiffPlug
* Copyright (C) 2018-2022 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,8 @@
import com.diffplug.common.swt.os.SwtPlatform;
import com.diffplug.gradle.pde.EclipseRelease;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
Expand Down Expand Up @@ -132,16 +134,22 @@ public void useNativesForRunningPlatform() {
}

public void constrainTransitivesToThisRelease() {
constrainTransitivesToThisReleaseExcept();
}

public void constrainTransitivesToThisReleaseExcept(String... artifactNames) {
List<String> names = Arrays.asList(artifactNames);
project.getConfigurations().forEach(config -> {
config.getResolutionStrategy().eachDependency(dep -> {
ModuleVersionSelector mod = dep.getRequested();
String version = groupIdArtifactIdToVersion.get(mod.getGroup() + ":" + mod.getName());
if (version != null) {
dep.useVersion(version);
if (!names.contains(mod.getName())) {
String version = groupIdArtifactIdToVersion.get(mod.getGroup() + ":" + mod.getName());
if (version != null) {
dep.useVersion(version);
}
}
});
});

}

/////////////
Expand Down

0 comments on commit 6c18520

Please sign in to comment.