From: Mathieu Baudier Date: Wed, 6 Mar 2024 16:09:24 +0000 (+0100) Subject: Improve build and local deployment X-Git-Tag: v2.3.28~25 X-Git-Url: https://git.argeo.org/?p=lgpl%2Fargeo-commons.git;a=commitdiff_plain;h=4f899ffcfd5652eb13748535353d2bd09f568bbc Improve build and local deployment --- diff --git a/Makefile b/Makefile index 9011b2dc0..407f4214b 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,4 @@ include sdk.mk -.PHONY: clean all osgi - -all: osgi - $(MAKE) -f Makefile-rcp.mk all - -install: osgi-install - -uninstall: osgi-uninstall A2_CATEGORY = org.argeo.cms @@ -49,10 +41,18 @@ org.argeo.api.uuid \ org.argeo.api.acr \ org.argeo.api.cms -clean: - rm -rf $(BUILD_BASE) +all: osgi-all + $(MAKE) -f Makefile-rcp.mk all + +clean: osgi-clean $(MAKE) -f Makefile-rcp.mk clean -A2_BUNDLES_CLASSPATH = $(subst $(space),$(pathsep),$(strip $(A2_BUNDLES))) +install: osgi-install + $(MAKE) -f Makefile-rcp.mk install + +uninstall: osgi-uninstall + $(MAKE) -f Makefile-rcp.mk uninstall + +include $(SDK_SRC_BASE)/sdk/argeo-build/osgi.mk -include $(SDK_SRC_BASE)/sdk/argeo-build/osgi.mk \ No newline at end of file +.PHONY: clean all install uninstall diff --git a/Makefile-rcp.mk b/Makefile-rcp.mk index 1fb93728c..a9e262843 100644 --- a/Makefile-rcp.mk +++ b/Makefile-rcp.mk @@ -1,7 +1,4 @@ include sdk.mk -.PHONY: clean all osgi - -all: osgi A2_CATEGORY = org.argeo.cms @@ -19,9 +16,16 @@ osgi/api/org.argeo.tp.osgi \ swt/rcp/org.argeo.tp.swt \ lib/linux/x86_64/swt/rcp/org.argeo.tp.swt \ -clean: - rm -rf $(BUILD_BASE) - VPATH = .:swt/rcp -include $(SDK_SRC_BASE)/sdk/argeo-build/osgi.mk \ No newline at end of file +all: osgi-all + +clean: osgi-clean + +install: osgi-install + +uninstall: osgi-uninstall + +include $(SDK_SRC_BASE)/sdk/argeo-build/osgi.mk + +.PHONY: clean all install uninstall diff --git a/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsDeploymentImpl.java b/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsDeploymentImpl.java index 52f97fd8d..0d53a09b0 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsDeploymentImpl.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/runtime/CmsDeploymentImpl.java @@ -64,7 +64,10 @@ public class CmsDeploymentImpl implements CmsDeployment { public void setHttpServer(HttpServer httpServer) { Objects.requireNonNull(httpServer); if (this.httpServer.isDone()) - throw new IllegalStateException("HTTP server is already set"); + if (httpExpected) + throw new IllegalStateException("HTTP server is already set"); + else + return;// ignore // create contexts whose handlers had already been published synchronized (httpHandlers) { synchronized (httpAuthenticators) { @@ -107,7 +110,8 @@ public class CmsDeploymentImpl implements CmsDeployment { } if (!this.httpServer.isDone()) throw new IllegalStateException("HTTP server is not set"); - HttpContext httpContext = httpServer.resultNow().createContext(contextPath); + // TODO use resultNow when switching to Java 21 + HttpContext httpContext = httpServer.join().createContext(contextPath); // we want to set the authenticator BEFORE the handler actually becomes active httpContext.setAuthenticator(authenticator); httpContext.setHandler(httpHandler); @@ -121,7 +125,8 @@ public class CmsDeploymentImpl implements CmsDeployment { httpHandlers.remove(contextPath); if (!httpServer.isDone()) return; - httpServer.resultNow().removeContext(contextPath); + // TODO use resultNow when switching to Java 21 + httpServer.join().removeContext(contextPath); log.debug(() -> "Removed handler " + contextPath + " : " + httpHandler.getClass().getName()); } diff --git a/org.argeo.init/src/org/argeo/init/RuntimeManagerMain.java b/org.argeo.init/src/org/argeo/init/RuntimeManagerMain.java index 9c8692c4b..5a8331dfe 100644 --- a/org.argeo.init/src/org/argeo/init/RuntimeManagerMain.java +++ b/org.argeo.init/src/org/argeo/init/RuntimeManagerMain.java @@ -59,9 +59,22 @@ public class RuntimeManagerMain implements RuntimeManager { logger.log(Level.TRACE, () -> "Runtime manager configuration: " + configuration); +// System.out.println("java.library.path=" + System.getProperty("java.library.path")); } public void run() { +// try { +// for (Path p : Files.newDirectoryStream(Paths.get("/usr/local/lib/a2"), "*.so")) { +// try { +// System.load(p.toString()); +// } catch (UnsatisfiedLinkError e) { +// e.printStackTrace(); +// } +// } +// } catch (IOException e) { +// e.printStackTrace(); +// } + OsgiRuntimeContext managerRuntimeContext = new OsgiRuntimeContext(configuration); try { managerRuntimeContext.run(); diff --git a/org.argeo.init/src/org/argeo/init/logging/ThinLoggerFinder.java b/org.argeo.init/src/org/argeo/init/logging/ThinLoggerFinder.java index 5be74fef9..3fa2bc868 100644 --- a/org.argeo.init/src/org/argeo/init/logging/ThinLoggerFinder.java +++ b/org.argeo.init/src/org/argeo/init/logging/ThinLoggerFinder.java @@ -30,7 +30,10 @@ public class ThinLoggerFinder extends LoggerFinder @Override public Logger getLogger(String name, Module module) { lazyInit(); - return logging.getLogger(name, module); + Objects.requireNonNull(name); + Logger logger = logging.getLogger(name, module); + Objects.requireNonNull(logger); + return logger; } private static void init() { diff --git a/org.argeo.init/src/org/argeo/init/logging/ThinLogging.java b/org.argeo.init/src/org/argeo/init/logging/ThinLogging.java index 2b2f6b3a7..d615678cd 100644 --- a/org.argeo.init/src/org/argeo/init/logging/ThinLogging.java +++ b/org.argeo.init/src/org/argeo/init/logging/ThinLogging.java @@ -194,6 +194,7 @@ class ThinLogging implements Consumer> { if (!loggers.containsKey(name)) { ThinLogger logger = new ThinLogger(name, computeApplicableLevel(name)); loggers.put(name, logger); + return logger; } return loggers.get(name); } diff --git a/sdk/argeo-build b/sdk/argeo-build index 08bc9ba66..6f8e29e85 160000 --- a/sdk/argeo-build +++ b/sdk/argeo-build @@ -1 +1 @@ -Subproject commit 08bc9ba6656515e235eb269c31bc2b1e93748055 +Subproject commit 6f8e29e850f9fcfa5149e296e650355fab930752 diff --git a/swt/org.argeo.swt.minidesktop/.project b/swt/org.argeo.swt.minidesktop/.project index b6c2c1ae4..764a285b2 100644 --- a/swt/org.argeo.swt.minidesktop/.project +++ b/swt/org.argeo.swt.minidesktop/.project @@ -20,6 +20,11 @@ + + org.eclipse.pde.ds.core.builder + + + org.eclipse.pde.PluginNature diff --git a/swt/org.argeo.swt.minidesktop/OSGI-INF/miniDesktop.xml b/swt/org.argeo.swt.minidesktop/OSGI-INF/miniDesktop.xml new file mode 100644 index 000000000..51913c778 --- /dev/null +++ b/swt/org.argeo.swt.minidesktop/OSGI-INF/miniDesktop.xml @@ -0,0 +1,4 @@ + + + + diff --git a/swt/org.argeo.swt.minidesktop/bnd.bnd b/swt/org.argeo.swt.minidesktop/bnd.bnd index f3c13bec5..1b43de5f7 100644 --- a/swt/org.argeo.swt.minidesktop/bnd.bnd +++ b/swt/org.argeo.swt.minidesktop/bnd.bnd @@ -1,2 +1,5 @@ Import-Package: org.eclipse.swt,\ * + +Service-Component:\ +OSGI-INF/miniDesktop.xml,\ diff --git a/swt/org.argeo.swt.minidesktop/build.properties b/swt/org.argeo.swt.minidesktop/build.properties index 34d2e4d2d..04bd7e126 100644 --- a/swt/org.argeo.swt.minidesktop/build.properties +++ b/swt/org.argeo.swt.minidesktop/build.properties @@ -1,4 +1,5 @@ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/miniDesktop.xml source.. = src/ output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/swt/org.argeo.swt.minidesktop/src/org/argeo/minidesktop/MiniDesktopManager.java b/swt/org.argeo.swt.minidesktop/src/org/argeo/minidesktop/MiniDesktopManager.java index adb2a55ba..6604b4f3e 100644 --- a/swt/org.argeo.swt.minidesktop/src/org/argeo/minidesktop/MiniDesktopManager.java +++ b/swt/org.argeo.swt.minidesktop/src/org/argeo/minidesktop/MiniDesktopManager.java @@ -44,82 +44,100 @@ public class MiniDesktopManager { this.stacking = stacking; } + public MiniDesktopManager() { + this(false, false); + } + + public void start() { + init(); + } + + public void stop() { + dispose(); + if (display != null) { + display.dispose(); + display = null; + } + } + public void init() { Display.setAppName("Mini SWT Desktop"); display = Display.getCurrent(); if (display != null) throw new IllegalStateException("Already a display " + display); - display = new Display(); + display = Display.getDefault(); - if (display.getTouchEnabled()) { - System.out.println("Touch enabled."); - } - - images = new MiniDesktopImages(display); + display.syncExec(() -> { + if (display.getTouchEnabled()) { + System.out.println("Touch enabled."); + } - int toolBarSize = 48; + images = new MiniDesktopImages(display); + + int toolBarSize = 48; + + if (isFullscreen()) { + rootShell = new Shell(display, SWT.NO_TRIM); + rootShell.setFullScreen(true); + Rectangle bounds = display.getBounds(); + rootShell.setLocation(0, 0); + rootShell.setSize(bounds.width, bounds.height); + } else { + rootShell = new Shell(display, SWT.CLOSE | SWT.RESIZE); + Rectangle shellArea = rootShell.computeTrim(200, 200, 800, 480); + rootShell.setSize(shellArea.width, shellArea.height); + rootShell.setText(Display.getAppName()); + rootShell.setImage(images.terminalIcon); + } - if (isFullscreen()) { - rootShell = new Shell(display, SWT.NO_TRIM); - rootShell.setFullScreen(true); - Rectangle bounds = display.getBounds(); - rootShell.setLocation(0, 0); - rootShell.setSize(bounds.width, bounds.height); - } else { - rootShell = new Shell(display, SWT.CLOSE | SWT.RESIZE); - Rectangle shellArea = rootShell.computeTrim(200, 200, 800, 480); - rootShell.setSize(shellArea.width, shellArea.height); - rootShell.setText(Display.getAppName()); - rootShell.setImage(images.terminalIcon); - } + rootShell.setLayout(noSpaceGridLayout(new GridLayout(2, false))); + Composite toolBarArea = new Composite(rootShell, SWT.NONE); + toolBarArea.setLayoutData(new GridData(toolBarSize, rootShell.getSize().y)); - rootShell.setLayout(noSpaceGridLayout(new GridLayout(2, false))); - Composite toolBarArea = new Composite(rootShell, SWT.NONE); - toolBarArea.setLayoutData(new GridData(toolBarSize, rootShell.getSize().y)); - - ToolBar toolBar; - if (isFullscreen()) { - toolBarShell = new Shell(rootShell, SWT.NO_TRIM | SWT.ON_TOP); - toolBar = new ToolBar(toolBarShell, SWT.VERTICAL | SWT.FLAT | SWT.BORDER); - createDock(toolBar); - toolBarShell.pack(); - toolBarArea.setLayoutData(new GridData(toolBar.getSize().x, toolBar.getSize().y)); - } else { - toolBar = new ToolBar(toolBarArea, SWT.VERTICAL | SWT.FLAT | SWT.BORDER); - createDock(toolBar); - toolBarArea.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); - } + ToolBar toolBar; + if (isFullscreen()) { + toolBarShell = new Shell(rootShell, SWT.NO_TRIM | SWT.ON_TOP); + toolBar = new ToolBar(toolBarShell, SWT.VERTICAL | SWT.FLAT | SWT.BORDER); + createDock(toolBar); + toolBarShell.pack(); + toolBarArea.setLayoutData(new GridData(toolBar.getSize().x, toolBar.getSize().y)); + } else { + toolBar = new ToolBar(toolBarArea, SWT.VERTICAL | SWT.FLAT | SWT.BORDER); + createDock(toolBar); + toolBarArea.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); + } - if (isStacking()) { - tabFolder = new CTabFolder(rootShell, SWT.MULTI | SWT.BORDER | SWT.BOTTOM); - tabFolder.setLayout(noSpaceGridLayout(new GridLayout())); - tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - Color selectionBackground = display.getSystemColor(SWT.COLOR_LIST_SELECTION); - tabFolder.setSelectionBackground(selectionBackground); - - // background - Control background = createBackground(tabFolder); - CTabItem homeTabItem = new CTabItem(tabFolder, SWT.NONE); - homeTabItem.setText("Home"); - homeTabItem.setImage(images.homeIcon); - homeTabItem.setControl(background); - tabFolder.setFocus(); - } else { - createBackground(rootShell); - } + if (isStacking()) { + tabFolder = new CTabFolder(rootShell, SWT.MULTI | SWT.BORDER | SWT.BOTTOM); + tabFolder.setLayout(noSpaceGridLayout(new GridLayout())); + tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + Color selectionBackground = display.getSystemColor(SWT.COLOR_LIST_SELECTION); + tabFolder.setSelectionBackground(selectionBackground); + + // background + Control background = createBackground(tabFolder); + CTabItem homeTabItem = new CTabItem(tabFolder, SWT.NONE); + homeTabItem.setText("Home"); + homeTabItem.setImage(images.homeIcon); + homeTabItem.setControl(background); + tabFolder.setFocus(); + } else { + createBackground(rootShell); + } - rootShell.open(); - // rootShell.layout(true, true); + rootShell.open(); + // rootShell.layout(true, true); - if (toolBarShell != null) { - int toolBarShellY = (display.getBounds().height - toolBar.getSize().y) / 2; - toolBarShell.setLocation(0, toolBarShellY); - toolBarShell.open(); - } + if (toolBarShell != null) { + int toolBarShellY = (display.getBounds().height - toolBar.getSize().y) / 2; + toolBarShell.setLocation(0, toolBarShellY); + toolBarShell.open(); + } - long jvmUptime = ManagementFactory.getRuntimeMXBean().getUptime(); - System.out.println("SWT Mini Desktop Manager available in " + jvmUptime + " ms."); + long jvmUptime = ManagementFactory.getRuntimeMXBean().getUptime(); + System.out.println("SWT Mini Desktop Manager available in " + jvmUptime + " ms."); + }); } protected void createDock(ToolBar toolBar) {