@@ -86,11 +86,7 @@ public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurab
8686 /**
8787 * Pipeline for building JAR
8888 */
89- public final JARLauncherBinary launcherBinary ;
90- /**
91- * Pipeline for building EXE
92- */
93- public final LauncherBinary launcherEXEBinary ;
89+ public final Map <UpdatesProvider .UpdateVariant , LauncherBinary > launcherBinaries ;
9490 // Server config
9591 public final AuthHookManager authHookManager ;
9692 public final LaunchServerModulesManager modulesManager ;
@@ -165,11 +161,8 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La
165161 modulesManager .invokeEvent (new LaunchServerInitPhase (this ));
166162
167163 // Set launcher EXE binary
168- launcherBinary = new JARLauncherBinary (this );
169- launcherEXEBinary = binary ();
170-
171- launcherBinary .init ();
172- launcherEXEBinary .init ();
164+ launcherBinaries = new HashMap <>();
165+ collectBinary ();
173166 launcherModuleLoader = new LauncherModuleLoader (this );
174167 if (config .components != null ) {
175168 logger .debug ("Init components" );
@@ -307,30 +300,34 @@ public Path createTempFilePath(String name, String ext) throws IOException {
307300 return path ;
308301 }
309302
310- private LauncherBinary binary () {
311- LaunchServerLauncherExeInit event = new LaunchServerLauncherExeInit (this , null );
303+ private void collectBinary () throws IOException {
304+ launcherBinaries .clear ();
305+ launcherBinaries .put (UpdatesProvider .UpdateVariant .JAR , new JARLauncherBinary (this ));
306+ LaunchServerLauncherBinaryInit event = new LaunchServerLauncherBinaryInit (this , launcherBinaries );
312307 modulesManager .invokeEvent (event );
313- if ( event . binary != null ) {
314- return event . binary ;
308+ for ( var e : launcherBinaries . values () ) {
309+ e . init () ;
315310 }
316- return new EXELauncherBinary (this );
317311 }
318312
319313 public void buildLauncherBinaries () throws IOException {
320- PipelineContext launcherContext = launcherBinary .build ();
321- PipelineContext exeContext = launcherEXEBinary .build ();
322- UpdatesProvider .UpdateUploadInfo jarInfo = launcherContext .makeUploadInfo (UpdatesProvider .UpdateVariant .JAR );
323- UpdatesProvider .UpdateUploadInfo exeInfo = exeContext .makeUploadInfo (UpdatesProvider .UpdateVariant .EXE );
324- List <UpdatesProvider .UpdateUploadInfo > list = new ArrayList <>(2 );
325- if (jarInfo != null ) {
326- list .add (jarInfo );
327- }
328- if (exeInfo != null ) {
329- list .add (exeInfo );
314+ List <PipelineContext > contexts = new ArrayList <>(2 );
315+ try {
316+ List <UpdatesProvider .UpdateUploadInfo > list = new ArrayList <>(2 );
317+ for (var e : launcherBinaries .entrySet ()) {
318+ var variant = e .getKey ();
319+ var binary = e .getValue ();
320+ var context = binary .build ();
321+ var info = context .makeUploadInfo (variant );
322+ list .add (info );
323+ contexts .add (context );
324+ }
325+ config .updatesProvider .pushUpdate (list );
326+ } finally {
327+ for (var e : contexts ) {
328+ e .clear ();
329+ }
330330 }
331- config .updatesProvider .pushUpdate (list );
332- launcherContext .clear ();
333- exeContext .clear ();
334331 }
335332
336333 public void close () throws Exception {
0 commit comments