Commit 10f906f6 authored by Christian Meyer's avatar Christian Meyer
Browse files

ZmtShortcutPlugin.java: resulting shortcut's filename contains sim name

parent 3202f4eb
......@@ -11,8 +11,10 @@ import java.nio.file.attribute.PosixFilePermissions
* GUI mode.
*/
public class ZmtShortcutPlugin implements Plugin<Project> {
private static final def SHORTCUT_UNIX = 'run-with-gui'
private static final def SHORTCUT_WIN = 'run-with-gui.bat'
private static final def SEPARATOR = '-'
private static final def SHORTCUT_PREFIX = 'run'
private static final def SHORTCUT_SUFFIX = 'with-gui'
private static final def SUFFIX_WIN = '.bat'
private static final def TEMPLATE_ENGINE = new groovy.text.SimpleTemplateEngine()
......@@ -22,12 +24,12 @@ public class ZmtShortcutPlugin implements Plugin<Project> {
// create shortcuts
def shortcutDir = Files.createTempDirectory('shortcuts')
afterEvaluate {
def unixShortcut = createLauncherShortcut(project, SHORTCUT_UNIX, shortcutDir)
def unixShortcut = createLauncherShortcut(project, SHORTCUT_PREFIX, SHORTCUT_SUFFIX, shortcutDir)
// set +x permissions if possible
if (FileSystems.getDefault().supportedFileAttributeViews().contains("posix")) {
Files.setPosixFilePermissions(unixShortcut, PosixFilePermissions.fromString('rwxr-xr-x'))
}
createLauncherShortcut(project, SHORTCUT_WIN, shortcutDir)
createLauncherShortcut(project, SHORTCUT_PREFIX, SHORTCUT_SUFFIX + SUFFIX_WIN, shortcutDir)
}
distributions.main.contents {
......@@ -41,15 +43,18 @@ public class ZmtShortcutPlugin implements Plugin<Project> {
* and saved to the given directory.
*
* @param project the project
* @param filename the file name of the template and the resulting file
* @param prefix the prefix of the template and resulting file name
* @param suffix the suffix of the template and resulting file name
* @param directory the directory where to save the resulting file
* @return the path to the resulting file
*/
private static Path createLauncherShortcut(Project project, String filename, Path directory) {
Path shortcut = Files.createFile(directory.resolve(filename))
private static Path createLauncherShortcut(Project project, String prefix, String suffix, Path directory) {
def simClassName = ZmtLaunchConfigPlugin.findSimClassName(project)
// add sim name to shortcut
Path shortcut = Files.createFile(directory.resolve(prefix + SEPARATOR + simClassName + SEPARATOR + suffix))
def binding = [simClassName : ZmtLaunchConfigPlugin.findSimClassName(project)]
def templateUrl = ZmtLaunchPlugin.class.getResource(filename)
def binding = [simClassName : simClassName]
def templateUrl = ZmtLaunchPlugin.class.getResource(prefix + SEPARATOR + suffix)
shortcut.append(TEMPLATE_ENGINE.createTemplate(templateUrl).make(binding))
return shortcut
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment