incubator-nmaven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r676802 - in /incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin: ChangeMavenSettingsXmlForm.Designer.cs ChangeMavenSettingsXmlForm.cs ChangeMavenSettingsXmlForm.resx Connect.cs
Date Tue, 15 Jul 2008 05:36:31 GMT
Author: brett
Date: Mon Jul 14 22:36:30 2008
New Revision: 676802

URL: http://svn.apache.org/viewvc?rev=676802&view=rev
Log:
[NMAVEN-106] [NMAVEN-170] Use a forked execution of Maven instead of the service embedder
which had previously been removed. Additionally make the location of the settings file configurable
from the user interface.
Submitted by: Leopoldo Agdeppa III, Jan Ancajas

Added:
    incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.Designer.cs
    incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.cs
    incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.resx
Modified:
    incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/Connect.cs

Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.Designer.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.Designer.cs?rev=676802&view=auto
==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.Designer.cs
(added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.Designer.cs
Mon Jul 14 22:36:30 2008
@@ -0,0 +1,134 @@
+#region Apache License, Version 2.0
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+#endregion
+
+namespace NMaven.VisualStudio.Addin
+{
+    partial class ChangeMavenSettingsXmlForm
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise,
false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.btnOk = new System.Windows.Forms.Button();
+            this.btnCancel = new System.Windows.Forms.Button();
+            this.txtBrowseSettingsXmlFile = new System.Windows.Forms.TextBox();
+            this.lblBrowseSettingsXmlFile = new System.Windows.Forms.Label();
+            this.btnBrowse = new System.Windows.Forms.Button();
+            this.SuspendLayout();
+            // 
+            // btnOk
+            // 
+            this.btnOk.Location = new System.Drawing.Point(478, 46);
+            this.btnOk.Name = "btnOk";
+            this.btnOk.Size = new System.Drawing.Size(90, 25);
+            this.btnOk.TabIndex = 0;
+            this.btnOk.Text = "&OK";
+            this.btnOk.UseVisualStyleBackColor = true;
+            this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
+            // 
+            // btnCancel
+            // 
+            this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+            this.btnCancel.Location = new System.Drawing.Point(574, 46);
+            this.btnCancel.Name = "btnCancel";
+            this.btnCancel.Size = new System.Drawing.Size(85, 25);
+            this.btnCancel.TabIndex = 1;
+            this.btnCancel.Text = "&Cancel";
+            this.btnCancel.UseVisualStyleBackColor = true;
+            this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
+            // 
+            // txtBrowseSettingsXmlFile
+            // 
+            this.txtBrowseSettingsXmlFile.Location = new System.Drawing.Point(131, 12);
+            this.txtBrowseSettingsXmlFile.Name = "txtBrowseSettingsXmlFile";
+            this.txtBrowseSettingsXmlFile.Size = new System.Drawing.Size(415, 22);
+            this.txtBrowseSettingsXmlFile.TabIndex = 2;
+            // 
+            // lblBrowseSettingsXmlFile
+            // 
+            this.lblBrowseSettingsXmlFile.AutoSize = true;
+            this.lblBrowseSettingsXmlFile.Location = new System.Drawing.Point(12, 12);
+            this.lblBrowseSettingsXmlFile.Name = "lblBrowseSettingsXmlFile";
+            this.lblBrowseSettingsXmlFile.Size = new System.Drawing.Size(113, 17);
+            this.lblBrowseSettingsXmlFile.TabIndex = 3;
+            this.lblBrowseSettingsXmlFile.Text = "Settings.xml File:";
+            // 
+            // btnBrowse
+            // 
+            this.btnBrowse.Location = new System.Drawing.Point(552, 9);
+            this.btnBrowse.Name = "btnBrowse";
+            this.btnBrowse.Size = new System.Drawing.Size(107, 28);
+            this.btnBrowse.TabIndex = 4;
+            this.btnBrowse.Text = "&Browse";
+            this.btnBrowse.UseVisualStyleBackColor = true;
+            this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click);
+            // 
+            // ChangeMavenSettingsXmlForm
+            // 
+            this.AcceptButton = this.btnOk;
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.CancelButton = this.btnCancel;
+            this.ClientSize = new System.Drawing.Size(671, 81);
+            this.ControlBox = false;
+            this.Controls.Add(this.btnBrowse);
+            this.Controls.Add(this.lblBrowseSettingsXmlFile);
+            this.Controls.Add(this.txtBrowseSettingsXmlFile);
+            this.Controls.Add(this.btnCancel);
+            this.Controls.Add(this.btnOk);
+            this.Name = "ChangeMavenSettingsXmlForm";
+            this.Text = "Change Maven settings.xml";
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Button btnOk;
+        private System.Windows.Forms.Button btnCancel;
+        private System.Windows.Forms.TextBox txtBrowseSettingsXmlFile;
+        private System.Windows.Forms.Label lblBrowseSettingsXmlFile;
+        private System.Windows.Forms.Button btnBrowse;
+    }
+}
\ No newline at end of file

Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.cs?rev=676802&view=auto
==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.cs
(added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.cs
Mon Jul 14 22:36:30 2008
@@ -0,0 +1,153 @@
+#region Apache License, Version 2.0
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace NMaven.VisualStudio.Addin
+{
+    
+    public partial class ChangeMavenSettingsXmlForm : Form 
+    {
+        private static string settingsXmlFile;
+        public static string SettingsXmlFile
+        {
+            get { return settingsXmlFile; }
+            set { settingsXmlFile = value; }
+        }
+
+        public ChangeMavenSettingsXmlForm()
+        {
+            InitializeComponent();
+
+            if (settingsXmlFile != null)
+            {
+                txtBrowseSettingsXmlFile.Text = settingsXmlFile;
+            }
+            
+        }
+
+
+
+        private void btnOk_Click(object sender, EventArgs e)
+        {
+            
+            // assign to the textbox value
+            if (System.IO.File.Exists(txtBrowseSettingsXmlFile.Text))
+            {
+                settingsXmlFile = txtBrowseSettingsXmlFile.Text;
+                this.DialogResult = DialogResult.OK;
+                this.Close();
+            }
+            else if ("".Equals(txtBrowseSettingsXmlFile.Text))
+            {
+                DialogResult res = MessageBox.Show(
+                    @"Your Settings File is set to empty, Do you want to use the default
settings.xml used by maven?",
+                    @"Maven Settings File set to Empty:",
+                    MessageBoxButtons.YesNo,
+                    MessageBoxIcon.Question);
+
+                if(res == DialogResult.Yes)
+                {
+                    settingsXmlFile = "";
+                    this.DialogResult = DialogResult.OK;
+                    this.Close();
+                }            }
+            else
+            {
+                string str = "Settings File: "
+                    + txtBrowseSettingsXmlFile.Text
+                    + "does not exists!!!";
+
+                MessageBox.Show(str,
+                    "Settings File Not Found:",
+                    MessageBoxButtons.OK,
+                    MessageBoxIcon.Error);
+
+            }
+
+            
+        }
+
+        private void btnCancel_Click(object sender, EventArgs e)
+        {
+            this.DialogResult = DialogResult.Cancel;
+            this.Close();
+        }
+
+        private void btnBrowse_Click(object sender, EventArgs e)
+        {
+            OpenFileDialog ofd = new OpenFileDialog();
+
+            if (!"".Equals(System.IO.File.Exists(txtBrowseSettingsXmlFile.Text)) &&
System.IO.File.Exists(txtBrowseSettingsXmlFile.Text))
+            {
+                ofd.FileName = txtBrowseSettingsXmlFile.Text;
+            }
+            else
+            {
+                txtBrowseSettingsXmlFile.Text = "";
+                ofd.InitialDirectory = getInitialDirectory();
+            }
+
+            ofd.Filter = "settings.xml file (settings.xml)|settings.xml|xml files (*.xml)|*.xml|All
files (*.*)|*.*";
+            ofd.FilterIndex = 1;
+            ofd.CheckFileExists = true;
+            ofd.RestoreDirectory = true;
+
+            if (ofd.ShowDialog() == DialogResult.OK)
+            {
+                txtBrowseSettingsXmlFile.Text = ofd.FileName;
+            }
+        }
+
+        private string getInitialDirectory()
+        {
+
+            string userProfile = System.Environment.GetEnvironmentVariable("UserProfile");
+            string userProfileM2 = userProfile + @"\.m2";
+
+            string m2Home = System.Environment.GetEnvironmentVariable("M2_HOME");
+            string m2HomeConf = m2Home + @"\conf";
+
+
+            if (System.IO.Directory.Exists(userProfileM2))
+            {
+                return userProfileM2;
+            }
+            else if (System.IO.Directory.Exists(m2HomeConf))
+            {
+                return m2HomeConf;
+            }
+            else
+            {
+                return @"c:\";
+            }
+
+        }
+
+
+    }
+}
\ No newline at end of file

Added: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.resx
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.resx?rev=676802&view=auto
==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.resx
(added)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/ChangeMavenSettingsXmlForm.resx
Mon Jul 14 22:36:30 2008
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms,
...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms,
...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this
is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET
Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"
/>
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2"
/>
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1"
/>
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"
/>
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>
\ No newline at end of file

Modified: incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/Connect.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/Connect.cs?rev=676802&r1=676801&r2=676802&view=diff
==============================================================================
--- incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/Connect.cs
(original)
+++ incubator/nmaven/branches/NMAVEN_0.14/assemblies/NMaven.VisualStudio.Addin/src/main/csharp/NMaven/VisualStudio/Addin/Connect.cs
Mon Jul 14 22:36:30 2008
@@ -56,11 +56,47 @@
 
 using NMaven.Model.Setting;
 using NMaven.Model.Pom;
+//using NMaven.VisualStudio.Addin.NMaven.VisualStudio.Addin;
  
 #endregion
   
   namespace NMaven.VisualStudio.Addin
   {
+      public class NMavenBuildSystemProperties : System.ComponentModel.ISynchronizeInvoke
+      {
+          private object application;
+
+          public object Application
+          {
+              get { return application; }
+              set { application = value; }
+          }
+
+          #region ISynchronizeInvoke Members
+
+          public IAsyncResult BeginInvoke(Delegate method, object[] args)
+          {
+              throw new Exception("The method or operation is not implemented.");
+          }
+
+          public object EndInvoke(IAsyncResult result)
+          {
+              throw new Exception("The method or operation is not implemented.");
+          }
+
+          public object Invoke(Delegate method, object[] args)
+          {
+              throw new Exception("The method or operation is not implemented.");
+          }
+
+          public bool InvokeRequired
+          {
+              get { return false; }
+          }
+
+          #endregion
+      }
+
     #region Connect
      /// <summary>The object for implementing an Add-in.</summary>
      /// <seealso class='IDTExtensibility2' />
@@ -169,25 +205,15 @@
  </configuration>";
   
                 container = new WindsorContainer(new XmlInterpreter(new Castle.Core.Resource.StaticContentResource(contents)));
-                ArtifactContext artifactContext = (ArtifactContext)container[typeof(ArtifactContext)];
-                object[] attributes = Assembly.GetExecutingAssembly()
-                    .GetCustomAttributes(typeof(System.Reflection.AssemblyInformationalVersionAttribute),
true);
-                String version = ((AssemblyInformationalVersionAttribute) attributes[0]).InformationalVersion;
-
-                NMaven.Artifact.Artifact artifactWar = artifactContext.CreateArtifact("org.apache.maven.dotnet",
-                    "dotnet-service-embedder", version, "war");
-                FileInfo warFileInfo = new FileInfo(localRepository + "/" + new JavaRepositoryLayout().pathOf(artifactWar)
+ "war");
-                logger.Log(Level.INFO, "Executing external command plugin: "
-                    + @"mvn org.apache.maven.dotnet.plugins:maven-embedder-plugin:start -Dport=8080
-DwarFile="""
-                    + warFileInfo.FullName + @"""");
-
-                ProcessStartInfo processStartInfo =
-                    new ProcessStartInfo("mvn", @"org.apache.maven.dotnet.plugins:maven-embedder-plugin:start
-Dport=8080 -DwarFile="""
-                     + warFileInfo.FullName + @"""");
-                processStartInfo.UseShellExecute = true;
-                processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
-                System.Diagnostics.Process.Start(processStartInfo);
+               
+                launchNMavenBuildSystem(application);
+            }
+        }
 
+        
+
+         private void launchNMavenBuildSystem(object application)
+         {
                 EnvDTE80.Windows2 windows2 = (EnvDTE80.Windows2)_applicationObject.Windows;
                 _applicationObject = (DTE2)application;
 
@@ -226,22 +252,35 @@
                             ctl1.Caption = "Configure Maven Repository...";
                             ctl1.Visible = true;
                             addReferenceControls.Add(ctl1);
-                            
-                            CommandBarButton ctlProjectImport = (CommandBarButton)
-                            commandBar.Controls.Add(MsoControlType.msoControlButton,
-                                                      System.Type.Missing,
-                                                      System.Type.Missing,
-                                                      control.Index,
+
+                            CommandBarButton ctlSettingsXml = (CommandBarButton)
+                            commandBar.Controls.Add(MsoControlType.msoControlButton, 
+                                                      System.Type.Missing, 
+                                                      System.Type.Missing, 
+                                                      control.Index, 
                                                       true);
-                            ctlProjectImport.Click +=
-                                new _CommandBarButtonEvents_ClickEventHandler(cbChangeProjectImportForm_Click);
-                            ctlProjectImport.Caption = "NMaven: Import Project";
-                            ctlProjectImport.Visible = true;
-                            addReferenceControls.Add(ctlProjectImport);     
+                            ctlSettingsXml.Click += 
+                                new _CommandBarButtonEvents_ClickEventHandler(cbChangeSettingsXmlForm_Click);
+                            ctlSettingsXml.Caption = "Change Maven settings.xml...";
+                            ctlSettingsXml.Visible = true;
+                            addReferenceControls.Add(ctlSettingsXml);
+                            
                             
                         }
                         else if (control.Caption.Equals("Clea&n"))
                         {
+                            // Add the stop maven build button here
+
+                            CommandBarButton stopButton = (CommandBarButton)commandBar.Controls.Add(MsoControlType.msoControlButton,
+                                System.Type.Missing, System.Type.Missing, control.Index +
1, true);
+                            stopButton.Caption = "Stop Maven Build...";
+                            stopButton.Visible = true;
+                            stopButton.Click += new _CommandBarButtonEvents_ClickEventHandler(cbStopMavenBuild_Click);
+                            buildControls.Add(stopButton);
+
+
+
+
                             CommandBarPopup ctl = (CommandBarPopup)
                                 commandBar.Controls.Add(MsoControlType.msoControlPopup,
                                 System.Type.Missing, System.Type.Missing, control.Index +
1, true);
@@ -296,7 +335,9 @@
                     vsProject.Events.ReferencesEvents.ReferenceRemoved 
                         += new _dispReferencesEvents_ReferenceRemovedEventHandler(ReferencesEvents_ReferenceRemoved);
                 }
-            }
+
+
+                outputWindowPane.OutputString("\nNMaven Addin Successful Started...");
         }
         #endregion
 
@@ -305,8 +346,8 @@
              MessageBox.Show("Removing Reference");
              Project project = pReference.ContainingProject;
 
-             FileInfo solutionFile = new FileInfo(_applicationObject.Solution.FileName);
-             String pomFileName = solutionFile.DirectoryName + @"\pom.xml";
+             String pomFileName =
+                 (new FileInfo(project.FileName).Directory).FullName + @"\pom.xml";
 
              if (!new FileInfo(pomFileName).Exists)
              {
@@ -452,36 +493,201 @@
         #region executeBuildCommand(FileInfo,string)
         private void executeBuildCommand(FileInfo pomFile, String goal)
         {
-            MavenExecutionRequest request = new MavenExecutionRequest();
-            request.goal = goal;
-            request.pomFile = @pomFile.FullName;
-            request.loggerPort = 9099;
-            request.loggerPortSpecified = true;
+            // MVN Command
 
-            try
+            if (mvnRunner != null && mvnRunner.IsRunning)
             {
-                ideContext.Build(request);
+                DialogResult res = MessageBox.Show("A Maven Build is currently running, Do
you want to stop the build and proceed to a new Build Execution?", "Stop NMaven Build:", MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
+
+                // re-check if it is still running, before calling stop
+                if (mvnRunner != null && mvnRunner.IsRunning && res == DialogResult.Yes)
+                {
+                    mvnRunner.stop();
+                }
+                else
+                {
+                    // do not execute the request
+                    return;
+                }
+
             }
-            catch (SoapException e)
-            {
-                string message = string.Format(
-                    "NMaven: Soap Error in build: {0}, {1}, {2}",
-                    e.Code,
-                    e.SubCode,
-                    e.StackTrace);
 
-                ideContext.GetLogger().Log(Level.INFO, message);
+
+            if (ChangeMavenSettingsXmlForm.SettingsXmlFile != null)
+            {
+                mvnRunner = new MVNRunner(_applicationObject, pomFile.DirectoryName, goal);
             }
-            catch (Exception e)
+            else
             {
-                ideContext.GetLogger().Log(Level.INFO, "NMaven: Error in build: " + e.Message
+ ", Pom File = " + pomFile.FullName +
-                    "," + e.StackTrace);
+                mvnRunner = new MVNRunner(_applicationObject, 
+                    pomFile.DirectoryName, 
+                    goal, 
+                    ChangeMavenSettingsXmlForm.SettingsXmlFile);
             }
+
+            mvnRunner.execute();
+
+
+
         } 
         #endregion
 
-        #region getPomFile()
-        private FileInfo getPomFile()
+
+
+
+
+        #region MVNRunnerClass
+
+
+        private class MVNRunner
+         {
+             private string goal;
+             private string directory;
+             private OutputWindowPane output;
+             private string settingsXml;
+             private System.Diagnostics.Process proc;
+             private static int runner_number = 0;
+
+
+             public MVNRunner(DTE2 dte2, string directory, string goal)
+             {
+                 this.directory = directory;
+                 this.goal = goal;
+                 this.settingsXml = null;
+
+                 makeOutputWindow(dte2);
+                 
+             }
+
+
+             public MVNRunner(DTE2 dte2, string directory, string goal, string settingsXml)
+             {
+                 this.directory = directory;
+                 this.goal = goal;
+                 this.settingsXml = settingsXml;
+
+                 makeOutputWindow(dte2);
+
+             }
+
+             private void makeOutputWindow(DTE2 dte2)
+             {
+                 // _applicationObject is from the main class
+                 Window win = dte2.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
+                 OutputWindow outputWindow = (OutputWindow)win.Object;
+                 output = outputWindow.OutputWindowPanes.Add(string.Format("[{0}] NMaven
Execute", ++runner_number));
+             }
+
+             public void execute()
+             {
+                 System.Threading.ThreadStart threadDelegate = new System.Threading.ThreadStart(this.doRunMvn);
+                 System.Threading.Thread t = new System.Threading.Thread(threadDelegate);
+                 t.Start();
+             }
+
+             private void doRunMvn()
+             {
+                 output.Activate();
+
+                 string args;
+
+                 if (settingsXml != null && !settingsXml.Equals(""))
+                 {
+                     args = string.Format("{0} -s\"{1}\"", goal, ChangeMavenSettingsXmlForm.SettingsXmlFile);
+                 }
+                 else
+                 {
+                     args = goal;
+                 }
+
+
+                 proc = new System.Diagnostics.Process();
+
+
+                 string mvn_file = string.Format("{0}\\bin\\mvn.bat", System.Environment.GetEnvironmentVariable("M2_HOME"));
+
+                 output.OutputString(string.Format("\nNExecuting Maven Command: {0} {1}\n\n",
mvn_file, args ));
+
+                 
+                 System.Diagnostics.ProcessStartInfo procInfo = new System.Diagnostics.ProcessStartInfo(mvn_file);
+                 procInfo.Arguments = args;
+                 procInfo.WorkingDirectory = this.directory;
+
+                 procInfo.RedirectStandardOutput = true;
+                 procInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
+                 procInfo.CreateNoWindow = true;
+                 procInfo.UseShellExecute = false;
+
+                 proc.StartInfo = procInfo;
+
+                 proc.EnableRaisingEvents = true;
+                 proc.Exited += new EventHandler(mvn_process_exited);
+                 
+
+
+                 proc.Start();
+                 System.IO.StreamReader mvnOutput = proc.StandardOutput;
+
+
+                 while (!proc.HasExited)
+                 {
+                     if (mvnOutput.Peek() != 0)
+                     {
+                         output.OutputString("\n" + mvnOutput.ReadLine());
+                     }
+                 }
+             }
+
+             
+             public bool IsRunning
+             {
+                 get
+                 {
+                     if (proc == null)
+                         return false;
+
+                     return !proc.HasExited;
+                 }
+             }
+
+             public void stop()
+             {
+                 output.OutputString("\nStopping Maven Execution....");
+                 if (IsRunning)
+                 {
+                     proc.Kill();
+                 }
+                 output.OutputString("\nMaven Execution Successfully Stoped!!!");
+             }
+
+             private void mvn_process_exited(object sender, System.EventArgs e)
+             {
+                 System.Diagnostics.Process process = (System.Diagnostics.Process)sender;
+                 
+                 int exitCode = process.ExitCode;
+                 if (exitCode == 0)
+                 {
+                    output.OutputString("\nNMaven Execution is Successful!!!");
+                 }
+                 else if (exitCode == -1)
+                 {
+                    output.OutputString("\nNMaven Execution Failed!!!");
+                 }
+                 else
+                 {
+                    output.OutputString("\nNMaven Execution Failed!!!, with exit code: "
+ exitCode);
+                 }
+             }
+
+
+         }
+
+        #endregion
+
+
+
+         #region getPomFile()
+         private FileInfo getPomFile()
         {
             FileInfo projectFileInfo = null;
             //TODO: Fix to handle multiple projects: NMAVEN-80
@@ -545,10 +751,28 @@
          private void cbShowConfigureRepositoryForm_Click(CommandBarButton btn, ref bool
Cancel)
          {
             new ConfigureMavenRepositoryForm().Show();
+        }
+
+
+        #region cbStopMavenBuild_Click(CommandBarButton,bool)
+        private void cbStopMavenBuild_Click(CommandBarButton btn, ref bool Cancel)
+         {
+             if (mvnRunner != null && mvnRunner.IsRunning)
+             {
+                 DialogResult res = MessageBox.Show("Do you want to stop the Maven Build?",
"Stop NMaven Build:", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+
+                 // re-check if it is still running, before calling stop
+                 if (mvnRunner != null && mvnRunner.IsRunning && res == DialogResult.Yes)
+                 {
+                     mvnRunner.stop();
+                 }
+             }
          }
+        #endregion
 
-        #region cbShowAddArtifactsForm_Click(CommandBarButton,bool)
-        private void cbShowAddArtifactsForm_Click(CommandBarButton btn, ref bool Cancel)
+
+         #region cbShowAddArtifactsForm_Click(CommandBarButton,bool)
+         private void cbShowAddArtifactsForm_Click(CommandBarButton btn, ref bool Cancel)
         {
             //First selected project
             foreach (Project project in (Array)_applicationObject.ActiveSolutionProjects)
@@ -560,25 +784,15 @@
         } 
         #endregion
         
-        #region cbChangeProjectImportForm_Click(CommandBarButton, bool)
-         private void cbChangeProjectImportForm_Click(CommandBarButton btn, ref bool Cancel)
+        
+        #region cbChangeSettingsXmlForm_Click(CommandBarButton, bool)
+        private void cbChangeSettingsXmlForm_Click(CommandBarButton btn, ref bool Cancel)
         {
-            NMavenImportProjectForm frm = new NMavenImportProjectForm(_applicationObject);
+            ChangeMavenSettingsXmlForm frm = new ChangeMavenSettingsXmlForm();
             frm.ShowDialog();
         }
         #endregion
-
-        #region OnBeginShutdown(Array)
-        /// <summary>Implements the OnBeginShutdown method of the IDTExtensibility2
interface. Receives notification that the host application is being unloaded.</summary>
-        /// <param term='custom'>Array of parameters that are host application specific.</param>
-        /// <seealso class='IDTExtensibility2' />
-        public void OnBeginShutdown(ref Array custom)
-        {
-            WebClient webClient = new WebClient();
-            webClient.DownloadData("http://localhost:8080?shutdown=true");
-        } 
-        #endregion
-
+        
         #region QueryStatus(string,vsCommandStatusTextWanted,vsCommandStatus,commandText)
         /// <summary>
         /// Implements the QueryStatus method of the IDTCommandTarget interface. 
@@ -637,7 +851,8 @@
         private IWindsorContainer container;
          private List<ReferencesEvents> referenceEvents;
         //private DirectoryInfo baseDirectoryInfo; 
+         private MVNRunner mvnRunner;
         #endregion
     }
     #endregion
-}
\ No newline at end of file
+}



Mime
View raw message