NPanday
  1. NPanday
  2. NPANDAY-470

maven-mojo-generator-plugin can't create javabinding

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.4-incubating
    • Fix Version/s: Backlog
    • Component/s: Maven Plugins
    • Labels:
      None
    • Environment:

      windows 7 64 bit, maven 2.2.1

      Description

      The plugin does work as documented here http://incubator.apache.org/npanday/docs/1.4.0-incubating/plugins/maven-mojo-generator-plugin/usage.html. I have a simple netplugin pom with a single c# class that inherits from AbstractMojo (see code below). When I run mvn install on my pom the following things happen

      • npanday successfully builds a .net plugin
      • npanday automatically generates a javabinding. The java binding is unexpected as this time (according to the documentation it first require to invoke an additional command).
      • The generated pom-java.xml does not compile for many reasons. First of all the syntax of the annotations cannot be parsed and results in a parse-exception, secondly (when you fix the syntax by hand), the java file will not compile because it imports from wrong packages and inherits from wrong types. Third, when you manually fix those issues it will compile, albeit the plugin will not run.

      In the npanday source tree there is an example of the msbuild plugin which actually works as netplugin. However, If you try to build the pom-java.xml of the msbuild plugin, it will fail for the same reasons. Only the provided 'javabinding' works as a plugin and it looks like this has been maintained by hand and not via the mojo-generator plugin.

      example pom:

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <!--  To generate java bindings automatically.  
          http://incubator.apache.org/npanday/docs/1.4.0-incubating/plugins/maven-mojo-generator-plugin/usage.html
          mvn org.apache.npanday.plugins:maven-mojo-generator-plugin:generate-bindings
      	mvn org.apache.npanday.plugins:maven-mojo-generator-plugin:1.4.1-incubating:generate-bindings
      	-->
        <modelVersion>4.0.0</modelVersion>
        <groupId>Test</groupId>
        <artifactId>NPanday.Plugin.MyMojoTest</artifactId>
        <packaging>netplugin</packaging>
        <name>my test mojo</name>
        <version>1.0-SNAPSHOT</version>
        <build>
          <sourceDirectory>src/main/cs</sourceDirectory>
          <testSourceDirectory>src/test/cs</testSourceDirectory>
          <plugins>
            <plugin>
              <groupId>org.apache.npanday.plugins</groupId>
              <artifactId>maven-compile-plugin</artifactId>
              <version>1.4.1-incubating-SNAPSHOT</version>
              <extensions>true</extensions>
            </plugin>
          </plugins>
        </build>
        <dependencies>
          <dependency>
            <groupId>org.apache.npanday</groupId>
            <artifactId>NPanday.Artifact</artifactId>
            <version>1.4.1-incubating-SNAPSHOT</version>
            <type>dotnet-library</type>
          </dependency>
          <dependency>
            <groupId>org.apache.npanday</groupId>
            <artifactId>NPanday.Model.AutomationExtensibility</artifactId>
            <version>1.4.1-incubating-SNAPSHOT</version>
            <type>dotnet-library</type>
          </dependency>
          <dependency>
            <groupId>org.apache.npanday.plugins</groupId>
            <artifactId>NPanday.Plugin</artifactId>
            <version>1.4.1-incubating-SNAPSHOT</version>
            <type>dotnet-library</type>
          </dependency>
          <dependency>
            <groupId>org.apache.npanday</groupId>
            <artifactId>NPanday.Model.Pom</artifactId>
            <version>1.4.1-incubating-SNAPSHOT</version>
            <type>dotnet-library</type>
          </dependency>
      	<!--
          <dependency>
            <groupId>org.apache.npanday.plugins</groupId>
            <artifactId>NPanday.Plugin.Runner</artifactId>
            <version>1.4.0-incubating</version>
            <type>dotnet-executable</type>
            <scope>runtime</scope>
          </dependency>
          <dependency>
            <groupId>org.apache.npanday.plugins</groupId>
            <artifactId>NPanday.Plugin.MojoGenerator</artifactId>
            <version>1.4.0-incubating</version>
            <type>dotnet-executable</type>
            <scope>runtime</scope>
          </dependency>
      	-->
        </dependencies>
      </project>
      

      c# Mojo:

      using System;
      using System.Collections.Generic;
      using System.IO;
      using System.Xml;
      using System.Xml.Serialization;
      using System.Diagnostics;
      using Microsoft.Win32;
      
      using NPanday.Plugin;
      using NPanday.Model.Pom;
      using NPanday.Model;
      using NPanday.Artifact;
      using System.Reflection;
      
      namespace NPanday.Plugin.MyMojoTest
      {
      	/// <summary>
      	/// C# Plugin that will generate the required system reference .dlls
      	/// </summary>
      	[ClassAttribute(Phase = "validate", Goal = "compile")]
      	public sealed class MyMojo : AbstractMojo
      	{
      
              public MyMojo()
      		{
      		}
      
      		
      		[FieldAttribute("mavenProject", Expression = "${project}", Type = "org.apache.maven.project.MavenProject")]
      		public NPanday.Model.Pom.Model mavenProject;
      
      		public string myProperty;
      		
      		public override Type GetMojoImplementationType()
      		{
      			return this.GetType();
      		}
      
              public override void Execute()
              {
      			Console.WriteLine("[INFO] HELLO MY c# PLUGIN "+myProperty);
              }
          }
      }
      

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            sergio rupena
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development