Skip to content

Commit

Permalink
Removed ability to export to a standalone executable JAR file. This h…
Browse files Browse the repository at this point in the history
…ad a few bugs anyway, but was also increasingly difficult to support since it required Java and JavaFX to be present on the destination machine, and to construct a complex classpath to run the JAR.
  • Loading branch information
neilccbrown committed Nov 27, 2023
1 parent 63966ab commit 6909329
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 276 deletions.
1 change: 0 additions & 1 deletion greenfoot/labels/english/greenfoot/greenfoot-labels
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export.app.help=Create an executable jar file that can be run on its own.
export.app.location=Save to:
export.app.browse=Browse
export.app.choose=Save executable jar file
export.app.more=More information on running on other machines
export.project.help=Create a standalone project gfar file. This allows the whole project to be given to other people as a single file that Greenfoot can open directly.
export.project.location=Save to:
export.project.browse=Browse
Expand Down
59 changes: 2 additions & 57 deletions greenfoot/src/main/java/greenfoot/export/Exporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ of the License, or (at your option) any later version.
import bluej.Boot;
import bluej.Config;
import bluej.pkgmgr.Project;
import bluej.utility.Utility;

import greenfoot.event.PublishEvent;
import greenfoot.event.PublishListener;
Expand All @@ -43,7 +42,6 @@ of the License, or (at your option) any later version.
import java.util.concurrent.ExecutionException;

import javafx.application.Platform;
import javafx.embed.swing.SwingFXUtils;
import javafx.geometry.Dimension2D;

import org.glavo.png.javafx.PNGJavaFXUtils;
Expand All @@ -65,7 +63,7 @@ public class Exporter implements PublishListener
*/
public enum ExportFunction
{
PUBLISH, PROJECT, APP;
PUBLISH, PROJECT;

/**
* Returns the export function which corresponds to the passed name.
Expand Down Expand Up @@ -157,10 +155,6 @@ public void doExport(Project project, ExportDialog dialog, ScenarioSaver scenari
{
publishToWebServer();
}
if (function.equals(ExportFunction.APP))
{
makeApplication();
}
if (function.equals(ExportFunction.PROJECT))
{
makeProject();
Expand Down Expand Up @@ -196,7 +190,7 @@ private void publishToWebServer()
boolean lockScenario = scenarioInfo.isLocked();

JarCreator jarCreator = new JarCreator(project, exportDir, jarName, worldName,
lockScenario, true);
lockScenario);

// do not include source
jarCreator.includeSource(false);
Expand Down Expand Up @@ -318,55 +312,6 @@ private static File[] getJarsInPlusLib(Project project)
File plusLibsDir = new File(project.getProjectDir(), Project.projectLibDirName);
return plusLibsDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".jar"));
}

/**
* Create an application (jar-file)
*/
@OnThread(Tag.Worker)
private void makeApplication()
{
dialog.setProgress(true, Config.getString("export.progress.writingJar"));
File exportFile = new File(scenarioInfo.getExportFileName());
File exportDir = exportFile.getParentFile();
String jarName = exportFile.getName();

boolean lockScenario = scenarioInfo.isLocked();
boolean hideControls = scenarioInfo.isHideControls();

JarCreator jarCreator = new JarCreator(project, exportDir, jarName, worldName,
lockScenario, hideControls, false, false);
// do not include source
jarCreator.includeSource(false);

// Add the Greenfoot standalone classes
File greenfootLibDir = Config.getGreenfootLibDir();
File greenfootDir = new File(greenfootLibDir, "standalone");
jarCreator.addFile(greenfootDir);

// Add 3rd party libraries used by Greenfoot.
Set<File> thirdPartyLibs = GreenfootUtil.get3rdPartyLibs();
for (File lib : thirdPartyLibs) {
jarCreator.addJarToJar(lib);
}

// Add jars in +libs dir in project directory
File[] jarFiles = getJarsInPlusLib(project);
if (jarFiles != null) {
for (File file : jarFiles) {
jarCreator.addJarToJar(file);
}
}

// Add text file with license information
File license = new File(Config.getGreenfootLibDir(), "GREENFOOT_LICENSES.txt");
if (license.exists())
{
jarCreator.addFile(license);
}

jarCreator.create();
dialog.setProgress(false, Config.getString("export.progress.complete"));
}

/**
* Create an standalone project (gfar-file)
Expand Down

This file was deleted.

32 changes: 4 additions & 28 deletions greenfoot/src/main/java/greenfoot/export/JarCreator.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the Greenfoot program.
Copyright (C) 2005-2009,2010,2011,2013,2014,2015,2018,2019 Poul Henriksen and Michael Kolling
Copyright (C) 2005-2009,2010,2011,2013,2014,2015,2018,2019,2023 Poul Henriksen and Michael Kolling
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -122,29 +122,6 @@ private JarCreator(File exportDir, String jarName)
this.jarName = jarName;
properties = new Properties();
}

/**
* Export the class files for a project.
*
* Convenience constructor that includes settings that are common for all
* projects and export types. This will exclude BlueJ metafiles.
*
* @param project The project to be exported.
* @param exportDir The directory to export to.
* @param jarName Name of the jar file that should be created.
* @param worldClass Name of the main class.
* @param lockScenario Should the exported scenario include 'act'
* and speedslider.
* @param hideControls Should the exported scenario include the controls panel
* @param applet Whether the export is for an applet on a webpage (true) or for a stand-alone JAR (false)
*/
public JarCreator(Project project, File exportDir, String jarName, String worldClass,
boolean lockScenario, boolean hideControls, boolean fullScreen, boolean applet)
{
this(project, exportDir, jarName, worldClass, lockScenario, applet);
properties.put("scenario.hideControls", "" + hideControls);
properties.put("scenario.fullScreen", "" + fullScreen);
}

/**
* Export the class files for a project.
Expand All @@ -157,11 +134,10 @@ public JarCreator(Project project, File exportDir, String jarName, String worldC
* @param jarName Name of the jar file that should be created.
* @param worldClass Name of the main class.
* @param lockScenario Should the exported scenario include 'act'
* and speedslider.
* @param applet Whether the export is for an applet on a webpage (true) or for a stand-alone JAR (false)
* and speedslider.
*/
public JarCreator(Project project, File exportDir, String jarName, String worldClass,
boolean lockScenario, boolean applet)
boolean lockScenario)
{
this(exportDir, jarName);

Expand Down Expand Up @@ -197,7 +173,7 @@ public JarCreator(Project project, File exportDir, String jarName, String worldC
addSkipDir(Project.projectLibDirName);

// Set the main class
String mainClass = (applet ? GreenfootScenarioViewer.class : GreenfootScenarioApplication.class).getCanonicalName();
String mainClass = GreenfootScenarioViewer.class.getCanonicalName();
setMainClass(mainClass);

// Add the properties read by the GreenfootScenarioViewer
Expand Down
122 changes: 0 additions & 122 deletions greenfoot/src/main/java/greenfoot/guifx/export/ExportAppTab.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ private void createTabs()
File defaultExportDir = project.getProjectDir().getParentFile();

addTab(new ExportPublishTab(project, this, scenarioSaver, scenarioInfo));
addTab(new ExportAppTab(asWindow, scenarioInfo, projectName, defaultExportDir));
addTab(new ExportProjectTab(asWindow, scenarioInfo, projectName, defaultExportDir));

tabbedPane.getTabs().setAll(exportTabs.values());
Expand Down

0 comments on commit 6909329

Please sign in to comment.