Skip to content
Snippets Groups Projects
Unverified Commit c49be3d6 authored by Johannes Feichtner's avatar Johannes Feichtner Committed by GitHub
Browse files

fix(manager/gradle): optimize performance of Gradle lock file maintenance and...

fix(manager/gradle): optimize performance of Gradle lock file maintenance and ensure gradlew is executable (#18348)
parent cdcb455d
Branches
No related tags found
No related merge requests found
......@@ -209,6 +209,21 @@ describe('modules/manager/gradle/artifacts', () => {
]);
});
it('aborts lock file maintenance if packageFileName is not build.gradle(.kts) in root project', async () => {
expect(
await updateArtifacts({
packageFileName: 'somedir/settings.gradle',
updatedDeps: [],
newPackageFileContent: '',
config: { isLockFileMaintenance: true },
})
).toBeNull();
expect(logger.logger.trace).toHaveBeenCalledWith(
'No build.gradle(.kts) file or not in root project - skipping lock file maintenance'
);
});
it('performs lock file maintenance', async () => {
const execSnapshots = mockExecAll();
......
......@@ -18,8 +18,10 @@ import {
extractGradleVersion,
getJavaConstraint,
gradleWrapperFileName,
prepareGradleCommand,
} from '../gradle-wrapper/utils';
import type { UpdateArtifact, UpdateArtifactsResult } from '../types';
import { isGradleBuildFile } from './utils';
async function getUpdatedLockfiles(
oldLockFileContentMap: Record<string, string | null>
......@@ -102,12 +104,25 @@ export async function updateArtifacts({
);
return null;
}
if (
config.isLockFileMaintenance &&
(!isGradleBuildFile(packageFileName) ||
dirname(packageFileName) !== dirname(gradlewFile))
) {
logger.trace(
'No build.gradle(.kts) file or not in root project - skipping lock file maintenance'
);
return null;
}
logger.debug('Updating found Gradle dependency lockfiles');
try {
const oldLockFileContentMap = await getFileContentMap(lockFiles);
await writeLocalFile(packageFileName, newPackageFileContent);
await prepareGradleCommand(gradlewFile);
let cmd = `${gradlewName} --console=plain -q`;
const execOptions: ExecOptions = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment