Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ecomod
zmt-build
Commits
10f906f6
Commit
10f906f6
authored
Oct 26, 2016
by
Christian Meyer
Browse files
ZmtShortcutPlugin.java: resulting shortcut's filename contains sim name
parent
3202f4eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/groovy/de/zmt/gradle/ZmtShortcutPlugin.groovy
View file @
10f906f6
...
...
@@ -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_
UN
IX
,
shortcutDir
)
def
unixShortcut
=
createLauncherShortcut
(
project
,
SHORTCUT_
PREFIX
,
SHORTCUT_SUFF
IX
,
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
.
findS
imClassName
(
project
)
]
def
templateUrl
=
ZmtLaunchPlugin
.
class
.
getResource
(
filename
)
def
binding
=
[
simClassName
:
s
imClassName
]
def
templateUrl
=
ZmtLaunchPlugin
.
class
.
getResource
(
prefix
+
SEPARATOR
+
suffix
)
shortcut
.
append
(
TEMPLATE_ENGINE
.
createTemplate
(
templateUrl
).
make
(
binding
))
return
shortcut
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment