You are viewing a plain text version of this content. The canonical link for it is here.
Posted to npanday-dev@incubator.apache.org by Brett Porter <br...@apache.org> on 2010/10/27 01:05:48 UTC

Re: svn commit: r1025511 - in /incubator/npanday/trunk: ./ components/dotnet-core/src/main/java/npanday/ components/dotnet-core/src/main/resources/META-INF/npanday/ components/dotnet-dao-project/src/main/java/npanday/dao/impl/ components/dotnet-executable/...

Hi,

Sorry again for the late review :)

On 20/10/2010, at 10:37 PM, apadilla@apache.org wrote:

> 
> Modified: incubator/npanday/trunk/components/dotnet-dao-project/src/main/java/npanday/dao/impl/ProjectDaoImpl.java
> URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-dao-project/src/main/java/npanday/dao/impl/ProjectDaoImpl.java?rev=1025511&r1=1025510&r2=1025511&view=diff
> ==============================================================================
> --- incubator/npanday/trunk/components/dotnet-dao-project/src/main/java/npanday/dao/impl/ProjectDaoImpl.java (original)
> +++ incubator/npanday/trunk/components/dotnet-dao-project/src/main/java/npanday/dao/impl/ProjectDaoImpl.java Wed Oct 20 11:37:11 2010
> @@ -586,22 +586,20 @@ public final class ProjectDaoImpl
>                 // project
>                 // now we need to generate the system path of the gac references so we can use
>                 // System.getenv("SystemRoot")
> +                //we have already set file for the assembly above (in createArtifactFrom) so we do not need re-resovle it
>                 if ( !projectDependency.isResolved() )
>                 {
>                     if ( ArtifactTypeHelper.isDotnetAnyGac( projectDependency.getArtifactType() ) )
>                     {
>                         try
>                         {
> -                            projectDependency.setResolved( true );
> -                            if ( projectDependency.getSystemPath() == null )
> +                            if (assembly.getFile().exists())
>                             {
> -                                projectDependency.setSystemPath( generateDependencySystemPath( projectDependency ) );
> +                                projectDependency.setSystemPath( assembly.getFile().getAbsolutePath());
> +                                projectDependency.setResolved( true );
> +                                assembly.setResolved( true );
>                             }
> -                            File f = new File( projectDependency.getSystemPath() );
> -                            assembly.setFile( f );
> -                            assembly.setResolved( true );
>                             artifactDependencies.add( assembly );
> -
>                         }
>                         catch ( ExceptionInInitializerError e )
>                         {

Are you sure this change is needed? It might be correct, but I can't see why it would be specific to .NET 4.0 support, and this is quite fragile code :) It might be best to make it a separately documented issue if it was to fix something else.

> @@ -1295,20 +1293,24 @@ public final class ProjectDaoImpl
>                                                                       VersionRange.createFromVersion( version ),
>                                                                       artifactType, publicKeyTokenId, scope,
>                                                                       null );
> -        // TODO: Use PathUtil!
> -        File artifactFile = ArtifactTypeHelper.isDotnetAnyGac( artifactType ) ? new File(
> -            "C:\\WINDOWS\\assembly\\" + artifactType + File.separator + artifactId + File.separator + version + "__" +
> -                publicKeyTokenId + File.separator + artifactId + ".dll" ) : new File( System.getProperty( "user.home" ),
> -                                                                                      File.separator + ".m2" +
> -                                                                                          File.separator + "uac" +
> -                                                                                          File.separator + "gac_msil" +
> -                                                                                          File.separator + artifactId +
> -                                                                                          File.separator + version +
> -                                                                                          "__" + groupId +
> -                                                                                          File.separator + artifactId +
> -                                                                                          "." +
> -                                                                                          ArtifactType.getArtifactTypeForPackagingName(
> -                                                                                              artifactType ).getExtension() );
> +        //using PathUtil
> +        File artifactFile = null;
> +        if (ArtifactTypeHelper.isDotnetAnyGac( artifactType ))
> +        {
> +            if (!ArtifactTypeHelper.isDotnet4Gac(artifactType))
> +            {
> +                artifactFile = PathUtil.getGlobalAssemblyCacheFileFor( assembly, new File("C:\\WINDOWS\\assembly\\") );
> +            }
> +            else
> +            {
> +                artifactFile = PathUtil.getGACFile4Artifact(assembly);
> +            }

could this be handled inside the getG..A..C...FileFor method?

> +        }
> +        else
> +        {
> +            artifactFile = PathUtil.getUserAssemblyCacheFileFor( assembly, new File( System.getProperty( "user.home" ),
> +                                                                                      File.separator + ".m2" + File.separator + "repository") );

We shouldn't hardcode the system properties / local repository - can it be passed in? (the comments on Joe's changes might make it redundant).

> 
> Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java
> URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java?rev=1025511&r1=1025510&r2=1025511&view=diff
> ==============================================================================
> --- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java (original)
> +++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java Wed Oct 20 11:37:11 2010
> 
> @@ -635,7 +647,7 @@ public final class CompilerContextImpl
>         logger.debug( "NPANDAY-061-001: Gac Root:" + gacRoot);
>         logger.debug( "NPANDAY-061-003: Artifact Type:" + type);
>         File gacFile;
> -        if ("gac_msil4".equalsIgnoreCase(type)) {
> +        if ("gac_msil4".equalsIgnoreCase(type) || "gac_32_4".equalsIgnoreCase(type) || "gac_64_4".equalsIgnoreCase(type)) {
>             gacFile = new File( gacRoot, artifact.getArtifactId() + File.separator + "v" + compilerRequirement.getFrameworkVersion() + "_" + artifact.getVersion() + "__" +
>                 artifact.getClassifier() + File.separator + artifact.getArtifactId() + ".dll" );
>         }

Should these be using the ArtifactType utilitiy as well?

> 
> Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/src/main/csharp/NPanday/Plugin/MojoGenerator/Generator.cs
> URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/src/main/csharp/NPanday/Plugin/MojoGenerator/Generator.cs?rev=1025511&r1=1025510&r2=1025511&view=diff
> ==============================================================================
> --- incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/src/main/csharp/NPanday/Plugin/MojoGenerator/Generator.cs (original)
> +++ incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/src/main/csharp/NPanday/Plugin/MojoGenerator/Generator.cs Wed Oct 20 11:37:11 2010
> @@ -100,11 +100,9 @@ namespace NPanday.Plugin.MojoGenerator
> 				jcuLocal.unmarshall(javaClass, fileInfo);
> 			}
> 			
> -			ResourceManager resourceManager = new ResourceManager("NPanday.Plugin.MojoGenerator", 
> -			                                                      Assembly.GetExecutingAssembly());
> -			String pomXml = (String) resourceManager.GetObject("pom-java.xml");
> -			TextReader reader = new StringReader(pomXml);
> -		    XmlSerializer serializer = new XmlSerializer(typeof(NPanday.Model.Pom.Model));
> +            TextReader reader = new StreamReader(Assembly.GetExecutingAssembly().
> +            GetManifestResourceStream(Assembly.GetExecutingAssembly().GetManifestResourceNames()[0]));
> +			XmlSerializer serializer = new XmlSerializer(typeof(NPanday.Model.Pom.Model));
> 			NPanday.Model.Pom.Model model = (NPanday.Model.Pom.Model) serializer.Deserialize(reader);	
> 			model.artifactId = artifactId + ".JavaBinding";
> 			model.groupId = groupId;

I'm not sure I understand this change. Is it reading the POM as the first resource from an asembly?

> 
> Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Converter/Algorithms/AbstractPomConverter.cs
> URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Converter/Algorithms/AbstractPomConverter.cs?rev=1025511&r1=1025510&r2=1025511&view=diff
> ==============================================================================
> --- incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Converter/Algorithms/AbstractPomConverter.cs (original)
> +++ incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Converter/Algorithms/AbstractPomConverter.cs Wed Oct 20 11:37:11 2010
> @@ -518,7 +518,7 @@ namespace NPanday.ProjectImporter.Conver
> 
>             foreach (Plugin plugin in model.build.plugins)
>             {
> -                if (groupId.ToLower().Equals(plugin.groupId.ToLower()) && artifactId.ToLower().Equals(plugin.artifactId.ToLower()))
> +                if (groupId.ToLower().Equals(plugin.groupId.ToLower(), StringComparison.InvariantCultureIgnoreCase) && artifactId.ToLower().Equals(plugin.artifactId.ToLower(), StringComparison.InvariantCultureIgnoreCase))
>                 {
>                     if (!string.IsNullOrEmpty(version) && version.Equals(plugin.version))
>                     {
> @@ -730,7 +730,7 @@ namespace NPanday.ProjectImporter.Conver
> 
> 
>             // resolve from GAC
> -            if (!string.IsNullOrEmpty(gacUtil.GetAssemblyInfo(reference.Name)))
> +            if (!string.IsNullOrEmpty(gacUtil.GetAssemblyInfo(reference.Name, null, projectDigest.Platform)))
>             {
>                 // Assembly is found at the gac
> 
> @@ -740,21 +740,50 @@ namespace NPanday.ProjectImporter.Conver
> 
>                 if ("MSIL".Equals(reference.ProcessorArchitecture, StringComparison.OrdinalIgnoreCase))
>                 {
> -                    refDependency.type = "gac_msil";
> +                    if ("4.0.0.0".Equals(reference.Version))
> +                    {
> +                        refDependency.type = "gac_msil4";
> +                    }
> +                    else
> +                    {
> +                        refDependency.type = "gac_msil";

This might be best in a utility method, in case a future version needs to be introduced that behaves the same (eg. 4.5.0.0).

> Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Converter/Algorithms/WebWithVbOrCsProjectFilePomConverter.cs
> URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Converter/Algorithms/WebWithVbOrCsProjectFilePomConverter.cs?rev=1025511&r1=1025510&r2=1025511&view=diff
> ==============================================================================
> --- incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Converter/Algorithms/WebWithVbOrCsProjectFilePomConverter.cs (original)
> +++ incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Converter/Algorithms/WebWithVbOrCsProjectFilePomConverter.cs Wed Oct 20 11:37:11 2010
> @@ -52,6 +52,11 @@ namespace NPanday.ProjectImporter.Conver
>             // change the outputDirectory of the plugin
>             Plugin compilePlugin = FindPlugin("npanday.plugin", "maven-compile-plugin");
>             AddPluginConfiguration(compilePlugin, "outputDirectory", "bin");
> +
> +            // Add NPanday compile plugin 
> +            Plugin aspxPlugin = AddPlugin("npanday.plugin", "maven-aspx-plugin");
> +            if (!string.IsNullOrEmpty(projectDigest.TargetFramework))
> +                AddPluginConfiguration(aspxPlugin, "frameworkVersion", projectDigest.TargetFramework);

Should the plugin only be added if the configuration will be set?

> Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Digest/Algorithms/NormalProjectDigestAlgorithm.cs
> URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Digest/Algorithms/NormalProjectDigestAlgorithm.cs?rev=1025511&r1=1025510&r2=1025511&view=diff
> ==============================================================================
> --- incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Digest/Algorithms/NormalProjectDigestAlgorithm.cs (original)
> +++ incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Digest/Algorithms/NormalProjectDigestAlgorithm.cs Wed Oct 20 11:37:11 2010
> @@ -164,6 +164,18 @@ namespace NPanday.ProjectImporter.Digest
>                                 break;
>                             case "Reference":
>                                 Reference reference = new Reference(projectBasePath, gac);
> +                                //quick workaround for cases of importing .net 4.0 targeted projects, as their referneces has to be also for 
> +                                //.net framework 4.0 (that is their version in GAC is 4.0.0.0). Then we will use this 
> +                                if (projectDigest.TargetFramework == "4.0")
There's a couple of these checks - maybe need a utility method alo?

> Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Digest/Model/Reference.cs
> URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Digest/Model/Reference.cs?rev=1025511&r1=1025510&r2=1025511&view=diff
> ==============================================================================
> --- incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Digest/Model/Reference.cs (original)
> +++ incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Digest/Model/Reference.cs Wed Oct 20 11:37:11 2010
> @@ -17,7 +17,6 @@ namespace NPanday.ProjectImporter.Digest
> 
>     public class Reference : IncludeBase
>     {
> -
>         #region Constructors
> 
>         public Reference(string projectBasePath, GacUtility gac) 
> @@ -218,7 +217,9 @@ namespace NPanday.ProjectImporter.Digest
>                 // compare the assembly name to the filename of the reference to determine if it is a match
>                 // as the location might not be set
>                 // TODO: why do we need to load the assembly?
> -                if (asmm.GetName().Name.Equals(Path.GetFileNameWithoutExtension(path)))
> +                // added StringComparison.OrdinalIgnoreCase to assembly name compratison in order to avoid errors with 
> +                // already loaded assemblies like nunit.framework and NUnit.Framework etc (note this can be reconsidered)

Do you need to elaborate on this on a separate thread on this list, about whether they need to be reconsidered? I'm not sure what problem you were seeing.

> Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Digest/PomConverter.cs
> URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Digest/PomConverter.cs?rev=1025511&r1=1025510&r2=1025511&view=diff
> ==============================================================================
> --- incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Digest/PomConverter.cs (original)
> +++ incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/NPanday/ProjectImporter/Digest/PomConverter.cs Wed Oct 20 11:37:11 2010
> @@ -128,8 +128,8 @@ namespace NPanday.ProjectImporter.Conver
>                     scmTag = scmTag.Trim();
> 
>                     Scm scmHolder = new Scm();
> -                    scmHolder.connection = string.Format("scm:svn:{0}",scmTag);
> -                    scmHolder.developerConnection = string.Format("scm:svn:{0}", scmTag);
> +                    scmHolder.connection = string.Format("scm:svn:{0}",scmTag); 
> +                    scmHolder.developerConnection = string.Format("scm:svn:{0}", scmTag); //why forcibly Subversion? (scm:hg for example). Need to add more fields to configure.

This could perhaps be filed as an issue. At the moment I think the UI takes an SVN location only.

> Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/AddArtifactsForm.cs
> URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/AddArtifactsForm.cs?rev=1025511&r1=1025510&r2=1025511&view=diff
> ==============================================================================
> --- incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/AddArtifactsForm.cs (original)
> +++ incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/AddArtifactsForm.cs Wed Oct 20 11:37:11 2010
> @@ -19,6 +19,7 @@
> //
> #endregion
> 
> +using System.Globalization;
> using Extensibility;
> using EnvDTE;
> using EnvDTE80;
> @@ -233,7 +234,7 @@ namespace NPanday.VisualStudio.Addin
>                     return false;
>                 }
>             }
> -            if (uri.ToLower().StartsWith("http") || uri.ToLower().StartsWith("mailto"))
> +            if (uri.ToLower().StartsWith("http") || uri.ToLower().StartsWith("mailto", true, CultureInfo.InvariantCulture))
>             {
>                 return false;
>             }
> @@ -443,7 +444,7 @@ namespace NPanday.VisualStudio.Addin
>                 VsWebSite.VSWebSite website = (VsWebSite.VSWebSite)project.Object;
> 
>                 Assembly a = Assembly.LoadFile(artifact.FileInfo.FullName);
> -                if (a.ToString().Split(",".ToCharArray())[0].ToLower().StartsWith("interop."))
> +                if (a.ToString().Split(",".ToCharArray())[0].ToLower().StartsWith("interop.", true, CultureInfo.InvariantCulture))
>                 {
>                     MessageBox.Show("Cannot add COM Interop reference from a Maven Artifact, just use Add Reference if you wish to add a COM reference.", "Add Maven Artifact", MessageBoxButtons.OK, MessageBoxIcon.Information);
>                     return false;
> 
> Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/Connect.cs
> URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/Connect.cs?rev=1025511&r1=1025510&r2=1025511&view=diff
> ==============================================================================
> --- incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/Connect.cs (original)
> +++ incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/Connect.cs Wed Oct 20 11:37:11 2010
> @@ -208,7 +208,7 @@ namespace NPanday.VisualStudio.Addin
>                 if (projectItem.Name.Contains(".cs") || projectItem.Name.Contains(".vb"))
>                 {
>                     //change addpluginConfiguration to accept xmlElement instead
> -                    pomUtil.AddMavenCompilePluginConfiguration("npanday.plugin", "maven-compile-plugin", "includeSources", "includeSource", projectItem.Name);
> +                    pomUtil.AddMavenCompilePluginConfiguration("npanday.plugin", "maven-compile-plugin", "includeSources", "includeSource", GetRelativePathToProject(projectItem, null));
>                 }
> 
>                 if (projectItem.Name.Contains(".resx"))
> @@ -280,7 +280,7 @@ namespace NPanday.VisualStudio.Addin
>                     if (projectItem.Name.Contains(".cs") || projectItem.Name.Contains(".vb"))
>                     {
>                         //change addpluginConfiguration to accept xmlElement instead
> -                        pomUtil.RemoveMavenCompilePluginConfiguration("npanday.plugin", "maven-compile-plugin", "includeSources", "includeSource", projectItem.Name);
> +                        pomUtil.RemoveMavenCompilePluginConfiguration("npanday.plugin", "maven-compile-plugin", "includeSources", "includeSource", GetRelativePathToProject(projectItem, null));
>                     }
> 
>                     if (projectItem.Name.Contains(".resx"))
> @@ -302,7 +302,7 @@ namespace NPanday.VisualStudio.Addin
>                 if (projectItem.Name.Contains(".cs") || projectItem.Name.Contains(".vb"))
>                 {
>                     //change addpluginConfiguration to accept xmlElement instead
> -                    pomUtil.RenameMavenCompilePluginConfiguration("npanday.plugin", "maven-compile-plugin", "includeSources", "includeSource",oldName, projectItem.Name);
> +                    pomUtil.RenameMavenCompilePluginConfiguration("npanday.plugin", "maven-compile-plugin", "includeSources", "includeSource", GetRelativePathToProject(projectItem, oldName), GetRelativePathToProject(projectItem, null));
>                 }
> 
>                 if (projectItem.Name.Contains(".resx"))
> @@ -315,17 +315,37 @@ namespace NPanday.VisualStudio.Addin
> 
>         }
> 
> +        /// <summary>
> +        /// Returns either a relative path to project (if a project item is assciated with a file - like *.cs) or just the name of project item
> +        /// </summary>
> +        /// <param name="projectItem"></param>
> +        /// <returns></returns>
> +        private static string GetRelativePathToProject(ProjectItem projectItem, string fileName)
> +        {
> +            if (projectItem.FileCount == 1)
> +            {
> +                Uri fullPathUri = fileName == null ? new Uri(projectItem.get_FileNames(0)) : new Uri(Path.Combine(Path.GetDirectoryName(projectItem.get_FileNames(0)), fileName));
> +                Uri projectUri = new Uri(Path.GetDirectoryName(projectItem.ContainingProject.FullName) + Path.DirectorySeparatorChar);
> +                return projectUri.MakeRelativeUri(fullPathUri).ToString();
> +            }
> +            return projectItem.Name;
> +        }    

Can you explain more why this is needed?

Thanks!

- Brett

--
Brett Porter
brett@apache.org
http://brettporter.wordpress.com/