Author: sisbell Date: Sat Feb 24 20:08:01 2007 New Revision: 511439 URL: http://svn.apache.org/viewvc?view=rev&rev=511439 Log: Copies of the assemblies from the plugins directory. Doing this to standardize the structure and naming of all .NET projects within NMaven.
Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/pom.xml (with props) incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/config/ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/config/resx.exe.config (with props) incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/csharp/ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/csharp/Plugin/ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/csharp/Plugin/Resx/ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/csharp/Plugin/Resx/MimeType.cs incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/csharp/Plugin/Resx/ResX.cs incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/nmaven-settings.xsd (with props) incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/pom.xml (with props) incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/ExecutionException.cs incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/SettingsGenerator.cs incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/nmavenSettings.cs Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/pom.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/pom.xml?view=auto&rev=511439 ============================================================================== --- incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/pom.xml (added) +++ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/pom.xml Sat Feb 24 20:08:01 2007 @@ -0,0 +1,42 @@ +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>NMaven.Plugin.ResX</groupId> + <artifactId>RexPlugin</artifactId> + <packaging>exe</packaging> + <version>0.14</version> + <name>NMaven.Plugin.ResX</name> + + <build> + <sourceDirectory>src/main/csharp</sourceDirectory> + <plugins> + <plugin> + <groupId>org.apache.maven.dotnet.plugins</groupId> + <artifactId>maven-compile-plugin</artifactId> + <extensions>true</extensions> + </plugin> + </plugins> + </build> + <profiles> + <profile> + <activation> + <property> + <name>version</name> + <value>1.1</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.dotnet.plugins</groupId> + <artifactId>maven-compile-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <frameworkVersion>1.1.4322</frameworkVersion> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> + +</project> \ No newline at end of file Propchange: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/config/resx.exe.config URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/config/resx.exe.config?view=auto&rev=511439 ============================================================================== --- incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/config/resx.exe.config (added) +++ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/config/resx.exe.config Sat Feb 24 20:08:01 2007 @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <appSettings> + <add key="abs" value="audio/x-mpeg"/> + <add key="ai" value="application/postscript"/> + <add key="aif" value="audio/x-aiff"/> + <add key="aifc" value="audio/x-aiff"/> + <add key="aiff" value="audio/x-aiff"/> + <add key="aim" value="application/x-aim"/> + <add key="art" value="image/x-jg"/> + <add key="asf" value="video/x-ms-asf"/> + <add key="asx" value="video/x-ms-asf "/> + <add key="au" value="audio/basic"/> + <add key="avi" value="video/x-msvideo"/> + <add key="avx" value="video/x-rad-screenplay"/> + <add key="bcpio" value="application/x-bcpio"/> + <add key="bin" value="application/octet-stream"/> + <add key="bmp" value="image/bmp"/> + <add key="body" value="text/html"/> + <add key="cdf" value="application/x-cdf"/> + <add key="cer" value="application/x-x509-ca-cert"/> + <add key="class" value="application/java"/> + <add key="cpio" value="application/x-cpio"/> + <add key="csh" value="application/x-csh"/> + <add key="css" value="text/css"/> + <add key="dib" value="image/bmp"/> + <add key="doc" value="application/msword"/> + <add key="dtd" value="text/plain"/> + <add key="dv" value="video/x-dv"/> + <add key="dvi" value="application/x-dvi"/> + <add key="eps" value="application/postscript"/> + <add key="etx" value="text/x-setext"/> + <add key="exe" value="application/octet-stream"/> + <add key="gif" value="image/gif"/> + <add key="gtar" value="application/x-gtar"/> + <add key="gz" value="application/x-gzip"/> + <add key="hdf" value="application/x-hdf"/> + <add key="htc" value="text/x-component"/> + <add key="htm" value="text/html"/> + <add key="html" value="text/html"/> + <add key="hqx" value="application/mac-binhex40"/> + <add key="ico" value="image/ico"/> + <add key="ief" value="image/ief"/> + <add key="jad" value="text/vnd.sun.j2me.app-descriptor"/> + <add key="jar" value="application/java-archive"/> + <add key="java" value="text/plain"/> + <add key="jnlp" value="application/x-java-jnlp-file"/> + <add key="jpe" value="image/jpeg"/> + <add key="jpeg" value="image/jpeg"/> + <add key="jpg" value="image/jpeg"/> + <add key="js" value="text/javascript"/> + <add key="jsf" value="text/plain"/> + <add key="jspf" value="text/plain"/> + <add key="kar" value="audio/midi"/> + <add key="latex" value="application/x-latex"/> + <add key="m3u" value="audio/x-mpegurl"/> + <add key="mac" value="image/x-macpaint"/> + <add key="man" value="application/x-troff-man"/> + <add key="me" value="application/x-troff-me"/> + <add key="mid" value="audio/midi"/> + <add key="midi" value="audio/midi"/> + <add key="mif" value="application/x-mif"/> + <add key="mms" value="application/vnd.wap.mms-message"/> + <add key="mov" value="video/quicktime"/> + <add key="movie" value="video/x-sgi-movie"/> + <add key="mp1" value="audio/x-mpeg"/> + <add key="mp2" value="audio/x-mpeg"/> + <add key="mp3" value="audio/x-mpeg"/> + <add key="mpa" value="audio/x-mpeg"/> + <add key="mpe" value="video/mpeg"/> + <add key="mpeg" value="video/mpeg"/> + <add key="mpega" value="audio/x-mpeg"/> + <add key="mpg" value="video/mpeg"/> + <add key="mpv2" value="video/mpeg2"/> + <add key="ms" value="application/x-wais-source"/> + <add key="nc" value="application/x-netcdf"/> + <add key="oda" value="application/oda"/> + <add key="par" value="application/x-jvending-par-archive"/> + <add key="pbm" value="image/x-portable-bitmap"/> + <add key="pct" value="image/pict"/> + <add key="pdf" value="application/pdf"/> + <add key="pgm" value="image/x-portable-graymap"/> + <add key="pic" value="image/pict"/> + <add key="pict" value="image/pict"/> + <add key="pls" value="audio/x-scpls"/> + <add key="png" value="image/png"/> + <add key="pnm" value="image/x-portable-anymap"/> + <add key="pnt" value="image/x-macpaint"/> + <add key="ppm" value="image/x-portable-pixmap"/> + <add key="ppt" value="application/powerpoint"/> + <add key="ps" value="application/postscript"/> + <add key="psd" value="image/x-photoshop"/> + <add key="qt" value="video/quicktime"/> + <add key="qti" value="image/x-quicktime"/> + <add key="qtif" value="image/x-quicktime"/> + <add key="ra" value="application/x-pn-realaudio"/> + <add key="ram" value="application/x-pn-realaudio"/> + <add key="ras" value="image/x-cmu-raster"/> + <add key="rgb" value="image/x-rgb"/> + <add key="rm" value="application/vnd.rn-realmedia"/> + <add key="roff" value="application/x-troff"/> + <add key="rtf" value="application/rtf"/> + <add key="rtx" value="text/richtext"/> + <add key="sh" value="application/x-sh"/> + <add key="shar" value="application/x-shar"/> + <add key="smf" value="audio/x-midi"/> + <add key="sit" value="application/x-stuffit"/> + <add key="snd" value="audio/basic"/> + <add key="src" value="application/x-wais-source"/> + <add key="sv4cpio" value="application/x-sv4cpio"/> + <add key="sv4crc" value="application/x-sv4crc"/> + <add key="swf" value="application/x-shockwave-flash"/> + <add key="t" value="application/x-troff"/> + <add key="tar" value="application/x-tar"/> + <add key="tcl" value="application/x-tcl"/> + <add key="tex" value="application/x-tex"/> + <add key="texi" value="application/x-texinfo"/> + <add key="texinfo" value="application/x-texinfo"/> + <add key="tif" value="image/tiff"/> + <add key="tiff" value="image/tiff"/> + <add key="torrent" value="application/x-bittorrent"/> + <add key="tr" value="application/x-troff"/> + <add key="tsv" value="text/tab-separated-values"/> + <add key="txt" value="text/plain"/> + <add key="ulw" value="audio/basic"/> + <add key="ustar" value="application/x-ustar"/> + <add key="wma" value="audio/x-ms-wma"/> + <add key="xbm" value="image/x-xbitmap"/> + <add key="xht" value="application/xhtml"/> + <add key="xhtml" value="application/xhtml"/> + <add key="xml" value="text/xml"/> + <add key="xpm" value="image/x-xpixmap"/> + <add key="x-properties" value="text/plain"/> + <add key="xsl" value="text/xml"/> + <add key="xwd" value="image/x-xwindowdump"/> + <add key="wav" value="audio/x-wav"/> + <add key="svg" value="image/svg"/> + <add key="svgz" value="image/svg"/> + <add key="vsd" value="application/x-visio"/> + <add key="wbmp" value="image/vnd.wap.wbmp"/> + <add key="wml" value="text/vnd.wap.wml"/> + <add key="wmlc" value="application/vnd.wap.wmlc"/> + <add key="wmls" value="text/vnd.wap.wmlscript"/> + <add key="wmlscriptc" value="application/vnd.wap.wmlscriptc"/> + <add key="wrl" value="x-world/x-vrml"/> + <add key="Z" value="application/x-compress"/> + <add key="z" value="application/x-compress"/> + <add key="zip" value="application/zip"/> + </appSettings> +</configuration> Propchange: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/config/resx.exe.config ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/csharp/Plugin/Resx/MimeType.cs URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/csharp/Plugin/Resx/MimeType.cs?view=auto&rev=511439 ============================================================================== --- incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/csharp/Plugin/Resx/MimeType.cs (added) +++ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/csharp/Plugin/Resx/MimeType.cs Sat Feb 24 20:08:01 2007 @@ -0,0 +1,66 @@ +// +// Copyright 2006 Shane Isbell +// +// Licensed 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. +// + +using System; + +namespace NMaven.Plugin.ResX +{ + /// <summary> + /// Provides mime-type information + /// </summary> + internal class MimeType + { + private string subType; + + private string type; + + private string extension; + + /// <summary> + /// Constructor + /// </summary> + /// <param name="type"></param> + /// <param name="subType"></param> + /// <param name="extension">the extension of a file with the mime-type</param> + + internal MimeType(string type, string subType, string extension) + { + this.type = type; + this.subType = subType; + this.extension = extension; + } + + internal string GetSubType() + { + return subType; + } + + internal string GetPrimaryType() + { + return type; + } + + internal string GetExtension() + { + return extension; + } + + public override string ToString() + { + return "SubType = " + subType + ", Type = " + type + ", Extension = " + extension; + } + } +} \ No newline at end of file Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/csharp/Plugin/Resx/ResX.cs URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/csharp/Plugin/Resx/ResX.cs?view=auto&rev=511439 ============================================================================== --- incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/csharp/Plugin/Resx/ResX.cs (added) +++ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Resx/src/main/csharp/Plugin/Resx/ResX.cs Sat Feb 24 20:08:01 2007 @@ -0,0 +1,173 @@ +// +// Copyright 2006 Shane Isbell +// +// Licensed 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. +// + +using System; +using System.Text; +using System.Resources; +using System.IO; +using System.Configuration; +using System.Drawing; + +namespace NMaven.Plugin.ResX +{ + /// <summary> + /// Utility for generating resource files + /// </summary> + class ResX + { + ///<summary> + /// Generates a resource file + ///</summary> + ///<param name = "sourceDirectory">directory containing resources (jpg, txt, wav)</param> + ///<param name = "outputFile">the generated .resources file</param> + ///<returns>void</returns> + public void Execute(string sourceDirectory, string outputFile) + { + AppSettingsReader appSettingsReader = new AppSettingsReader(); + if (!hasConfig(appSettingsReader)) throw new Exception("NMAVEN-9000-003: Could not find exe.config file."); + + ResXResourceWriter resourceWriter = new ResXResourceWriter(@outputFile); + + DirectoryInfo directoryInfo = + new DirectoryInfo(@sourceDirectory); + foreach (FileInfo fileInfo in directoryInfo.GetFiles()) + { + MimeType mimeType = GetMimeTypeFor(fileInfo.Name, appSettingsReader); + string extension = mimeType.GetExtension(); + if (extension.Equals("ico")) + resourceWriter.AddResource(fileInfo.Name, new Icon(@fileInfo.FullName)); + else if (extension.Equals("x-properties")) + { + StreamReader reader = new StreamReader(fileInfo.OpenRead(),Encoding.Default); + while(reader.Peek() >= 0) + { + string[] values = reader.ReadLine().Split('='); + if(values != null && values.Length == 2 && !values[0].StartsWith("#")) + resourceWriter.AddResource(values[0], values[1]); + } + reader.Close(); + } + else if (extension.Equals("db")) + continue;//Thumbnail + else if(extension.Equals("wav")) + { + MemoryStream memoryStream = FileInfoToMemoryStream(fileInfo); + resourceWriter.AddResource(fileInfo.Name, memoryStream); + memoryStream.Close(); + } + else if (mimeType.GetPrimaryType().Equals("image")) + resourceWriter.AddResource(fileInfo.Name, new Bitmap(@fileInfo.FullName)); + else if(mimeType.GetPrimaryType().Equals("text")) + resourceWriter.AddResource(fileInfo.Name, fileInfo.OpenText().ReadToEnd()); + else + { + MemoryStream memoryStream = FileInfoToMemoryStream(fileInfo); + resourceWriter.AddResource(fileInfo.Name, memoryStream.ToArray()); + memoryStream.Close(); + } + } + resourceWriter.Generate(); + resourceWriter.Close(); + } + + /// <summary> + /// Entry method + /// </summary> + /// <param name="args">array of arguments: 1) source directory of resources and 2) resource output file</param> + /// <returns>if successful, return 0, otherwise returns 1</returns> + public static int Main(string[] args) + { + Console.WriteLine("NMAVEN Resource Generator Utility "); + if (args.Length != 2) + { + StringBuilder stringBuilder = new StringBuilder(); + foreach (string arg in args) + stringBuilder.Append("Arg = ").Append(arg).Append(", "); + + Console.Error.WriteLine("NMAVEN-9000-000: Exiting program: Incorrect number of args (should have 2): Number Found = {0}, {1} ", + args.Length, stringBuilder.ToString()); + return 1; + } + + string sourceDirectory = args[0]; + string outputFile = args[1]; + + ResX resX = new ResX(); + try + { + resX.Execute(sourceDirectory, outputFile); + } + catch (Exception e) + { + Console.Error.WriteLine("NMAVEN-9000-002: Unable to generate resources: " + e.ToString()); + return 1; + } + return 0; + } + + /// <summary> + /// Returns mime-type information for the given file + /// </summary> + /// <param name="fileName">file name</param> + /// <param name="appSettingsReader">reader for the utility config</param> + /// <returns>mime-type information for the given file</returns> + private MimeType GetMimeTypeFor(String fileName, AppSettingsReader appSettingsReader) + { + string extension = new FileInfo(fileName).Extension.Substring(1); + string mimeType = null; + try + { + mimeType = (string)appSettingsReader.GetValue(extension, typeof(string)); + } + catch (InvalidOperationException e) + { + Console.WriteLine("NMAVEN-9000-001: Could not find the mime-type: Extension = {0} " + , extension); + return new MimeType("", "", extension); + } + return new MimeType(mimeType.Split('/')[0], mimeType.Split('/')[1], extension); + } + + /// <summary> + /// Converts file info to memory stream + /// </summary> + /// <param name="fileInfo">file info</param> + /// <returns>memory stream for the file</returns> + private MemoryStream FileInfoToMemoryStream(FileInfo fileInfo) + { + MemoryStream memoryStream = new MemoryStream(); + BinaryReader reader = new BinaryReader(fileInfo.Open(FileMode.Open), Encoding.Default); + byte[] buffer = new byte[1024]; + int n = 0; + while ((n = reader.Read(buffer, 0, 1024)) > 0) + memoryStream.Write(buffer, 0, n); + return memoryStream; + } + + private bool hasConfig(AppSettingsReader appSettingsReader) + { + try + { + string s = (string)appSettingsReader.GetValue("txt", typeof(string)); + return true; + } + catch (InvalidOperationException e) + { + return false; + } + } + } +} Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/nmaven-settings.xsd URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/nmaven-settings.xsd?view=auto&rev=511439 ============================================================================== --- incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/nmaven-settings.xsd (added) +++ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/nmaven-settings.xsd Sat Feb 24 20:08:01 2007 @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="utf-8"?> +<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xs:element name="nmavenSettings"> + <xs:complexType> + <xs:sequence> + <xs:element name="operatingSystem" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="architecture" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="defaultSetup" minOccurs="0" maxOccurs="1"> + <xs:complexType> + <xs:sequence> + <xs:element name="vendorName" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="vendorVersion" type="xs:string" minOccurs="0" maxOccurs="1" /> + <xs:element name="frameworkVersion" type="xs:string" minOccurs="0" maxOccurs="1" /> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="vendors" minOccurs="0" maxOccurs="1"> + <xs:complexType> + <xs:sequence> + <xs:element name="vendor" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="vendorName" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="vendorVersion" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="isDefault" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="frameworks" minOccurs="0" maxOccurs="1"> + <xs:complexType> + <xs:sequence> + <xs:element name="framework" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="frameworkVersion" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="installRoot" type="xs:string" minOccurs="0" maxOccurs="1"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"> + <xs:complexType> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element ref="nmavenSettings" /> + </xs:choice> + </xs:complexType> + </xs:element> +</xs:schema> \ No newline at end of file Propchange: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/nmaven-settings.xsd ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/pom.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/pom.xml?view=auto&rev=511439 ============================================================================== --- incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/pom.xml (added) +++ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/pom.xml Sat Feb 24 20:08:01 2007 @@ -0,0 +1,50 @@ +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>NMaven.Plugin.Settings</groupId> + <artifactId>SettingsPlugin</artifactId> + <packaging>exe</packaging> + <version>0.14</version> + <name>NMaven.Plugin.Settings</name> + <dependencies> + <dependency> + <groupId>org.nunit</groupId> + <artifactId>nunit.framework</artifactId> + <version>2.2.8.0</version> + <type>library</type> + </dependency> + </dependencies> + <build> + <sourceDirectory>src/main/csharp</sourceDirectory> + <testSourceDirectory>src/test/csharp</testSourceDirectory> + <plugins> + <plugin> + <groupId>org.apache.maven.dotnet.plugins</groupId> + <artifactId>maven-compile-plugin</artifactId> + <extensions>true</extensions> + </plugin> + </plugins> + </build> + <profiles> + <profile> + <activation> + <property> + <name>version</name> + <value>1.1</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.dotnet.plugins</groupId> + <artifactId>maven-compile-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <frameworkVersion>1.1.4322</frameworkVersion> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> + +</project> \ No newline at end of file Propchange: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/ExecutionException.cs URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/ExecutionException.cs?view=auto&rev=511439 ============================================================================== --- incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/ExecutionException.cs (added) +++ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/ExecutionException.cs Sat Feb 24 20:08:01 2007 @@ -0,0 +1,33 @@ +// +// Copyright 2006 Shane Isbell +// +// Licensed 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. +// + +using System; +using System.Runtime.Serialization; + +namespace NMaven.Plugin +{ + [Serializable] + public class ExecutionException : Exception + { + public ExecutionException() : base(){ } + + public ExecutionException(String message) : base(message) { } + + public ExecutionException(String message, Exception exception) : base(message, exception) { } + + public ExecutionException(SerializationInfo info, StreamingContext context) : base(info, context) { } + } +} Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/SettingsGenerator.cs URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/SettingsGenerator.cs?view=auto&rev=511439 ============================================================================== --- incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/SettingsGenerator.cs (added) +++ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/SettingsGenerator.cs Sat Feb 24 20:08:01 2007 @@ -0,0 +1,288 @@ +// +// Copyright 2006 Shane Isbell +// +// Licensed 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. +// + +using System; +using System.IO; +using System.Collections; +using System.Xml.Serialization; +using Microsoft.Win32; +using NMaven.Plugin; + +namespace NMaven.Plugin.Settings +{ + public class SettingsGenerator + { + protected internal SettingsGenerator() { } + + void Execute(string outputFile) + { + XmlSerializer serializer = new XmlSerializer(typeof(nmavenSettings)); + + nmavenSettings settings = new nmavenSettings(); + settings.operatingSystem = Environment.OSVersion.ToString(); + + RegistryKey monoRegistryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Novell\Mono"); + RegistryKey microsoftRegistryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\.NETFramework"); + + string defaultMonoCLR = (monoRegistryKey != null) ? (string) monoRegistryKey.GetValue("DefaultCLR") : null; + + settings.defaultSetup = GetDefaultSetup(defaultMonoCLR, + (string) microsoftRegistryKey.GetValue("InstallRoot")); + + nmavenSettingsVendor[] microsoftVendors = null; + try + { + microsoftVendors = GetVendorsForMicrosoft(microsoftRegistryKey); + } + catch(ExecutionException e) + { + Console.WriteLine(e.ToString()); + } + + nmavenSettingsVendor[] monoVendors = null; + try + { + monoVendors = GetVendorsForMono(monoRegistryKey, defaultMonoCLR); + } + catch(ExecutionException e) + { + Console.WriteLine(e.ToString()); + } + + nmavenSettingsVendor dotGnuVendor = null; + try + { + dotGnuVendor = GetVendorForGnu(Environment.GetEnvironmentVariable("CSCC_LIB_PATH")); + } + catch(ExecutionException e) + { + Console.WriteLine(e.ToString()); + } + int monoVendorsLength = (monoVendors == null) ? 0: monoVendors.Length; + int dotGnuVendorLength = (dotGnuVendor == null) ? 0: 1; + int microsoftVendorsLength = (microsoftVendors == null) ? 0: microsoftVendors.Length; + + nmavenSettingsVendor[] vendors = + new nmavenSettingsVendor[microsoftVendorsLength + monoVendorsLength + dotGnuVendorLength]; + + int copyLocation = 0; + if(microsoftVendors != null) + { + microsoftVendors.CopyTo(vendors, copyLocation); + copyLocation+=microsoftVendors.Length; + } + if(monoVendors != null) + { + monoVendors.CopyTo(vendors, copyLocation); + copyLocation+=monoVendors.Length; + } + if(dotGnuVendor != null) + vendors[copyLocation] = dotGnuVendor; + + settings.vendors = vendors; + + TextWriter writer = new StreamWriter(@outputFile); + serializer.Serialize(writer, settings); + writer.Close(); + } + + public static int Main(string[] args) + { + if(args == null || args.Length != 1) + { + Console.WriteLine("NMAVEN-000-000: Incorrect number of arguements:"); + return 1; + } + + try { + new SettingsGenerator().Execute(args[0]); + } + catch(DirectoryNotFoundException e) + { + Console.WriteLine("NMAVEN-000-000:" + e.ToString()); + return 1; + } + return 0; + } + + protected nmavenSettingsDefaultSetup GetDefaultSetup(string defaultMonoCLR, + string installRoot) + { + nmavenSettingsDefaultSetup defaultSetup = new nmavenSettingsDefaultSetup(); + if(installRoot == null) + { + defaultSetup.vendorName = "MONO"; + defaultSetup.vendorVersion = defaultMonoCLR; + return (defaultMonoCLR != null) ? defaultSetup : null; + } + bool dirInfo11 = new DirectoryInfo(Path.Combine(installRoot, "v1.1.4322")).Exists; + bool dirInfo20 = new DirectoryInfo(Path.Combine(installRoot, "v2.0.50727")).Exists; + + if(installRoot != null) + { + if(!dirInfo11 && !dirInfo20) + return null; + defaultSetup.vendorName = "MICROSOFT"; + defaultSetup.vendorVersion = (dirInfo20) ? "2.0.50727" : "1.1.4322"; + defaultSetup.frameworkVersion = defaultSetup.vendorVersion; + return defaultSetup; + } + else if(defaultMonoCLR != null) + { + defaultSetup.vendorName = "MONO"; + defaultSetup.vendorVersion = defaultMonoCLR; + defaultSetup.frameworkVersion = "2.0.50727"; + return defaultSetup; + } + return null; + } + + protected nmavenSettingsVendor GetVendorForGnu(String libPath) + { + if(libPath == null) + throw new ExecutionException("NMAVEN-9011-000: No CSCC_LIB_PATH Found"); + + if (libPath.EndsWith("lib" + Path.DirectorySeparatorChar + "cscc" + Path.DirectorySeparatorChar + "lib")) + { + string installR = new DirectoryInfo(libPath).Parent.Parent.Parent.FullName; + string[] tokenizedInstallRoot = installR.Split(Path.DirectorySeparatorChar); + string vendorVersion = tokenizedInstallRoot[tokenizedInstallRoot.Length - 1]; + if (!isValidVersion(vendorVersion)) + { + throw new ExecutionException("NMAVEN-9011-001: Invalid version format for dotGNU: Version = " + + vendorVersion + ", Root = " + installR); + } + + nmavenSettingsVendor vendor = new nmavenSettingsVendor(); + vendor.vendorName = "DotGNU"; + vendor.vendorVersion = vendorVersion; + nmavenSettingsVendorFramework[] vendorFrameworks = new nmavenSettingsVendorFramework[1]; + nmavenSettingsVendorFramework vf = new nmavenSettingsVendorFramework(); + vf.installRoot = Path.Combine(installR, "bin"); + vf.frameworkVersion = "2.0.50727";//doesn't matter + vendorFrameworks[0] = vf; ; + vendor.frameworks = vendorFrameworks; + return vendor; + } + throw new ExecutionException("NMAVEN-9011-002: CSCC_LIB_PATH found but could not determine vendor information"); + } + + private nmavenSettingsVendor[] GetVendorsForMicrosoft(RegistryKey microsoftRegistryKey) + { + if(microsoftRegistryKey == null) + throw new ExecutionException("NMAVEN-9011-006: Microsoft installation could not be found."); + string installRoot = (string) microsoftRegistryKey.GetValue("InstallRoot"); + if(installRoot == null) throw new ExecutionException("NMAVEN-9011-005"); + + nmavenSettingsVendor[] vendors = new nmavenSettingsVendor[3]; + DirectoryInfo dirInfo11 = new DirectoryInfo(Path.Combine(installRoot, "v1.1.4322")); + DirectoryInfo dirInfo20 = new DirectoryInfo(Path.Combine(installRoot, "v2.0.50727")); + DirectoryInfo dirInfo30 = new DirectoryInfo(Path.Combine(installRoot, "v3.0")); + int vendorCounter = 0; + if (dirInfo11.Exists) + { + nmavenSettingsVendor vendor = new nmavenSettingsVendor(); + vendor.vendorName = "MICROSOFT"; + vendor.vendorVersion = "1.1.4322"; + nmavenSettingsVendorFramework[] vendorFrameworks = new nmavenSettingsVendorFramework[1]; + nmavenSettingsVendorFramework vf11 = new nmavenSettingsVendorFramework(); + vf11.installRoot = dirInfo11.FullName; + vf11.frameworkVersion = "1.1.4322"; + vendorFrameworks[0] = vf11; + vendor.frameworks = vendorFrameworks; + vendors[vendorCounter++] = vendor; + } + if (dirInfo20.Exists) + { + nmavenSettingsVendor vendor = new nmavenSettingsVendor(); + vendor.vendorName = "MICROSOFT"; + vendor.vendorVersion = "2.0.50727"; + nmavenSettingsVendorFramework[] vendorFrameworks = new nmavenSettingsVendorFramework[1]; + nmavenSettingsVendorFramework vf11 = new nmavenSettingsVendorFramework(); + vf11.installRoot = dirInfo20.FullName; + vf11.frameworkVersion = "2.0.50727"; + vendorFrameworks[0] = vf11; + vendor.frameworks = vendorFrameworks; + vendors[vendorCounter++] = vendor; + } + if (dirInfo30.Exists) + { + nmavenSettingsVendor vendor = new nmavenSettingsVendor(); + vendor.vendorName = "MICROSOFT"; + vendor.vendorVersion = "3.0"; + nmavenSettingsVendorFramework[] vendorFrameworks = new nmavenSettingsVendorFramework[1]; + nmavenSettingsVendorFramework vf11 = new nmavenSettingsVendorFramework(); + vf11.installRoot = dirInfo30.FullName; + vf11.frameworkVersion = "3.0"; + vendorFrameworks[0] = vf11; + vendor.frameworks = vendorFrameworks; + vendors[vendorCounter++] = vendor; + } + + return vendors; + } + + private nmavenSettingsVendor[] GetVendorsForMono(RegistryKey monoRegistryKey, string defaultMonoCLR) + { + if(monoRegistryKey == null) + throw new ExecutionException("NMAVEN-9011-007: Mono installation could not be found."); + nmavenSettingsVendor[] vendors = new nmavenSettingsVendor[monoRegistryKey.SubKeyCount]; + int i = 0; + foreach (string keyName in monoRegistryKey.GetSubKeyNames()) + { + string sdkInstallRoot = (string) monoRegistryKey.OpenSubKey(keyName).GetValue("SdkInstallRoot"); + if(sdkInstallRoot == null) + throw new ExecutionException("NMAVEN-9011-004: Could not find install root key for mono"); + string installRoot = Path.Combine(sdkInstallRoot, "bin"); + nmavenSettingsVendorFramework[] vendorFrameworks = new nmavenSettingsVendorFramework[2]; + nmavenSettingsVendorFramework vf11 = new nmavenSettingsVendorFramework(); + vf11.installRoot = installRoot; + vf11.frameworkVersion = "1.1.4322"; + vendorFrameworks[0] = vf11; + + nmavenSettingsVendorFramework vf20 = new nmavenSettingsVendorFramework(); + vf20.installRoot = installRoot; + vf20.frameworkVersion = "2.0.50727"; + vendorFrameworks[1] = vf20; + + nmavenSettingsVendor vendor = new nmavenSettingsVendor(); + vendor.vendorName = "MONO"; + vendor.vendorVersion = keyName; + vendor.frameworks = vendorFrameworks; + if(defaultMonoCLR.Equals(keyName)) vendor.isDefault = "true"; + vendors[i++] = vendor; + } + return vendors; + } + + private bool isValidVersion(String version) + { + string[] vendorVersionToken = version.Split('.'); + foreach (string token in vendorVersionToken) + { + try + { + Single.Parse(token); + } + catch(Exception) + { + return false; + } + } + return true; + } + } +} Added: incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/nmavenSettings.cs URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/nmavenSettings.cs?view=auto&rev=511439 ============================================================================== --- incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/nmavenSettings.cs (added) +++ incubator/nmaven/branches/SI_IDE/assemblies/NMaven.Plugin.Settings/src/main/csharp/Plugin/Settings/nmavenSettings.cs Sat Feb 24 20:08:01 2007 @@ -0,0 +1,95 @@ +//------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Runtime Version: 1.1.4322.573 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +//------------------------------------------------------------------------------ + +// +// This source code was auto-generated by xsd, Version=1.1.4322.573. +// +using System.Xml.Serialization; + + +/// <remarks/> +[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] +public class nmavenSettings { + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string operatingSystem; + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string architecture; + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public nmavenSettingsDefaultSetup defaultSetup; + + /// <remarks/> + [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlArrayItemAttribute("vendor", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)] + public nmavenSettingsVendor[] vendors; +} + +/// <remarks/> +public class nmavenSettingsDefaultSetup { + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string vendorName; + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string vendorVersion; + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string frameworkVersion; +} + +/// <remarks/> +public class nmavenSettingsVendorFramework { + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string frameworkVersion; + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string installRoot; +} + +/// <remarks/> +public class nmavenSettingsVendor { + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string vendorName; + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string vendorVersion; + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string isDefault; + + /// <remarks/> + [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlArrayItemAttribute("framework", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)] + public nmavenSettingsVendorFramework[] frameworks; +} + +/// <remarks/> +[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] +public class NewDataSet { + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute("nmavenSettings")] + public nmavenSettings[] Items; +}