-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor plugin to be configuration aware
Previously the dependencies were resolved in a detached configuration, which had a few bad side effects. One is that the same dependency with different versions would be resolved to the latest and be shown once. The other is that the configuration's resolutionStrategy and compoent rules were not honored. Now every configuration is resolved (safely by cloning) and the report an aggregate of the results. This lets us decide if we should auto include all repositories found, which may sometimes cause misbehaviors. This is a major refactoring to transition the code from a scripting style to a Java style. This is mostly needed for code clarity, as the former style made sense when the plugin was untyped. The contribution to being type-safe was a nice addition, but made the code appear awkward. The ability to define custom resolution strategies allows filtering the report to disallow release candidates or other exclusion policies.
- Loading branch information
Showing
11 changed files
with
1,025 additions
and
222 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
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
81 changes: 81 additions & 0 deletions
81
src/main/groovy/com/github/benmanes/gradle/versions/updates/Coordinate.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,81 @@ | ||
/* | ||
* Copyright 2012-2015 Ben Manes. All Rights Reserved. | ||
* | ||
* 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 com.github.benmanes.gradle.versions.updates | ||
|
||
import groovy.transform.EqualsAndHashCode | ||
import groovy.transform.ToString | ||
import groovy.transform.TupleConstructor | ||
import groovy.transform.TypeChecked | ||
import org.gradle.api.artifacts.Dependency | ||
import org.gradle.api.artifacts.ModuleVersionIdentifier | ||
import org.gradle.api.artifacts.ModuleVersionSelector | ||
import org.gradle.api.artifacts.ResolvedDependency | ||
|
||
/** | ||
* The dependency's coordinate. | ||
* | ||
* @author Ben Manes ([email protected]) | ||
*/ | ||
@TypeChecked | ||
@EqualsAndHashCode | ||
class Coordinate { | ||
final String groupId | ||
final String artifactId | ||
final String version | ||
|
||
public Coordinate(String groupId, String artifactId, String version) { | ||
this.groupId = groupId ?: 'none' | ||
this.artifactId = artifactId ?: 'none' | ||
this.version = version ?: 'none' | ||
} | ||
|
||
public Key getKey() { | ||
return new Key(groupId, artifactId) | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return groupId + ':' + artifactId + ':' + version | ||
} | ||
|
||
static Coordinate from(ModuleVersionSelector selector) { | ||
return new Coordinate(selector.group, selector.name, selector.version) | ||
} | ||
|
||
static Coordinate from(Dependency dependency) { | ||
return new Coordinate(dependency.group, dependency.name, dependency.version) | ||
} | ||
|
||
static Coordinate from(ModuleVersionIdentifier identifier) { | ||
return new Coordinate(identifier.group, identifier.name, identifier.version) | ||
} | ||
|
||
@EqualsAndHashCode | ||
static class Key { | ||
final String groupId | ||
final String artifactId | ||
|
||
private Key(String groupId, String artifactId) { | ||
this.groupId = groupId | ||
this.artifactId = artifactId | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return groupId + ':' + artifactId | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/groovy/com/github/benmanes/gradle/versions/updates/DependencyStatus.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,53 @@ | ||
/* | ||
* Copyright 2012-2015 Ben Manes. All Rights Reserved. | ||
* | ||
* 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 com.github.benmanes.gradle.versions.updates | ||
|
||
import groovy.transform.EqualsAndHashCode | ||
import groovy.transform.ToString | ||
import groovy.transform.TypeChecked | ||
import org.gradle.api.artifacts.UnresolvedDependency | ||
|
||
/** | ||
* The version status of a dependency. | ||
* <p> | ||
* The <tt>latestVersion</tt> is set if the dependency was successfully resolved, otherwise the | ||
* <tt>unresolved</tt> contains the exception that caused the resolution to fail. | ||
* | ||
* @author Ben Manes ([email protected]) | ||
*/ | ||
@ToString | ||
@TypeChecked | ||
@EqualsAndHashCode | ||
class DependencyStatus { | ||
final UnresolvedDependency unresolved | ||
final Coordinate coordinate | ||
final String latestVersion | ||
|
||
DependencyStatus(Coordinate coordinate, String latestVersion) { | ||
this.latestVersion = latestVersion | ||
this.coordinate = coordinate | ||
} | ||
|
||
DependencyStatus(Coordinate coordinate, UnresolvedDependency unresolved) { | ||
this.coordinate = coordinate | ||
this.unresolved = unresolved | ||
this.latestVersion = 'none' | ||
} | ||
|
||
Coordinate getLatestCoordinate() { | ||
return new Coordinate(coordinate?.groupId, coordinate?.artifactId, latestVersion) | ||
} | ||
} |
Oops, something went wrong.
3392948
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed something else: For a project that has the jacoco plugin applied, 0.11.x started listing the
org.jacoco:org.jacoco.agent:0.7.1.201405082137
andorg.jacoco:org.jacoco.ant:0.7.1.201405082137
dependencies. Is this intentional?