@Test @EnabledOnOs(OS.MAC) public void testCreateDesktopLink() throws Exception { FileUtils.recursiveDelete(new File(userHome), new File("/tmp")); assertTrue(new File(userHome).exists() == false); final String appName = "MyFirstApp"; final String appNameWithSuffix = appName + AppFactory.APP_EXTENSION; final Path desktop = Paths.get(JavaSystemProperties.getUserHome(), "Desktop"); Files.createDirectories(desktop); assertTrue(Files.isDirectory(desktop)); final Path link = desktop.resolve(appNameWithSuffix); assertTrue(Files.exists(link) == false); AppFactory.createDesktopLink(appName, script, IcnsFactorySample.class.getResource("icon.png").getFile()); assertTrue(Files.isSymbolicLink(link)); }
public final static void createDesktopLink(final String appname, final String script, final String... iconPaths) throws Exception { Assert.requireNonBlank(appname, "appname"); if (!desktopLinkExists(appname)) { final Path approot = getApplicationRootInCache(appname); if (!Files.isDirectory(approot)) { createAppWithoutMenuEntry(appname, script, iconPaths); } final Path link = getDesktopLink(appname); Files.deleteIfExists(link); Files.createSymbolicLink(link, approot); } }
AppFactory { public final static void createDesktopLink(final String appname, final String script, final String... iconPaths) throws Exception { Assert.requireNonBlank(appname, "appname"); if (!desktopLinkExists(appname)) { final Path approot = getApplicationRootInCache(appname); if (!Files.isDirectory(approot)) { createAppWithoutMenuEntry(appname, script, iconPaths); } final Path link = getDesktopLink(appname); Files.deleteIfExists(link); Files.createSymbolicLink(link, approot); } } }
AppFactory { public final static void createDesktopLink(final String appname, final String script, final String... iconPaths) throws Exception { Assert.requireNonBlank(appname, "appname"); if (!desktopLinkExists(appname)) { final Path approot = getApplicationRootInCache(appname); if (!Files.isDirectory(approot)) { createAppWithoutMenuEntry(appname, script, iconPaths); } final Path link = getDesktopLink(appname); Files.deleteIfExists(link); Files.createSymbolicLink(link, approot); } }  }
AppFactory { public final static void createDesktopLink(final String appname, final String script, final String... iconPaths) throws Exception { Assert.requireNonBlank(appname, "appname"); if (!desktopLinkExists(appname)) { final Path approot = getApplicationRootInCache(appname); if (!Files.isDirectory(approot)) { createAppWithoutMenuEntry(appname, script, iconPaths); } final Path link = getDesktopLink(appname); Files.deleteIfExists(link); Files.createSymbolicLink(link, approot); } }  static boolean exists(final String name); static void createApp(final String name, final String script, final String... iconPaths); final static boolean desktopLinkExists(final String appname); final static void createDesktopLink(final String appname, final String script, final String... iconPaths); }
AppFactory { public final static void createDesktopLink(final String appname, final String script, final String... iconPaths) throws Exception { Assert.requireNonBlank(appname, "appname"); if (!desktopLinkExists(appname)) { final Path approot = getApplicationRootInCache(appname); if (!Files.isDirectory(approot)) { createAppWithoutMenuEntry(appname, script, iconPaths); } final Path link = getDesktopLink(appname); Files.deleteIfExists(link); Files.createSymbolicLink(link, approot); } }  static boolean exists(final String name); static void createApp(final String name, final String script, final String... iconPaths); final static boolean desktopLinkExists(final String appname); final static void createDesktopLink(final String appname, final String script, final String... iconPaths); final static String CONTENTS_FOLDER_NAME; final static String APP_EXTENSION; }