3131import com .google .protobuf .util .JsonFormat ;
3232import java .io .IOException ;
3333import java .nio .charset .StandardCharsets ;
34+ import java .time .LocalDateTime ;
3435import java .util .List ;
3536import java .util .jar .JarEntry ;
3637import java .util .jar .JarOutputStream ;
@@ -124,7 +125,7 @@ static void writeReflectConfigFile(
124125 String jarEntryLocation =
125126 String .format ("src/main/resources/META-INF/native-image/%s/reflect-config.json" , pakkage );
126127 try {
127- jos .putNextEntry (new JarEntry (jarEntryLocation ));
128+ jos .putNextEntry (jarEntry (jarEntryLocation ));
128129 jos .write (prettyGson .toJson (reflectConfigInfo ).getBytes (StandardCharsets .UTF_8 ));
129130 } catch (IOException e ) {
130131 throw new GapicWriterException ("Could not write reflect-config.json" , e );
@@ -141,7 +142,7 @@ private static String writeClazz(
141142
142143 String path = getPath (clazz .packageString (), clazz .classIdentifier ().name ());
143144 String className = clazz .classIdentifier ().name ();
144- JarEntry jarEntry = new JarEntry (String .format ("%s/%s.java" , path , className ));
145+ JarEntry jarEntry = jarEntry (String .format ("%s/%s.java" , path , className ));
145146 try {
146147 jos .putNextEntry (jarEntry );
147148 jos .write (code .getBytes (StandardCharsets .UTF_8 ));
@@ -159,7 +160,7 @@ private static void writeSamples(
159160 GapicClass gapicClazz , String pakkage , String clazzPath , JarOutputStream jos ) {
160161 for (Sample sample : gapicClazz .samples ()) {
161162 JarEntry jarEntry =
162- new JarEntry (
163+ jarEntry (
163164 String .format (
164165 "samples/snippets/generated/%s/%s/%s/%s.java" ,
165166 clazzPath ,
@@ -189,7 +190,7 @@ static String writePackageInfo(
189190 codeWriter .clear ();
190191
191192 String packagePath = "src/main/java/" + packageInfo .pakkage ().replaceAll ("\\ ." , "/" );
192- JarEntry jarEntry = new JarEntry (String .format ("%s/package-info.java" , packagePath ));
193+ JarEntry jarEntry = jarEntry (String .format ("%s/package-info.java" , packagePath ));
193194 try {
194195 jos .putNextEntry (jarEntry );
195196 jos .write (code .getBytes (StandardCharsets .UTF_8 ));
@@ -201,7 +202,7 @@ static String writePackageInfo(
201202
202203 private static void writeMetadataFile (GapicContext context , String path , JarOutputStream jos ) {
203204 if (context .gapicMetadataEnabled ()) {
204- JarEntry jarEntry = new JarEntry (String .format ("%s/gapic_metadata.json" , path ));
205+ JarEntry jarEntry = jarEntry (String .format ("%s/gapic_metadata.json" , path ));
205206 try {
206207 jos .putNextEntry (jarEntry );
207208 jos .write (
@@ -230,4 +231,10 @@ private static String getPath(String pakkage, String className) {
230231 private static String getSamplePackage (GapicClass gapicClazz ) {
231232 return gapicClazz .classDefinition ().packageString ().concat (".samples" );
232233 }
234+
235+ private static JarEntry jarEntry (String name ) {
236+ JarEntry entry = new JarEntry (name );
237+ entry .setTimeLocal (LocalDateTime .of (2010 , 1 , 1 , 0 , 0 , 0 ));
238+ return entry ;
239+ }
233240}
0 commit comments