Retrieving version from ResolvedArtifact needs simplification?


(Marcel Overdijk) #1

I need to retrieve the version from a ResolvedArtifact and this seems to be the only possible way:

artifact.moduleVersion.id.version

Note that

artifact.resolvedDependency.moduleVersion

is a lot cleaner but getResolvedDependency() in DefaultResolvedArtifact will be deprecated in Gradle 2.0

public ResolvedDependency getResolvedDependency() {
        DeprecationLogger.nagUserOfDeprecated(
                "ResolvedArtifact.getResolvedDependency()",
                "For version info use ResolvedArtifact.getModuleVersion(), to access the dependency graph use ResolvedConfiguration.getFirstLevelModuleDependencies()"
        );
        return resolvedDependency;
    }