Example #1
0
 public void MvnPackage()
 {
     try
     {
         string        path   = stb_local_pdir.Text;
         DirectoryInfo dire   = new DirectoryInfo(path);
         String        cmd    = string.Format("cd {0} & mvn package --settings {1} -DskipTests", dire.Parent.FullName, stb_maven_xml.Text);
         CmdResult     result = Command.run(cmd);
         if (result.isFailed())
         {
             errorLabel.Text = "打包失败:" + result.result;
             run             = false;
             MessageBox.Show(this, errorLabel.Text);
         }
         else if (result.isSuccess())
         {
             step = 3;
         }
     }
     catch (Exception ex)
     {
         errorLabel.Text = "mvn package 异常:" + ex.Message;
         run             = false;
         MessageBox.Show(this, errorLabel.Text);
     }
 }
Example #2
0
        private void IceDeployVersionForm_Load(object sender, EventArgs e)
        {
            stb_remote_pdir.Text = ice.IceSrvDir;
            if (ice.Project != null)
            {
                if (null != ice.Project.LocalCodePath)
                {
                    stb_local_pdir.Text = ice.Project.LocalCodePath;
                }
                if (null != ice.Project.LocalIceXmlPath)
                {
                    stb_icexml.Text = ice.Project.LocalIceXmlPath;
                }
                if (null != ice.Project.MavenSetting)
                {
                    stb_maven_xml.Text = ice.Project.MavenSetting;
                }
            }

            stb_local_pdir.SkinTxt.TextChanged += stb_local_pdir_TextChanged;

            stb_local_pdir.SkinTxt.AllowDrop  = true;
            stb_local_pdir.SkinTxt.DragDrop  += stb_local_pdir_DragDrop;
            stb_local_pdir.SkinTxt.DragEnter += stb_local_pdir_DragEnter;

            stb_icexml.SkinTxt.AllowDrop  = true;
            stb_icexml.SkinTxt.DragDrop  += stb_icexml_DragDrop;
            stb_icexml.SkinTxt.DragEnter += stb_icexml_DragEnter;


            stb_maven_xml.SkinTxt.AllowDrop  = true;
            stb_maven_xml.SkinTxt.DragDrop  += stb_maven_xml_DragDrop;
            stb_maven_xml.SkinTxt.DragEnter += stb_maven_xml_DragEnter;

            if (stb_maven_xml.Text == "")
            {
                try
                {
                    CmdResult result = Command.run("mvn -v");
                    if (result.isFailed())
                    {
                        errorLabel.Text = "检测到未安装Maven或者未设置Maven环境变量,需手动打包";
                    }
                    else if (result.isSuccess())
                    {
                        // Maven home: F:\Server\apache-maven-3.3.9\bin\..
                        int index = result.result.IndexOf("Maven home:");
                        if (index != -1)
                        {
                            int    len  = result.result.IndexOf("..", index);
                            string line = result.result.Substring(index, len - index);
                            len       = "Maven home:".Length;
                            mavenHome = line.Substring(len, line.IndexOf("bin\\") - len);
                            mavenHome = Utils.PathWinToLinux(mavenHome.Trim());
                            if (File.Exists(mavenHome + "conf/settings.xml"))
                            {
                                stb_maven_xml.Text = mavenHome + "conf/settings.xml";
                            }
                            else
                            {
                                errorLabel.Text = mavenHome + "conf/settings.xml 未找到,请手动指定";
                            }
                        }
                    }
                }
                catch (Exception ex) {
                    Console.WriteLine(ex.Message);
                }
            }
        }