Ejemplo n.º 1
0
        private void RefreshCommandLine()
        {
            CommandLineBuilder commandLine = new CommandLineBuilder();

            switch (StartAction)
            {
            case StartAction.Class:
                var projectConfigs = ParentPropertyPage.Configurations;
                JavaProjectConfig projectConfig = projectConfigs != null && projectConfigs.Count == 1 ? (JavaProjectConfig)projectConfigs[0] : null;
                string            javaPath      = projectConfig != null?projectConfig.FindJavaBinary("java.exe", true) : null;

                commandLine.AppendFileNameIfNotNull(javaPath);

                string agentSwitch;
                if (DebugAgent == DebugAgent.Jdwp)
                {
                    agentSwitch = "-Xrunjdwp:transport=dt_socket,server=y,address=6777";
                }
                else
                {
                    agentSwitch = "-agentpath:{AgentPath}";
                }

                commandLine.AppendSwitch(agentSwitch);
                if (!string.IsNullOrEmpty(AgentArguments))
                {
                    commandLine.AppendTextUnquoted("=" + AgentArguments);
                }

                if (!string.IsNullOrEmpty(VirtualMachineArguments))
                {
                    commandLine.AppendTextUnquoted(" " + VirtualMachineArguments);
                }

                if (!string.IsNullOrEmpty(StartClass))
                {
                    commandLine.AppendFileNameIfNotNull(StartClass);
                }

                break;

            case StartAction.Program:
            case StartAction.Browser:
                throw new NotSupportedException();

            case StartAction.Unknown:
            default:
                break;
            }

            if (!string.IsNullOrEmpty(ExtraArguments))
            {
                commandLine.AppendTextUnquoted(" " + ExtraArguments);
            }

            txtCommandLine.Text = commandLine.ToString();
        }
        internal void RefreshCommandLine()
        {
            CommandLineBuilder commandLine = new CommandLineBuilder();

            string javacPath = null;

            if (ParentPropertyPage.ProjectManager != null && ParentPropertyPage.ProjectManager.SharedBuildOptions.General != null)
            {
                javacPath = ParentPropertyPage.ProjectManager.SharedBuildOptions.General.JavacPath;
            }
            if (javacPath == null)
            {
                javacPath = ParentPropertyPage.GetConfigProperty(JavaConfigConstants.JavacPath, _PersistStorageType.PST_PROJECT_FILE);
            }

            string fullucc = javacPath;

            try
            {
                if (!string.IsNullOrEmpty(fullucc) && !Path.IsPathRooted(fullucc) && ParentPropertyPage.ProjectManager != null)
                {
                    fullucc = Path.Combine(ParentPropertyPage.ProjectManager.ProjectFolder, javacPath);
                }
            }
            catch (ArgumentException)
            {
                fullucc = javacPath;
            }

            if (string.IsNullOrEmpty(fullucc))
            {
                var projectConfigs = ParentPropertyPage.Configurations;
                JavaProjectConfig projectConfig = projectConfigs != null && projectConfigs.Count == 1 ? (JavaProjectConfig)projectConfigs[0] : null;
                fullucc = projectConfig != null?projectConfig.FindJavaBinary("javac.exe", true) : null;
            }

            commandLine.AppendFileNameIfNotNull(fullucc);

            commandLine.AppendSwitchIfNotNullOrEmpty("-encoding ", Encoding);

            switch (DebuggingInformation)
            {
            case DebuggingInformation.All:
                commandLine.AppendSwitch("-g");
                break;

            case DebuggingInformation.Specific:
                if (!string.IsNullOrEmpty(SpecificDebuggingInformation))
                {
                    commandLine.AppendSwitchIfNotNull("-g:", SpecificDebuggingInformation);
                }
                else
                {
                    commandLine.AppendSwitch("-g:none");
                }

                break;

            case DebuggingInformation.None:
                commandLine.AppendSwitch("-g:none");
                break;

            case DebuggingInformation.Default:
            default:
                break;
            }

            if (!string.IsNullOrEmpty(SourceRelease) && !string.Equals(SourceRelease, "Default", StringComparison.OrdinalIgnoreCase))
            {
                commandLine.AppendSwitchIfNotNull("-source ", SourceRelease);
            }
            if (!string.IsNullOrEmpty(TargetRelease) && !string.Equals(TargetRelease, "Default", StringComparison.OrdinalIgnoreCase))
            {
                commandLine.AppendSwitchIfNotNull("-target ", TargetRelease);
            }

            commandLine.AppendSwitchIfNotNullOrEmpty("-d ", OutputPath);

            if (!ShowWarnings)
            {
                commandLine.AppendSwitch("-nowarn");
            }
            else if (ShowAllWarnings)
            {
                commandLine.AppendSwitch("-Xlint");
                commandLine.AppendSwitch("-deprecation");
            }

            if (!string.IsNullOrEmpty(ExtraArguments))
            {
                commandLine.AppendTextUnquoted(" " + ExtraArguments);
            }

            txtBuildCommandLine.Text = commandLine.ToString();
        }