@@ -232,6 +232,8 @@ export async function uploadPayload(payloadFileName: string, uploadContext?: Upl
232232 */
233233const mavenExcludedExtensions = [ '.repositories' , '.sha1' ]
234234
235+ const sourceExcludedExtensions = [ '.DS_Store' ]
236+
235237/**
236238 * Determines if the specified file path corresponds to a Maven metadata file
237239 * by checking against known metadata file extensions. This is used to identify
@@ -244,24 +246,22 @@ function isExcludedDependencyFile(path: string): boolean {
244246 return mavenExcludedExtensions . some ( ( extension ) => path . endsWith ( extension ) )
245247}
246248
247- /**
248- * Gets all files in dir. We use this method to get the source code, then we run a mvn command to
249- * copy over dependencies into their own folder, then we use this method again to get those
250- * dependencies. If isDependenciesFolder is true, then we are getting all the files
251- * of the dependencies which were copied over by the previously-run mvn command, in which case
252- * we DO want to include any dependencies that may happen to be named "target", hence the check
253- * in the first part of the IF statement. The point of excluding folders named target is that
254- * "target" is also the name of the folder where .class files, large JARs, etc. are stored after
255- * building, and we do not want these included in the ZIP so we exclude these when calling
256- * getFilesRecursively on the source code folder.
257- */
249+ // do not zip the .DS_Store file as it may appear in the diff.patch
250+ function isExcludedSourceFile ( path : string ) : boolean {
251+ return sourceExcludedExtensions . some ( ( extension ) => path . endsWith ( extension ) )
252+ }
253+
254+ // zip all dependency files and all source files excluding "target" (contains large JARs) plus ".git" and ".idea" (may appear in diff.patch)
258255function getFilesRecursively ( dir : string , isDependenciesFolder : boolean ) : string [ ] {
259256 const entries = nodefs . readdirSync ( dir , { withFileTypes : true } )
260257 const files = entries . flatMap ( ( entry ) => {
261258 const res = path . resolve ( dir , entry . name )
262- // exclude 'target' directory from ZIP (except if zipping dependencies) due to issues in backend
263259 if ( entry . isDirectory ( ) ) {
264- if ( isDependenciesFolder || entry . name !== 'target' ) {
260+ if ( isDependenciesFolder ) {
261+ // include all dependency files
262+ return getFilesRecursively ( res , isDependenciesFolder )
263+ } else if ( entry . name !== 'target' && entry . name !== '.git' && entry . name !== '.idea' ) {
264+ // exclude the above directories when zipping source code
265265 return getFilesRecursively ( res , isDependenciesFolder )
266266 } else {
267267 return [ ]
@@ -310,8 +310,8 @@ export async function zipCode(
310310 const sourceFiles = getFilesRecursively ( projectPath , false )
311311 let sourceFilesSize = 0
312312 for ( const file of sourceFiles ) {
313- if ( nodefs . statSync ( file ) . isDirectory ( ) ) {
314- getLogger ( ) . info ( 'CodeTransformation: Skipping directory, likely a symlink ' )
313+ if ( nodefs . statSync ( file ) . isDirectory ( ) || isExcludedSourceFile ( file ) ) {
314+ getLogger ( ) . info ( 'CodeTransformation: Skipping file ' )
315315 continue
316316 }
317317 const relativePath = path . relative ( projectPath , file )
0 commit comments