incubator-nmaven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r601925 - in /incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components: dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/ dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/ dotnet-compiler/src/ma...
Date Fri, 07 Dec 2007 00:26:12 GMT
Author: sisbell
Date: Thu Dec  6 16:26:10 2007
New Revision: 601925

URL: http://svn.apache.org/viewvc?rev=601925&view=rev
Log:
Fixed problem with locating of marshallers.

Modified:
    incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblerContext.java
    incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoMarshaller.java
    incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/AssemblerContextImpl.java
    incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java
    incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/DefaultAssemblyInfoMarshaller.java
    incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/JavaAssemblyInfoMarshaller.java
    incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/VBAssemblyInfoMarshaller.java

Modified: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblerContext.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblerContext.java?rev=601925&r1=601924&r2=601925&view=diff
==============================================================================
--- incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblerContext.java
(original)
+++ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblerContext.java
Thu Dec  6 16:26:10 2007
@@ -38,7 +38,6 @@
      * Returns the assembly info associated with this context.
      *
      * @return the assembly info associated with this context.
-
      */
     AssemblyInfo getAssemblyInfo();
 
@@ -57,6 +56,7 @@
      *
      * @param mavenProject the maven project
      */
-    void init( MavenProject mavenProject );
+    void init( MavenProject mavenProject )
+        throws AssemblyInfoException;
 
 }

Modified: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoMarshaller.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoMarshaller.java?rev=601925&r1=601924&r2=601925&view=diff
==============================================================================
--- incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoMarshaller.java
(original)
+++ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoMarshaller.java
Thu Dec  6 16:26:10 2007
@@ -51,4 +51,5 @@
 
     void init( ProgrammingLanguage programmingLanguage, File buildSourcesDirectory );
 
+    ProgrammingLanguage getProgrammingLanguageForMarshaller();
 }

Modified: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/AssemblerContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/AssemblerContextImpl.java?rev=601925&r1=601924&r2=601925&view=diff
==============================================================================
--- incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/AssemblerContextImpl.java
(original)
+++ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/AssemblerContextImpl.java
Thu Dec  6 16:26:10 2007
@@ -25,6 +25,7 @@
 import org.apache.maven.dotnet.assembler.AssemblyInfoMarshallerAnnotation;
 import org.apache.maven.dotnet.ProgrammingLanguage;
 import org.apache.maven.dotnet.BuildDirectories;
+import org.apache.maven.dotnet.PlatformUnsupportedException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.model.Organization;
 
@@ -34,6 +35,12 @@
 
 import java.io.*;
 import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.jar.JarFile;
+import java.util.jar.JarEntry;
 
 /**
  * Provides an implementation of the <code>AssemblerContext</code>.
@@ -54,6 +61,8 @@
      */
     private Logger logger;
 
+    private List<AssemblyInfoMarshaller> marshallers;
+
     /**
      * Constructor. This method is intended to by invoked by the plexus-container, not by
the application developer.
      */
@@ -132,50 +141,88 @@
     public AssemblyInfoMarshaller getAssemblyInfoMarshallerFor( ProgrammingLanguage programmingLanguage
)
         throws AssemblyInfoException
     {
-        Class assemblyInfoMarshallerClass = null;
-        for ( Class c : AssemblyInfoMarshaller.class.getClasses() )
+
+        for(AssemblyInfoMarshaller m : marshallers)
         {
-            AssemblyInfoMarshallerAnnotation annotation =
-                (AssemblyInfoMarshallerAnnotation) c.getAnnotation( AssemblyInfoMarshallerAnnotation.class
);
-            if ( annotation != null )
+            if(m.getProgrammingLanguageForMarshaller().equals( programmingLanguage))
             {
-                if ( Arrays.asList( annotation.programmingLanguages() ).contains( programmingLanguage
) )
-                {
-                    assemblyInfoMarshallerClass = c;
-                }
+                return m;
             }
         }
-        if ( assemblyInfoMarshallerClass == null )
-        {
-            throw new AssemblyInfoException( "" );
-        }
-
-        AssemblyInfoMarshaller marshaller;
-        try
-        {
-            marshaller = (AssemblyInfoMarshaller) assemblyInfoMarshallerClass.newInstance();
-            marshaller.init( programmingLanguage, new File( mavenProject.getBuild().getDirectory(),
-                                                            BuildDirectories.BUILD_SOURCES.getBuildDirectoryName()
) );
-        }
-        catch ( InstantiationException e )
-        {
-            throw new AssemblyInfoException( "NMAVEN-020-003: Unable to create AssemblyInfoMarshaller:
Class Name = " +
-                assemblyInfoMarshallerClass.getName(), e );
-        }
-        catch ( IllegalAccessException e )
-        {
-            throw new AssemblyInfoException( "NMAVEN-020-004: Unable to create AssemblyInfoMarshaller:
Class Name = " +
-                assemblyInfoMarshallerClass.getName(), e );
-        }
-
-        return marshaller;
+        return null;
     }
 
     /**
      * @see AssemblerContext#init(org.apache.maven.project.MavenProject)
      */
     public void init( MavenProject mavenProject )
+        throws AssemblyInfoException
     {
         this.mavenProject = mavenProject;
+
+        String[] classPathJars = System.getProperty( "java.class.path" ).split( "[" + File.pathSeparator
+ "]" );
+        for ( String classPathJar : classPathJars )
+        {
+            if ( classPathJar.contains( "dotnet-extensions-" ) )
+            {
+                JarFile jarFile = null;
+                try
+                {
+                    jarFile = new JarFile( classPathJar );
+                }
+                catch ( IOException e )
+                {
+                    e.printStackTrace();
+                }
+                Enumeration jarEntries = jarFile.entries();
+
+                while ( jarEntries.hasMoreElements() )
+                {
+                    JarEntry jarEntry = (JarEntry) jarEntries.nextElement();
+                    if ( jarEntry.isDirectory() || !jarEntry.getName().endsWith( "class"
) )
+                    {
+                        continue;
+                    }
+
+                    String className = null;
+                    try
+                    {
+                        String[] tokens = jarEntry.getName().split( "[//]" );
+
+                        Class c = Class.forName( tokens[tokens.length - 1].split( "[.]" )[0]
);
+                        className = c.getName();
+                        AssemblyInfoMarshallerAnnotation annotation =
+                            (AssemblyInfoMarshallerAnnotation) c.getAnnotation(
+                                AssemblyInfoMarshallerAnnotation.class );
+                        if ( annotation != null )
+                        {
+                            for ( ProgrammingLanguage programmingLanguage : annotation.programmingLanguages()
)
+                            {
+                                AssemblyInfoMarshaller marshaller = (AssemblyInfoMarshaller)
c.newInstance();
+                                marshaller.init( programmingLanguage, new File( mavenProject.getBuild().getDirectory(),
+                                                                                BuildDirectories.BUILD_SOURCES.getBuildDirectoryName()
) );
+                                marshallers.add( marshaller );
+                            }
+
+                        }
+                    }
+                    catch ( ClassNotFoundException e )
+                    {
+                        throw new AssemblyInfoException(
+                            "NMAVEN-061-007: Unable to create AssemblyInfoMarshaller: Class
Name = " + className, e );
+                    }
+                    catch ( InstantiationException e )
+                    {
+                        throw new AssemblyInfoException(
+                            "NMAVEN-020-003: Unable to create AssemblyInfoMarshaller: Class
Name = " + className, e );
+                    }
+                    catch ( IllegalAccessException e )
+                    {
+                        throw new AssemblyInfoException(
+                            "NMAVEN-020-004: Unable to create AssemblyInfoMarshaller: Class
Name = " + className, e );
+                    }
+                }
+            }
+        }
     }
 }

Modified: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java?rev=601925&r1=601924&r2=601925&view=diff
==============================================================================
--- incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java
(original)
+++ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java
Thu Dec  6 16:26:10 2007
@@ -202,7 +202,7 @@
         String[] classPathJars = System.getProperty( "java.class.path" ).split( "[" + File.pathSeparator
+ "]" );
         for ( String classPathJar : classPathJars )
         {
-            if ( classPathJar.contains( "dotnet-compiler-" ) )
+            if ( classPathJar.contains( "dotnet-extensions-" ) )
             {
                 JarFile jarFile = null;
                 try

Modified: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/DefaultAssemblyInfoMarshaller.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/DefaultAssemblyInfoMarshaller.java?rev=601925&r1=601924&r2=601925&view=diff
==============================================================================
--- incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/DefaultAssemblyInfoMarshaller.java
(original)
+++ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/DefaultAssemblyInfoMarshaller.java
Thu Dec  6 16:26:10 2007
@@ -119,6 +119,11 @@
         this.buildSourcesDirectory = buildSourcesDirectory;
     }
 
+    public ProgrammingLanguage getProgrammingLanguageForMarshaller()
+    {
+        return programmingLanguage;
+    }
+
     /**
      * Sets the specified value within the specified assembly info
      *
@@ -198,5 +203,31 @@
         sb.append( "[assembly: Assembly" ).append( name ).append( "(\"" ).append( value ).append(
"\")]" ).append(
             "\r\n" );
         return sb.toString();
+    }
+
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+        if ( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+
+        final DefaultAssemblyInfoMarshaller that = (DefaultAssemblyInfoMarshaller) o;
+
+        if ( programmingLanguage != that.programmingLanguage )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    public int hashCode()
+    {
+        return programmingLanguage.hashCode();
     }
 }

Modified: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/JavaAssemblyInfoMarshaller.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/JavaAssemblyInfoMarshaller.java?rev=601925&r1=601924&r2=601925&view=diff
==============================================================================
--- incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/JavaAssemblyInfoMarshaller.java
(original)
+++ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/JavaAssemblyInfoMarshaller.java
Thu Dec  6 16:26:10 2007
@@ -94,6 +94,11 @@
         this.buildSourcesDirectory = buildSourcesDirectory;
     }
 
+    public ProgrammingLanguage getProgrammingLanguageForMarshaller()
+    {
+        return programmingLanguage;
+    }
+
     /**
      * Returns an assembly entry with a name-value pair beginning with '/**@'  and ending
with '*\/'
      *
@@ -107,5 +112,31 @@
         sb.append( "/**@assembly: Assembly" ).append( name ).append( "(\"" ).append( value
).append( "\")*/" ).append(
             "\r\n" );
         return sb.toString();
+    }
+
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+        if ( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+
+        final JavaAssemblyInfoMarshaller that = (JavaAssemblyInfoMarshaller) o;
+
+        if ( programmingLanguage != that.programmingLanguage )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    public int hashCode()
+    {
+        return programmingLanguage.hashCode();
     }
 }

Modified: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/VBAssemblyInfoMarshaller.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/VBAssemblyInfoMarshaller.java?rev=601925&r1=601924&r2=601925&view=diff
==============================================================================
--- incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/VBAssemblyInfoMarshaller.java
(original)
+++ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/VBAssemblyInfoMarshaller.java
Thu Dec  6 16:26:10 2007
@@ -93,6 +93,11 @@
         this.buildSourcesDirectory = buildSourcesDirectory;
     }
 
+    public ProgrammingLanguage getProgrammingLanguageForMarshaller()
+    {
+        return programmingLanguage;
+    }
+
     /**
      * Returns an assembly entry with a name-value pair surrounded by angle brackets.
      *
@@ -106,5 +111,31 @@
         sb.append( "<Assembly: Assembly" ).append( name ).append( "(\"" ).append( value
).append( "\")>" ).append(
             "\r\n" );
         return sb.toString();
+    }
+
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+        if ( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+
+        final VBAssemblyInfoMarshaller that = (VBAssemblyInfoMarshaller) o;
+
+        if ( programmingLanguage != that.programmingLanguage )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    public int hashCode()
+    {
+        return programmingLanguage.hashCode();
     }
 }



Mime
View raw message