@@ -50,7 +50,7 @@ public InputStream getPgBinary(String system, String machineHardware) throws IOE
50
50
if (distribution != null ) {
51
51
Resource resource = findPgBinary (normalize (format ("postgres-%s-%s-%s.txz" , system , architecture , distribution )));
52
52
if (resource != null ) {
53
- logger .info ("Distribution specific postgres binaries found: {} " , resource .getFilename ());
53
+ logger .info ("Distribution specific postgres binaries found: '{}' " , resource .getFilename ());
54
54
return resource .getInputStream ();
55
55
} else {
56
56
logger .debug ("Distribution specific postgres binaries not found" );
@@ -59,13 +59,25 @@ public InputStream getPgBinary(String system, String machineHardware) throws IOE
59
59
60
60
Resource resource = findPgBinary (normalize (format ("postgres-%s-%s.txz" , system , architecture )));
61
61
if (resource != null ) {
62
- logger .info ("System specific postgres binaries found: {} " , resource .getFilename ());
62
+ logger .info ("System specific postgres binaries found: '{}' " , resource .getFilename ());
63
63
return resource .getInputStream ();
64
64
}
65
65
66
- logger .error ("No postgres binaries were found, you must add an appropriate maven dependency " +
67
- "that meets the following parameters - system: {}, architecture: {}" , system , architecture );
68
- throw new IllegalStateException ("Missing postgres binaries" );
66
+ if (StringUtils .equals (system , "Darwin" ) && StringUtils .equals (machineHardware , "aarch64" )) {
67
+ resource = findPgBinary (normalize (format ("postgres-%s-%s.txz" , system , "x86_64" )));
68
+ if (resource != null ) {
69
+ logger .warn ("No native binaries supporting aarch64 architecture found. " +
70
+ "Trying to use binaries for amd64 architecture instead: '{}'. " +
71
+ "Make sure you have Rosetta 2 emulation enabled. " +
72
+ "Note that performance may be degraded." , resource .getFilename ());
73
+ return resource .getInputStream ();
74
+ }
75
+ }
76
+
77
+ logger .error ("No postgres binaries found, you need to add an appropriate maven dependency " +
78
+ "that meets the following parameters - system: '{}', architecture: '{}' " +
79
+ "[https://github.com/zonkyio/embedded-postgres#additional-architectures]" , system , architecture );
80
+ throw new IllegalStateException ("Missing embedded postgres binaries" );
69
81
}
70
82
71
83
private static Resource findPgBinary (String resourceLocation ) throws IOException {
@@ -74,8 +86,8 @@ private static Resource findPgBinary(String resourceLocation) throws IOException
74
86
List <URL > urls = Collections .list (classLoader .getResources (resourceLocation ));
75
87
76
88
if (urls .size () > 1 ) {
77
- logger .error ("Detected multiple binaries of the same architecture: {} " , urls );
78
- throw new IllegalStateException ("Duplicate postgres binaries" );
89
+ logger .error ("Detected multiple binaries of the same architecture: '{}' " , urls );
90
+ throw new IllegalStateException ("Duplicate embedded postgres binaries" );
79
91
}
80
92
if (urls .size () == 1 ) {
81
93
return new Resource (urls .get (0 ));
0 commit comments