:-)

Thanks.
--
Olivier

2009/1/26 nicolas de loof <[email protected]>:
> Oups ....
>
> 2009/1/26 Olivier Lamy <[email protected]>
>>
>> Hi,
>> Are you sure the units tests will pass for all ;-))
>> File x = new File(
>>
>> "D:/platina/repository/com/google/gwt/gwt-dev/1.5.2/gwt-dev-1.5.2-windows.jar"
>> );
>> --
>> Olivier
>>
>> 2009/1/26  <[email protected]>:
>> > Revision 8909 Author ndeloof Date 2009-01-26 04:49:50 -0600 (Mon, 26 Jan
>> > 2009)
>> >
>> > Log Message
>> >
>> > Detect GWT version and adapt scripts arguments, main class ... according
>> >
>> > Modified Paths
>> >
>> > trunk/mojo/gwt-maven-plugin/pom.xml
>> >
>> > trunk/mojo/gwt-maven-plugin/src/main/java/org/codehaus/mojo/gwt/GwtRuntime.java
>> >
>> > trunk/mojo/gwt-maven-plugin/src/main/java/org/codehaus/mojo/gwt/shell/scripting/AbstractScriptWriter.java
>> >
>> > Added Paths
>> >
>> >
>> > trunk/mojo/gwt-maven-plugin/src/main/java/org/codehaus/mojo/gwt/GwtVersion.java
>> >
>> > trunk/mojo/gwt-maven-plugin/src/test/java/org/codehaus/mojo/gwt/GwtRuntimeTest.java
>> > trunk/mojo/gwt-maven-plugin/src/test/resources/gwt-dev-1.4.62-fake.jar
>> > trunk/mojo/gwt-maven-plugin/src/test/resources/gwt-dev-1.5.3-fake.jar
>> >
>> > Diff
>> >
>> > Modified: trunk/mojo/gwt-maven-plugin/pom.xml (8908 => 8909)
>> >
>> > --- trunk/mojo/gwt-maven-plugin/pom.xml       2009-01-25 23:47:45 UTC
>> > (rev 8908)
>> > +++ trunk/mojo/gwt-maven-plugin/pom.xml       2009-01-26 10:49:50 UTC
>> > (rev 8909)
>> > @@ -172,6 +172,11 @@
>> >        <version>1.0-beta-1</version>
>> >        <scope>test</scope>
>> >      </dependency>
>> > +    <dependency>
>> > +     <groupId>bcel</groupId>
>> > +     <artifactId>bcel</artifactId>
>> > +     <version>5.1</version>
>> > +    </dependency>
>> >    </dependencies>
>> >    <profiles>
>> >      <profile>
>> >
>> > Modified:
>> >
>> > trunk/mojo/gwt-maven-plugin/src/main/java/org/codehaus/mojo/gwt/GwtRuntime.java
>> > (8908 => 8909)
>> >
>> > ---
>> >
>> > trunk/mojo/gwt-maven-plugin/src/main/java/org/codehaus/mojo/gwt/GwtRuntime.java
>> >       2009-01-25
>> > 23:47:45 UTC (rev 8908)
>> > +++
>> >
>> > trunk/mojo/gwt-maven-plugin/src/main/java/org/codehaus/mojo/gwt/GwtRuntime.java
>> >       2009-01-26
>> > 10:49:50 UTC (rev 8909)
>> > @@ -20,7 +20,11 @@
>> >   */
>> >
>> >  import java.io.File;
>> > +import java.net.URL;
>> >
>> > +import org.apache.bcel.classfile.ClassParser;
>> > +import org.apache.bcel.classfile.JavaClass;
>> > +
>> >  /**
>> >   * @author ndeloof
>> >   * @version $Id$
>> > @@ -33,18 +37,70 @@
>> >      /** The gwt-dev-[platform] jar used at runtime */
>> >      private File gwtDevJar;
>> >
>> > +    /** The gwt version we are running */
>> > +    private GwtVersion version;
>> >
>> >      /**
>> > -     * @param gwtUserJar
>> > -     * @param gwtDevJar
>> > +     * @param gwtUserJar gwt user library
>> > +     * @param gwtDevJar gwt dev library
>> > +     * @param version gwt version
>> >       */
>> > -    public GwtRuntime( File gwtUserJar, File gwtDevJar )
>> > +    public GwtRuntime( File gwtUserJar, File gwtDevJar, String version
>> > )
>> >      {
>> >          super();
>> > +        this.version = GwtVersion.fromMavenVersion( version );
>> >          this.gwtUserJar = gwtUserJar;
>> >          this.gwtDevJar = gwtDevJar;
>> >      }
>> >
>> > +    /**
>> > +     * @param gwtUserJar gwt user library
>> > +     * @param gwtDevJar gwt dev library
>> > +     */
>> > +    public GwtRuntime( File gwtUserJar, File gwtDevJar )
>> > +    {
>> > +        this( gwtUserJar, gwtDevJar, readGwtDevVersion( gwtDevJar ) );
>> > +    }
>> > +
>> > +    /**
>> > +     * Read the GWT version from the About class present in gwt-dev JAR
>> > +     *
>> > +     * @param gwtDevJar gwt platform-dependent developer library
>> > +     * @return version declared in dev library
>> > +     */
>> > +    private static String readGwtDevVersion( File gwtDevJar )
>> > +    {
>> > +        try
>> > +        {
>> > +             URL about = new URL( "jar:" + gwtDevJar.toURL() +
>> > "!/com/google/gwt/dev/About.class" );
>> > +            ClassParser parser = new ClassParser( about.openStream(),
>> > "About.class" );
>> > +            JavaClass clazz = parser.parse();
>> > +            for ( org.apache.bcel.classfile.Field field :
>> > clazz.getFields()
>> > )
>> > +            {
>> > +                if ( "GWT_VERSION_NUM".equals( field.getName() ) )
>> > +                {
>> > +                    // Return the constant value between quotes
>> > +                    String constant =
>> > field.getConstantValue().toString();
>> > +                    return constant.substring( 1, constant.length() - 1
>> > );
>> > +                }
>> > +            }
>> > +            throw new IllegalStateException( "Failed to retrieve
>> > GWT_VERSION_NUM in " + gwtDevJar.getName()
>> > +                + " 'About' class" );
>> > +
>> > +            // Can't get this to work as expected, always return maven
>> > dependency "1.5.3" :'-(
>> > +            // ClassLoader cl = new URLClassLoader( new URL[] {
>> > gwtDevJar.toURL() }, ClassLoader.getSystemClassLoader()
>> > +            // );
>> > +            // Class<?> about = cl.loadClass(
>> > "com.google.gwt.dev.About" );
>> > +            // Field versionNumber = about.getField( "GWT_VERSION_NUM"
>> > );
>> > +            // String version = versionNumber.get( about ).toString();
>> > +            // return version;
>> > +        }
>> > +        catch ( Exception e )
>> > +        {
>> > +            throw new IllegalStateException( "Failed to read gwt-dev
>> > version from " + gwtDevJar.getAbsolutePath() );
>> > +        }
>> > +    }
>> > +
>> >      public File getGwtUserJar()
>> >      {
>> >          return gwtUserJar;
>> > @@ -55,4 +111,9 @@
>> >          return gwtDevJar;
>> >      }
>> >
>> > +    public GwtVersion getVersion()
>> > +    {
>> > +        return version;
>> > +    }
>> > +
>> >  }
>> >
>> > Added:
>> >
>> > trunk/mojo/gwt-maven-plugin/src/main/java/org/codehaus/mojo/gwt/GwtVersion.java
>> > (0 => 8909)
>> >
>> > ---
>> >
>> > trunk/mojo/gwt-maven-plugin/src/main/java/org/codehaus/mojo/gwt/GwtVersion.java
>> > (rev 0)
>> > +++
>> >
>> > trunk/mojo/gwt-maven-plugin/src/main/java/org/codehaus/mojo/gwt/GwtVersion.java
>> >       2009-01-26
>> > 10:49:50 UTC (rev 8909)
>> > @@ -0,0 +1,83 @@
>> > +package org.codehaus.mojo.gwt;
>> > +
>> > +/**
>> > + * @author ndeloof
>> > + */
>> > +public enum GwtVersion
>> > +{
>> > +    ONE_DOT_FOUR
>> > +    {
>> > +        @Override
>> > +        public String getShellFQCN()
>> > +        {
>> > +            return "com.google.gwt.dev.GWTShell";
>> > +        }
>> > +    },
>> > +    ONE_DOT_FIVE
>> > +    {
>> > +        @Override
>> > +        public String getShellFQCN()
>> > +        {
>> > +            return "com.google.gwt.dev.GWTShell";
>> > +        }
>> > +    },
>> > +    ONE_DOT_SIX
>> > +    {
>> > +        @Override
>> > +        public String getShellFQCN()
>> > +        {
>> > +            return "com.google.gwt.dev.HostedMode";
>> > +        }
>> > +
>> > +        @Override
>> > +        public boolean fixEmbeddedTomcatClassloaderIssue()
>> > +        {
>> > +            return true;
>> > +        }
>> > +    },
>> > +    FUTURE
>> > +    {
>> > +        @Override
>> > +        public String getShellFQCN()
>> > +        {
>> > +            return "com.google.gwt.dev.HostedMode";
>> > +        }
>> > +
>> > +        @Override
>> > +        public boolean fixEmbeddedTomcatClassloaderIssue()
>> > +        {
>> > +            return true;
>> > +        }
>> > +    };
>> > +
>> > +    /**
>> > +     * @return fully qualified class name of the GWTShell "main" class
>> > +     */
>> > +    public abstract String getShellFQCN();
>> > +
>> > +    /**
>> > +     * @return <code>true</code> if this version fixes
>> > EmbeddedTomcatServer
>> > issue with SystemClassLoader
>> > +     * @see
>> > http://code.google.com/p/google-web-toolkit/issues/detail?id=1032
>> > +     */
>> > +    public boolean fixEmbeddedTomcatClassloaderIssue()
>> > +    {
>> > +        return false;
>> > +    }
>> > +
>> > +    static GwtVersion fromMavenVersion( String version )
>> > +    {
>> > +        if ( version.startsWith( "1.4" ) )
>> > +        {
>> > +            return ONE_DOT_FOUR;
>> > +        }
>> > +        if ( version.startsWith( "1.5" ) )
>> > +        {
>> > +            return ONE_DOT_FIVE;
>> > +        }
>> > +        if ( version.startsWith( "1.6" ) )
>> > +        {
>> > +            return ONE_DOT_SIX;
>> > +        }
>> > +        return FUTURE;
>> > +    }
>> > +}
>> >
>> > Modified:
>> >
>> > trunk/mojo/gwt-maven-plugin/src/main/java/org/codehaus/mojo/gwt/shell/scripting/AbstractScriptWriter.java
>> > (8908 => 8909)
>> >
>> > ---
>> >
>> > trunk/mojo/gwt-maven-plugin/src/main/java/org/codehaus/mojo/gwt/shell/scripting/AbstractScriptWriter.java
>> >     2009-01-25
>> > 23:47:45 UTC (rev 8908)
>> > +++
>> >
>> > trunk/mojo/gwt-maven-plugin/src/main/java/org/codehaus/mojo/gwt/shell/scripting/AbstractScriptWriter.java
>> >     2009-01-26
>> > 10:49:50 UTC (rev 8909)
>> > @@ -42,6 +42,7 @@
>> >      extends AbstractLogEnabled
>> >      implements ScriptWriter
>> >  {
>> > +
>> >      /**
>> >       * @plexus.requirement
>> >       */
>> > @@ -105,7 +106,7 @@
>> >          //
>> > "com.google.gwt.dev.GWTShell" );
>> >          String extra = getExtraJvmArgs( configuration );
>> >          writer.print( "\"" + getJavaCommand( configuration ) + "\" " +
>> > extra );
>> > -
>> > +
>> >          writer.print( " -Dcatalina.base=\"" +
>> > configuration.getTomcat().getAbsolutePath() + "\" " );
>> >          writer.print( " -cp \"" + getPlatformClasspathVariable() + "\"
>> > " );
>> >          //writer.print( " -jar \"" + booterJar + "\" " );
>> > @@ -120,10 +121,10 @@
>> >              }
>> >          }
>> >
>> > -
>> > +
>> >          //writer.print( " org.codehaus.mojo.gwt.fork.ForkBooter " );
>> >          //writer.print( " \"" + classpath.getAbsolutePath() + "\" " );
>> > -        writer.print( " com.google.gwt.dev.GWTShell" );
>> > +        writer.print( " " + runtime.getVersion().getShellFQCN() );
>> >          writer.print( " -gen \"" );
>> >          writer.print( configuration.getGen().getAbsolutePath() );
>> >          writer.print( "\" -logLevel " );
>> > @@ -148,6 +149,8 @@
>> >          return file;
>> >      }
>> >
>> > +
>> > +
>> >      /**
>> >       * Write compile script.
>> >       */
>> > @@ -230,7 +233,7 @@
>> >                  writer.print( "\"" + getJavaCommand( configuration ) +
>> > "\"
>> > " + extra );
>> >                  writer.print( " -cp \"" + configuration.getPluginJar()
>> > +
>> > "\" " );
>> >                  writer.print( " org.codehaus.mojo.gwt.fork.ForkBooter "
>> > );
>> > -                writer.print( " \"" + classpath.getAbsolutePath() + "\"
>> > "
>> > );
>> > +                writer.print( " \"" + classpath.getAbsolutePath() + "\"
>> > "
>> > );
>> >                  writer.print( " com.google.gwt.i18n.tools.I18NSync" );
>> >                  writer.print( " -out " );
>> >                  writer.print( "\"" +
>> > configuration.getGenerateDirectory() +
>> > "\"" );
>> > @@ -251,7 +254,7 @@
>> >
>> >                  writer.print( "\"" + getJavaCommand( configuration ) +
>> > "\"
>> > " + extra );
>> >                  writer.print( " -cp \"" + configuration.getPluginJar()
>> > +
>> > "\" " );
>> > -                writer.print( " org.codehaus.mojo.gwt.fork.ForkBooter "
>> > );
>> > +                writer.print( " org.codehaus.mojo.gwt.fork.ForkBooter "
>> > );
>> >                  writer.print( " \"" + classpath.getAbsolutePath() + "\"
>> > "
>> > );
>> >                  writer.print( " com.google.gwt.i18n.tools.I18NSync" );
>> >                  writer.print( " -createMessages " );
>> > @@ -282,7 +285,7 @@
>> >              targetPackageDirectory.mkdirs();
>> >          }
>> >      }
>> > -
>> > +
>> >      /**
>> >       * Write test scripts.
>> >       */
>> > @@ -357,7 +360,7 @@
>> >              }
>> >          }
>> >      }
>> > -
>> > +
>> >      protected String getJavaCommand( GwtShellScriptConfiguration
>> > configuration )
>> >          throws MojoExecutionException
>> >      {
>> > @@ -382,6 +385,6 @@
>> >          // use the same JVM as the one used to run Maven (the
>> > "java.home"
>> > one)
>> >          return System.getProperty( "java.home" ) + File.separator +
>> > "bin" +
>> > File.separator + "java";
>> >      }
>> > -
>> > -
>> > +
>> > +
>> >  }
>> > \ No newline at end of file
>> >
>> > Added:
>> >
>> > trunk/mojo/gwt-maven-plugin/src/test/java/org/codehaus/mojo/gwt/GwtRuntimeTest.java
>> > (0 => 8909)
>> >
>> > ---
>> >
>> > trunk/mojo/gwt-maven-plugin/src/test/java/org/codehaus/mojo/gwt/GwtRuntimeTest.java
>> > (rev 0)
>> > +++
>> >
>> > trunk/mojo/gwt-maven-plugin/src/test/java/org/codehaus/mojo/gwt/GwtRuntimeTest.java
>> >   2009-01-26
>> > 10:49:50 UTC (rev 8909)
>> > @@ -0,0 +1,33 @@
>> > +package org.codehaus.mojo.gwt;
>> > +
>> > +import java.io.File;
>> > +
>> > +import junit.framework.TestCase;
>> > +
>> > +/**
>> > + * @author ndeloof
>> > + */
>> > +public class GwtRuntimeTest
>> > +    extends TestCase
>> > +{
>> > +    /**
>> > +     * Check version detection from GWT-dev Jar
>> > +     */
>> > +    public void testGwtVersion153Detection()
>> > +    {
>> > +        File x = new File(
>> >
>> > "D:/platina/repository/com/google/gwt/gwt-dev/1.5.2/gwt-dev-1.5.2-windows.jar"
>> > );
>> > +        File basedir = new File( System.getProperty( "basedir", "." )
>> > );
>> > +        File gwtDevJar = new File( basedir,
>> > "target/test-classes/gwt-dev-1.5.3-fake.jar" );
>> > +        GwtRuntime gwt = new GwtRuntime( null, x );
>> > +        assertEquals( GwtVersion.ONE_DOT_FIVE, gwt.getVersion() );
>> > +    }
>> > +
>> > +    public void testGwtVersion1462Detection()
>> > +    {
>> > +        File basedir = new File( System.getProperty( "basedir", "." )
>> > );
>> > +        File gwtDevJar = new File( basedir,
>> > "target/test-classes/gwt-dev-1.4.62-fake.jar" );
>> > +        GwtRuntime gwt = new GwtRuntime( null, gwtDevJar );
>> > +        assertEquals( GwtVersion.ONE_DOT_FOUR, gwt.getVersion() );
>> > +    }
>> > +
>> > +}
>> >
>> > Added:
>> > trunk/mojo/gwt-maven-plugin/src/test/resources/gwt-dev-1.4.62-fake.jar
>> >
>> > (Binary files differ)
>> >
>> > Property changes on:
>> > trunk/mojo/gwt-maven-plugin/src/test/resources/gwt-dev-1.4.62-fake.jar
>> > ___________________________________________________________________
>> > Name:
>> > svn:mime-type + application/octet-stream
>> >
>> > Added:
>> > trunk/mojo/gwt-maven-plugin/src/test/resources/gwt-dev-1.5.3-fake.jar
>> >
>> > (Binary files differ)
>> >
>> > Property changes on:
>> > trunk/mojo/gwt-maven-plugin/src/test/resources/gwt-dev-1.5.3-fake.jar
>> > ___________________________________________________________________
>> > Name:
>> > svn:mime-type + application/octet-stream
>> > ________________________________
>> >
>> > To unsubscribe from this list please visit:
>> >
>> > http://xircles.codehaus.org/manage_email
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to