diff --git a/packages/build-tools/src/buildErrors/__tests__/detectError.test.ts b/packages/build-tools/src/buildErrors/__tests__/detectError.test.ts index 937dcb7d..f569fb28 100644 --- a/packages/build-tools/src/buildErrors/__tests__/detectError.test.ts +++ b/packages/build-tools/src/buildErrors/__tests__/detectError.test.ts @@ -249,4 +249,46 @@ note`; - The last one Refer to "Xcode Logs" below for additional, more detailed logs.`); }); + + it('detects MAVEN_CACHE_ERROR correctly', async () => { + const err = await resolveBuildPhaseErrorAsync( + new Error(), + [`https://szymon.pl/maven/cache`], + { + job: { platform: Platform.ANDROID, mode: BuildMode.BUILD } as Job, + phase: BuildPhase.RUN_GRADLEW, + env: { + EAS_BUILD_MAVEN_CACHE_URL: 'https://szymon.pl/maven/cache', + }, + }, + '/fake/path' + ); + + expect(err.errorCode).toBe('MAVEN_CACHE_ERROR'); + expect(err.userFacingErrorCode).toBe('EAS_BUILD_UNKNOWN_GRADLE_ERROR'); + expect(err.userFacingMessage).toBe( + `Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.` + ); + }); + + it('does not throw MAVEN_CACHE_ERROR if "Could not find BlurView-version-2.0.3.jar" log is present', async () => { + const err = await resolveBuildPhaseErrorAsync( + new Error(), + [`Could not find BlurView-version-2.0.3.jar sth sthelse https://szymon.pl/maven/cache`], + { + job: { platform: Platform.ANDROID, mode: BuildMode.BUILD } as Job, + phase: BuildPhase.RUN_GRADLEW, + env: { + EAS_BUILD_MAVEN_CACHE_URL: 'https://szymon.pl/maven/cache', + }, + }, + '/fake/path' + ); + + expect(err.errorCode).toBe('EAS_BUILD_UNKNOWN_GRADLE_ERROR'); + expect(err.userFacingErrorCode).toBe('EAS_BUILD_UNKNOWN_GRADLE_ERROR'); + expect(err.userFacingMessage).toBe( + `Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.` + ); + }); }); diff --git a/packages/build-tools/src/buildErrors/buildErrorHandlers.ts b/packages/build-tools/src/buildErrors/buildErrorHandlers.ts index 97e37383..0d9cd4dd 100644 --- a/packages/build-tools/src/buildErrors/buildErrorHandlers.ts +++ b/packages/build-tools/src/buildErrors/buildErrorHandlers.ts @@ -299,7 +299,13 @@ export const buildErrorHandlers: ErrorHandler[] = [ phase: BuildPhase.RUN_GRADLEW, regexp: ({ env }: ErrorContext) => env.EAS_BUILD_MAVEN_CACHE_URL - ? new RegExp(escapeRegExp(env.EAS_BUILD_MAVEN_CACHE_URL)) + ? // The BlurView 2.0.3 jar was removed from jitpack.io + // and it caused false positive MAVEN_CACHE_ERROR errors being reported. + new RegExp( + `^(?!.*Could not find BlurView-version-2\\.0\\.3\\.jar).*${escapeRegExp( + env.EAS_BUILD_MAVEN_CACHE_URL + )}` + ) : undefined, createError: () => new TrackedBuildError('MAVEN_CACHE_ERROR', `maven: cache error`), },