{"record":{"id":"93eabe03408f8640","repo":"apache/maven","slug":"could-not-delete-file","errorCode":null,"errorMessage":"Could not delete {} file. ","messagePattern":"Could not delete (.+?) file\\. ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"impl/maven-core/src/main/java/org/apache/maven/execution/DefaultBuildResumptionDataRepository.java","lineNumber":88,"sourceCode":"        properties.setProperty(REMAINING_PROJECTS, value);\n\n        return properties;\n    }\n\n    @Override\n    public void applyResumptionData(MavenExecutionRequest request, MavenProject rootProject) {\n        Properties properties =\n                loadResumptionFile(Paths.get(rootProject.getBuild().getDirectory()));\n        applyResumptionProperties(request, properties);\n    }\n\n    @Override\n    public void removeResumptionData(MavenProject rootProject) {\n        Path resumeProperties = Paths.get(rootProject.getBuild().getDirectory(), RESUME_PROPERTIES_FILENAME);\n        try {\n            Files.deleteIfExists(resumeProperties);\n        } catch (IOException e) {\n            LOGGER.warn(\"Could not delete {} file. \", RESUME_PROPERTIES_FILENAME, e);\n        }\n    }\n\n    private Properties loadResumptionFile(Path rootBuildDirectory) {\n        Properties properties = new Properties();\n        Path path = rootBuildDirectory.resolve(RESUME_PROPERTIES_FILENAME);\n        if (!Files.exists(path)) {\n            LOGGER.warn(\"The {} file does not exist. The --resume / -r feature will not work.\", path);\n            return properties;\n        }\n\n        try (Reader reader = Files.newBufferedReader(path)) {\n            properties.load(reader);\n        } catch (IOException e) {\n            LOGGER.warn(\"Unable to read {}. The --resume / -r feature will not work.\", path);\n        }\n\n        return properties;","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/execution/DefaultBuildResumptionDataRepository.java#L70-L106","documentation":"DefaultBuildResumptionDataRepository.removeResumptionData deletes the resume state file (target/resume.properties in the root project's build directory) after a resumed build. If Files.deleteIfExists raises IOException - typically a file lock on Windows or a read-only target directory - Maven logs this warning and continues; the stale file is simply rewritten on the next failed build.","triggerScenarios":"A resumed build finishes and Maven tries to delete root-module target/resume.properties while another process (IDE file indexer, antivirus, a second concurrent Maven run on the same checkout) holds the file open, or the target directory does not grant delete permission to the build user.","commonSituations":"Windows workstations with antivirus/indexing scanning target/; two CI jobs sharing one workspace; container builds where target/ was created by root and the build runs as another user.","solutions":["Delete target/resume.properties manually once no other process holds it, then re-run","Fix directory permissions so the build user owns the root module's target/","Stop running concurrent Maven builds against the same checkout/workspace","Ignore it: harmless in itself; the next failed build overwrites the file"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before triggering a resumed build programmatically, ensure the file is deletable\nPath target = Paths.get(rootProject.getBuild().getDirectory());\nPath resume = target.resolve(\"resume.properties\");\nif (Files.exists(resume) && !Files.isWritable(target)) {\n    throw new IllegalStateException(\"target/ not writable; resume file cannot be removed later\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never run two Maven builds concurrently on the same checkout","Exclude target/ from antivirus/on-access scanning on Windows","Keep build user as owner of the workspace (avoid root-created target/ in containers)"],"tags":["resume","file-io","windows-file-lock","permissions"],"backgroundTag":"file-delete-permission-denied","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}