Author: lcorneliussen Date: Mon May 2 16:12:06 2011 New Revision: 1098642 URL: http://svn.apache.org/viewvc?rev=1098642&view=rev Log: [NPANDAY-385] MojoGenerator did not work and exception was catched silently. Both fixed, but not tested.
Added: incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/src/main/resources/pom-java.xml Removed: incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/src/main/resources/resgen/pom-java.xml Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/pom.xml incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/src/main/csharp/NPanday/Plugin/MojoGenerator/Generator.cs incubator/npanday/trunk/plugins/pom.xml incubator/npanday/trunk/pom.xml Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/pom.xml URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/pom.xml?rev=1098642&r1=1098641&r2=1098642&view=diff ============================================================================== --- incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/pom.xml (original) +++ incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/pom.xml Mon May 2 16:12:06 2011 @@ -42,5 +42,39 @@ under the License. <version>1.3.1-incubating-SNAPSHOT</version> <type>library</type> </dependency> - </dependencies> + </dependencies> + + <build> + <resources> + <resource> + <!-- make sure that the java-pom.xml is not copied here, but in the configured + maven-resources-plugin including filtering --> + <directory>nowhere</directory> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>copy-resources</id> + <phase>process-resources</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${basedir}/target/assembly-resources/resource</outputDirectory> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> </project> 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=1098642&r1=1098641&r2=1098642&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 Mon May 2 16:12:06 2011 @@ -1,4 +1,4 @@ -#region Apache License, Version 2.0 +#region Apache License, Version 2.0 // // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file @@ -21,135 +21,126 @@ using System; using System.Collections.Generic; using System.IO; -using System.Reflection; using System.Runtime.Remoting; -using System.Resources; -using System.Text; using System.Xml.Serialization; -using NPanday.Plugin; using NPanday.Plugin.Generator; namespace NPanday.Plugin.MojoGenerator { - /// <summary> - /// Provides methods for loading plugins and for creating Mojos. - /// </summary> - internal sealed class Generator - { - internal Generator() - { - } - - /// <summary> - /// Loads the specified plugin assembly file into the returned plugin application domain. - /// </summary> - /// <param name="pluginAssemblyFile">the.NET maven plugin</param> - /// <returns>application domain for .NET maven plugin</returns> - /// - internal AppDomain GetApplicationDomainFor(FileInfo pluginAssemblyFile) - { - Console.WriteLine("Loading Generator: " + pluginAssemblyFile.DirectoryName); - AppDomainSetup setup = new AppDomainSetup(); - setup.ApplicationBase = pluginAssemblyFile.DirectoryName; + /// <summary> + /// Provides methods for loading plugins and for creating Mojos. + /// </summary> + internal sealed class Generator + { + internal Generator() + { + } + + /// <summary> + /// Loads the specified plugin assembly file into the returned plugin application domain. + /// </summary> + /// <param name="pluginAssemblyFile">the.NET maven plugin</param> + /// <returns>application domain for .NET maven plugin</returns> + /// + internal AppDomain GetApplicationDomainFor(FileInfo pluginAssemblyFile) + { + Console.WriteLine("Loading Generator: " + pluginAssemblyFile.DirectoryName); + AppDomainSetup setup = new AppDomainSetup(); + setup.ApplicationBase = pluginAssemblyFile.DirectoryName; - AppDomain applicationDomain = AppDomain.CreateDomain("Loader", null, setup); - PluginDomainManager pluginDomainManager = (PluginDomainManager) applicationDomain.DomainManager; + AppDomain applicationDomain = AppDomain.CreateDomain("Loader", null, setup); + PluginDomainManager pluginDomainManager = (PluginDomainManager)applicationDomain.DomainManager; pluginDomainManager.LoadPlugin(pluginAssemblyFile); - return applicationDomain; - } - - /// <summary> - /// Creates an instance of the specified mojo name within the specified application domain. - /// </summary> - /// <param name="mojoName">the name of the mojo to create</param> - /// <param name="pluginAssemblyFile">the.NET maven plugin</param> - /// <param name="paramFile">the file containing the parameters to inject into an instance - /// of the specified mojo</param> - /// <param name="applicationDomain"> - /// the application domain used to create the specified mojo name instance</param> - /// <returns>an instance of the specified mojo name within the specified application domain</returns> - internal int BuildPluginProject(AppDomain applicationDomain, FileInfo pluginArtifact, - FileInfo outputDirectory, string groupId, string artifactId, - string version) - { - ObjectHandle objectHandle = - applicationDomain.CreateInstanceFrom(@pluginArtifact.FullName, - "NPanday.Plugin.Generator.JavaClassUnmarshaller"); - JavaClassUnmarshaller jcuRemote = (JavaClassUnmarshaller) objectHandle.Unwrap(); - List<JavaClass> javaClasses = jcuRemote.GetMojosFor(artifactId, groupId); - JavaClassUnmarshaller jcuLocal = new JavaClassUnmarshaller(); - - char[] delim = {'.'}; - DirectoryInfo sourceDirectory = new DirectoryInfo(@outputDirectory.FullName + "/src/main/java/" - + artifactId.Replace('.', '/')); + return applicationDomain; + } + + /// <summary> + /// Creates an instance of the specified mojo name within the specified application domain. + /// </summary> + /// <param name="mojoName">the name of the mojo to create</param> + /// <param name="pluginAssemblyFile">the.NET maven plugin</param> + /// <param name="paramFile">the file containing the parameters to inject into an instance + /// of the specified mojo</param> + /// <param name="applicationDomain"> + /// the application domain used to create the specified mojo name instance</param> + /// <returns>an instance of the specified mojo name within the specified application domain</returns> + internal int BuildPluginProject(AppDomain applicationDomain, FileInfo pluginArtifact, + FileInfo outputDirectory, string groupId, string artifactId, + string version) + { + ObjectHandle objectHandle = + applicationDomain.CreateInstanceFrom(@pluginArtifact.FullName, + "NPanday.Plugin.Generator.JavaClassUnmarshaller"); + JavaClassUnmarshaller jcuRemote = (JavaClassUnmarshaller)objectHandle.Unwrap(); + List<JavaClass> javaClasses = jcuRemote.GetMojosFor(artifactId, groupId); + JavaClassUnmarshaller jcuLocal = new JavaClassUnmarshaller(); + + char[] delim = { '.' }; + DirectoryInfo sourceDirectory = new DirectoryInfo(@outputDirectory.FullName + "/src/main/java/" + + artifactId.Replace('.', '/')); sourceDirectory.Create(); - if(javaClasses.Count == 0) - { - Console.WriteLine("NPanday-000-000: There are no Mojos within the assembly: Artifact Id = " - + artifactId); - return 1; - } - - foreach(JavaClass javaClass in javaClasses) - { - string[] tokens = javaClass.ClassName.Split(delim); - string classFileName = tokens[tokens.Length - 1]; - FileInfo fileInfo = new FileInfo(sourceDirectory.FullName + "/" - + classFileName + ".java"); + if (javaClasses.Count == 0) + { + Console.WriteLine("NPanday-000-000: There are no Mojos within the assembly: Artifact Id = " + + artifactId); + return 1; + } + + foreach (JavaClass javaClass in javaClasses) + { + string[] tokens = javaClass.ClassName.Split(delim); + string classFileName = tokens[tokens.Length - 1]; + FileInfo fileInfo = new FileInfo(sourceDirectory.FullName + "/" + + classFileName + ".java"); jcuLocal.unmarshall(javaClass, fileInfo); - } - try - { - - 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; - model.version = version; - model.name = artifactId + ".JavaBinding"; + } + + TextReader reader = new StreamReader(typeof(Generator).Assembly + .GetManifestResourceStream("NPanday.Plugin.MojoGenerator.pom-java.xml")); + + 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; + model.version = version; + model.name = artifactId + ".JavaBinding"; FileInfo outputPomXml = new FileInfo(@outputDirectory.FullName + "/pom-java.xml"); - TextWriter textWriter = new StreamWriter(@outputPomXml.FullName); + TextWriter textWriter = new StreamWriter(@outputPomXml.FullName); serializer.Serialize(textWriter, model); - } - catch (Exception e) + + return 0; + } + + public static int Main(string[] args) + { + + string targetAssemblyFile = GetArgFor("targetAssemblyFile", args); + string outputDirectory = GetArgFor("outputDirectory", args); + string pluginArtifactPath = GetArgFor("pluginArtifactPath", args); + string groupId = GetArgFor("groupId", args); + string artifactId = GetArgFor("artifactId", args); + string version = GetArgFor("artifactVersion", args); + + + Generator generator = new Generator(); + AppDomain applicationDomain = + generator.GetApplicationDomainFor(new FileInfo(targetAssemblyFile)); + return generator.BuildPluginProject(applicationDomain, new FileInfo(pluginArtifactPath), + new FileInfo(outputDirectory), + groupId, artifactId, version); + } + + private static string GetArgFor(string name, string[] args) + { + char[] delim = { '=' }; + foreach (string arg in args) { - Console.WriteLine(e); - } - return 0; - } - - public static int Main(string[] args) - { - - string targetAssemblyFile = GetArgFor("targetAssemblyFile", args); - string outputDirectory = GetArgFor("outputDirectory", args); - string pluginArtifactPath = GetArgFor("pluginArtifactPath", args); - string groupId = GetArgFor("groupId", args); - string artifactId = GetArgFor("artifactId", args); - string version = GetArgFor("artifactVersion", args); - - - Generator generator = new Generator(); - AppDomain applicationDomain = - generator.GetApplicationDomainFor(new FileInfo(targetAssemblyFile)); - return generator.BuildPluginProject(applicationDomain, new FileInfo(pluginArtifactPath), - new FileInfo(outputDirectory), - groupId, artifactId, version); - } - - private static string GetArgFor(string name, string[] args) - { - char[] delim = {'='}; - foreach(string arg in args) - { string[] tokens = arg.Split(delim); if (tokens[0].Equals(name)) return tokens[1]; - } + } return null; - } - } + } + } } Added: incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/src/main/resources/pom-java.xml URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/src/main/resources/pom-java.xml?rev=1098642&view=auto ============================================================================== --- incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/src/main/resources/pom-java.xml (added) +++ incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/src/main/resources/pom-java.xml Mon May 2 16:12:06 2011 @@ -0,0 +1,66 @@ +<!-- +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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId></groupId> + <artifactId></artifactId> + <packaging>maven-plugin</packaging> + <version></version> + <name></name> + <dependencies> + <dependency> + <groupId>npanday</groupId> + <artifactId>dotnet-assembler</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>npanday</groupId> + <artifactId>dotnet-executable</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>npanday</groupId> + <artifactId>dotnet-artifact</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>npanday</groupId> + <artifactId>dotnet-plugin</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + <version>${plexus.utils.version}</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + </plugins> + </build> +</project> Modified: incubator/npanday/trunk/plugins/pom.xml URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/pom.xml?rev=1098642&r1=1098641&r2=1098642&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/pom.xml (original) +++ incubator/npanday/trunk/plugins/pom.xml Mon May 2 16:12:06 2011 @@ -54,10 +54,7 @@ under the License. <module>wix-maven-plugin</module> <module>partcover-maven-plugin</module> </modules> - <properties> - <plexus.utils.version>1.5.1</plexus.utils.version> - </properties> - <dependencies> + <dependencies> <dependency> <groupId>npanday</groupId> <artifactId>dotnet-assembler</artifactId> @@ -85,7 +82,7 @@ under the License. <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> - <version>1.4.5</version> + <version>${plexus.utils.version}</version> </dependency> </dependencies> <build> Modified: incubator/npanday/trunk/pom.xml URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/pom.xml?rev=1098642&r1=1098641&r2=1098642&view=diff ============================================================================== --- incubator/npanday/trunk/pom.xml (original) +++ incubator/npanday/trunk/pom.xml Mon May 2 16:12:06 2011 @@ -434,7 +434,7 @@ under the License. <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> - <version>1.4.5</version> + <version>${plexus.utils.version}</version> </dependency> <dependency> <groupId>org.codehaus.plexus</groupId> @@ -592,7 +592,8 @@ under the License. </profile> </profiles> <properties> - <mavenVersion>2.0.9</mavenVersion> + <mavenVersion>2.0.9</mavenVersion> + <plexus.utils.version>1.5.1</plexus.utils.version> <npanday.snapshots.url>http://repo.npanday.org/archiva/repository/npanday-snapshots</npanday.snapshots.url> <npanday.releases.url>http://repo.npanday.org/archiva/repository/npanday-releases</npanday.releases.url> <bootstrap.npanday.version>${project.version}</bootstrap.npanday.version>