fix(gradle): Take plugin repositories into account (#4185)

This commit is contained in:
Sho Ikeda 2019-07-26 12:35:00 +09:00 committed by Rhys Arkins
parent 3d36f28875
commit 6ce0648398

View file

@ -7,16 +7,16 @@ const GRADLE_DEPENDENCY_REPORT_FILENAME = 'gradle-renovate-report.json';
interface GradleProject { interface GradleProject {
project: string; project: string;
repositories: string[]; repositories: string[];
dependencies: GradleModule[]; dependencies: GradleDependency[];
} }
interface GradleModule { interface GradleDependency {
name: string; name: string;
group: string; group: string;
version: string; version: string;
} }
type GradleModuleWithRepos = GradleModule & { repos: string[] }; type GradleDependencyWithRepos = GradleDependency & { repos: string[] };
// TODO: Unify with GradleDependency ? // TODO: Unify with GradleDependency ?
export interface BuildDependency { export interface BuildDependency {
@ -40,9 +40,10 @@ allprojects {
doLast { doLast {
def project = ['project': project.name] def project = ['project': project.name]
output << project output << project
def repos = repositories def repos = (repositories + settings.pluginManagement.repositories)
.collect { "$it.url" } .collect { "$it.url" }
.findAll { !it.startsWith('file:') } .findAll { !it.startsWith('file:') }
.unique()
project.repositories = repos project.repositories = repos
def deps = (buildscript.configurations + configurations) def deps = (buildscript.configurations + configurations)
.collect { it.dependencies } .collect { it.dependencies }
@ -97,7 +98,7 @@ async function readGradleReport(localDir: string): Promise<GradleProject[]> {
function mergeDependenciesWithRepositories( function mergeDependenciesWithRepositories(
project: GradleProject project: GradleProject
): GradleModuleWithRepos[] { ): GradleDependencyWithRepos[] {
if (!project.dependencies) { if (!project.dependencies) {
return []; return [];
} }
@ -108,17 +109,17 @@ function mergeDependenciesWithRepositories(
} }
function flatternDependencies( function flatternDependencies(
accumulator: GradleModuleWithRepos[], accumulator: GradleDependencyWithRepos[],
currentValue: GradleModuleWithRepos[] currentValue: GradleDependencyWithRepos[]
) { ) {
accumulator.push(...currentValue); accumulator.push(...currentValue);
return accumulator; return accumulator;
} }
function combineReposOnDuplicatedDependencies( function combineReposOnDuplicatedDependencies(
accumulator: GradleModuleWithRepos[], accumulator: GradleDependencyWithRepos[],
currentValue: GradleModuleWithRepos currentValue: GradleDependencyWithRepos
): GradleModuleWithRepos[] { ): GradleDependencyWithRepos[] {
const existingDependency = accumulator.find( const existingDependency = accumulator.find(
dep => dep.name === currentValue.name && dep.group === currentValue.group dep => dep.name === currentValue.name && dep.group === currentValue.group
); );
@ -133,7 +134,9 @@ function combineReposOnDuplicatedDependencies(
return accumulator; return accumulator;
} }
function buildDependency(gradleModule: GradleModuleWithRepos): BuildDependency { function buildDependency(
gradleModule: GradleDependencyWithRepos
): BuildDependency {
return { return {
name: gradleModule.name, name: gradleModule.name,
depGroup: gradleModule.group, depGroup: gradleModule.group,