[ https://issues.apache.org/jira/browse/MBUILDCACHE-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17878116#comment-17878116 ]
ASF GitHub Bot commented on MBUILDCACHE-106: -------------------------------------------- AlexanderAshitkin commented on code in PR #178: URL: https://github.com/apache/maven-build-cache-extension/pull/178#discussion_r1738654358 ########## src/main/java/org/apache/maven/buildcache/CacheControllerImpl.java: ########## @@ -892,6 +892,18 @@ private void restoreGeneratedSources(Artifact artifact, Path artifactFilePath, M Files.createDirectories(outputDir); } CacheUtils.unzip(artifactFilePath, outputDir); + OutputType outputType = OutputType.fromClassifier(artifact.getClassifier()); + if (outputType != OutputType.GENERATED_SOURCE) { + return; + } + Path targetDir = Paths.get(project.getBuild().getDirectory()); + if (outputDir.equals(targetDir.resolve("generated-sources")) Review Comment: It's possible that there are multiple generated source roots attached at different levels. The best solution would be to add extra metadata to accurately track and restore all the source roots. Alternatively, it's possible to implement a convention-based restoration by matching the logic in `CacheControllerImpl#attachGeneratedSources` to restore all the sources associated with a `GENERATED_SOURCE` cache entry. Check this part too: ```java for (String sourceRoot : sourceRoots) { final Path sourceRootPath = Paths.get(sourceRoot); if (Files.isDirectory(sourceRootPath) && sourceRootPath.startsWith(targetDir) && !(sourceRootPath.startsWith(generatedSourcesDir) || sourceRootPath.startsWith(generatedTestSourcesDir))) { // dir within target attachDirIfNotEmpty(sourceRootPath, targetDir, project); } } ``` > Missing compile source roots matching 'generated-sources' and > 'generated-test-sources' when compiler is skipped > --------------------------------------------------------------------------------------------------------------- > > Key: MBUILDCACHE-106 > URL: https://issues.apache.org/jira/browse/MBUILDCACHE-106 > Project: Maven Build Cache Extension > Issue Type: Bug > Reporter: Réda Housni Alaoui > Priority: Major > Labels: pull-request-available > -- This message was sent by Atlassian Jira (v8.20.10#820010)