Skip to content

Commit

Permalink
Pass command line arguments to packaged program on Windows (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGreatCabbage authored and tomcashman committed Jul 31, 2019
1 parent adc7c0e commit 0eb34cc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[1.6.0]
- Exe now passes command line arguments to packaged program

[1.5.1-SNAPSHOT]

[1.5.0]
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8

group = 'org.mini2Dx'
version = '1.5.1-SNAPSHOT'
version = '1.6.0'
description = 'Gradle plugin for bundling your Java application for distribution on Windows, Mac and Linux'

dependencies {
Expand Down
7 changes: 6 additions & 1 deletion natives/windows/JavaApplicationConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class JavaApplicationConfig
[XmlElement("includesJre")]
public bool IncludesJre { get; set; }

public String ToStartInfoArguments()
public String ToStartInfoArguments(String[] runtimeArgs)
{
StringBuilder arguments = new StringBuilder();
if (VmArgs != null)
Expand All @@ -75,6 +75,11 @@ public String ToStartInfoArguments()
}
}

foreach (String arg in runtimeArgs)
{
arguments.Append(" " + arg);
}

return arguments.ToString();
}
}
Expand Down
4 changes: 2 additions & 2 deletions natives/windows/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void Main(string[] args)

try
{
if (args.Length > 0)
if (args.Length == 1 && args[0].Equals("--example"))
{
JavaApplicationConfig exampleConfig = new JavaApplicationConfig();
exampleConfig.ClassPath = new List<String>();
Expand Down Expand Up @@ -85,7 +85,7 @@ static void Main(string[] args)
return;
}
}
process.StartInfo.Arguments = applicationConfig.ToStartInfoArguments();
process.StartInfo.Arguments = applicationConfig.ToStartInfoArguments(args);
process.StartInfo.WorkingDirectory = @AppDomain.CurrentDomain.BaseDirectory;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
Expand Down

0 comments on commit 0eb34cc

Please sign in to comment.