-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply dependency management resolution strategy to all detached configs
Support for a dependency management-specific resolution strategy was added in 8f59648. This resolution strategy is applied to any configuration that’s created by the plugin for resolving imported boms. It is not, however, applied to various other configurations that are used by the plugin. The configurations that are used when apply Maven exclusions are one example. The fact that the resolution strategy isn’t applied to all detached configurations that are created by the plugin has proven to be problematic. If a user configures the main configurations to disable caching this will have no effect. The problem is that the logic for applying Maven exclusions creates a detached configuration and copies a main configuration’s dependencies into it. When this detached configuration is resolved, it’s done so with the default caching rules. When the main configuration that contains the same dependency is resolved, the custom caching configuration is ignored. Presumably, this happens because the dependency has already been resolved once in this build and Gradle doesn’t want different parts of the build to use different snapshots. This commit updates the plugin to introduce a new central location, DependencyManagementConfigurationContainer, for creating detached configurations. The dependency management resolution strategy is apply to every configuration that’s created by this configuration container, thereby ensuring that things like the caching configuration are applied consistently. Closes gh-74
- Loading branch information
1 parent
c496031
commit 096e87f
Showing
11 changed files
with
166 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...y/io/spring/gradle/dependencymanagement/DependencyManagementConfigurationContainer.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2014-2016 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.spring.gradle.dependencymanagement | ||
|
||
import org.gradle.api.DomainObjectCollection | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.Configuration | ||
import org.gradle.api.artifacts.ConfigurationContainer | ||
import org.gradle.api.artifacts.Dependency | ||
|
||
/** | ||
* A container for {@link Configuration Configurations} created by the dependency management plugin | ||
* that aren't part of the project's configurations. | ||
* | ||
* @author Andy Wilkinson | ||
*/ | ||
class DependencyManagementConfigurationContainer { | ||
|
||
private final DomainObjectCollection<Configuration> configurations | ||
|
||
private final ConfigurationContainer delegate | ||
|
||
DependencyManagementConfigurationContainer(Project project) { | ||
this.delegate = project.configurations | ||
this.configurations = project.container(Configuration) | ||
} | ||
|
||
Configuration newConfiguration(Dependency... dependencies) { | ||
Configuration configuration = delegate.detachedConfiguration(dependencies) | ||
configurations.add(configuration) | ||
return configuration | ||
} | ||
|
||
void resolutionStrategy(Closure closure) { | ||
this.configurations.all { Configuration configuration -> | ||
configuration.resolutionStrategy closure | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.