Skip to content
Snippets Groups Projects
Unverified Commit 969d455a authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

fix(gradle-wrapper): use distribution url instead of version (#6003)

parent 5145c044
No related branches found
No related tags found
No related merge requests found
......@@ -86,10 +86,14 @@ describe(getName(__filename), () => {
'gradlew.bat',
].forEach((file) => {
expect(
readFileSync(resolve(__dirname, `./__fixtures__/testFiles/${file}`))
readFileSync(
resolve(__dirname, `./__fixtures__/testFiles/${file}`),
'utf8'
)
).toEqual(
readFileSync(
resolve(__dirname, `./__fixtures__/expectedFiles/${file}`)
resolve(__dirname, `./__fixtures__/expectedFiles/${file}`),
'utf8'
)
);
});
......
......@@ -24,8 +24,21 @@ async function addIfUpdated(
return null;
}
function getDistributionUrl(newPackageFileContent: string): string {
const distributionUrlLine = newPackageFileContent
.split('\n')
.find((line) => line.startsWith('distributionUrl='));
if (distributionUrlLine) {
return distributionUrlLine
.replace('distributionUrl=', '')
.replace('https\\:', 'https:');
}
return null;
}
export async function updateArtifacts({
packageFileName,
newPackageFileContent,
updatedDeps,
config,
}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {
......@@ -34,12 +47,18 @@ export async function updateArtifacts({
logger.debug({ updatedDeps }, 'gradle-wrapper.updateArtifacts()');
const gradlew = gradleWrapperFileName(config);
const gradlewPath = resolve(projectDir, `./${gradlew}`);
const cmd = await prepareGradleCommand(
let cmd = await prepareGradleCommand(
gradlew,
projectDir,
await fs.stat(gradlewPath).catch(() => null),
`wrapper --gradle-version ${config.toVersion}`
`wrapper`
);
const distributionUrl = getDistributionUrl(newPackageFileContent);
if (distributionUrl) {
cmd += ` --gradle-distribution-url ${distributionUrl}`;
} else {
cmd += ` --gradle-version ${config.toVersion}`;
}
logger.debug(`Updating gradle wrapper: "${cmd}"`);
const execOptions: ExecOptions = {
docker: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment