-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add manifest files generated from ksp into final jar #1094
Conversation
926cd1c
to
8f0fc18
Compare
src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinKSPMetaFilesCopyTest.kt
Outdated
Show resolved
Hide resolved
@@ -42,7 +43,7 @@ open class JarExtractor protected constructor( | |||
Files.createDirectories(target) | |||
else -> jar.getInputStream(entry).use { | |||
Files.createDirectories(target.parent) | |||
Files.copy(it, target) | |||
Files.copy(it, target, StandardCopyOption.REPLACE_EXISTING) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened here to need the REPLACE_EXISTING
attribute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we are using the same generated classes directory for all the jar creation processes during KotlinCompile
when its trying to copy there is a java.nio.file.FileAlreadyExistsException
. This is to avoid that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one common file that would be a duplicate is META-INF/MANIFEST.MF
.
val relativePath = srcJarsPath.relativize(path) | ||
val destPath = Paths.get(directories.generatedClasses).resolve(relativePath) | ||
destPath.parent.toFile().mkdirs() | ||
Files.copy(path, destPath, StandardCopyOption.REPLACE_EXISTING) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And same here, is this actually needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as this #1094
src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinKSPMetaFilesCopyTest.kt
Outdated
Show resolved
Hide resolved
a9d29cc
to
1ae9b7c
Compare
1fec6cb
to
f0278eb
Compare
f0278eb
to
0ebc3cd
Compare
61d8eac
to
d7405ab
Compare
expandWithSources( | ||
SourceJarExtractor( | ||
destDir = Paths.get(directories.temp).resolve("_srcjars"), | ||
fileMatcher = IS_JVM_SOURCE_FILE, | ||
destDir = Paths.get(directories.temp).resolve(SOURCE_JARS_DIR), | ||
fileMatcher = { str: String -> IS_JVM_SOURCE_FILE.test(str) || "/$MANIFEST_DIR" in str }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not fully aware of the whole compilation process but if we add this logic here, it will also run for jars generated by kapt
(as it's based on whole input.sourceJarsList
). Since the issue for missing manifest files seems to be related to ksp
only, could we possibly put this expand logic in a place where it wouldn't affect kapt
generated jars? 💭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zalewskise I think we actually want this for Kapt as wellsince the meta directory could contain files needed in the final jar. One example that comes to mind is google-auto-service where it spits out information that's needed in the final jar.
Fix for issue #991