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

                 Key: NPANDAY-470
                 URL: https://issues.apache.org/jira/browse/NPANDAY-470
             Project: NPanday
          Issue Type: Bug
          Components: Maven Plugins
    Affects Versions: 1.4.1-incubating
         Environment: windows 7 64 bit, maven 2.2.1
            Reporter: sergio rupena


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:
{code:xml}
<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>
{code}

c# Mojo:


{code}
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);
        }
    }
}
{code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to