Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.codehaus.mojo.gwt.shell;
  
  /*
   * I18NMojo.java
   *
   * Created on August 19th, 2008
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
 
 import java.io.File;
 
Creates I18N interfaces for constants and messages files.

Author(s):
Sascha-Matthias Kulawik <sascha@kulawik.de>
ccollins
Version:
$Id$
Goal:
i18n
Phase:
generate-sources
RequiresDependencyResolution:
compile
Description:
Creates I18N interfaces for constants and messages files.
 
 public class I18NMojo
     extends AbstractGwtShellMojo
 {
    
List of resourceBundles that should be used to generate i18n Messages interfaces.

Parameter:
Alias:
i18nMessagesNames
 
     private String[] i18nMessagesBundles;

    
Shortcut for a single i18nMessagesBundle

Parameter:
 
     private String i18nMessagesBundle;

    
List of resourceBundles that should be used to generate i18n Constants interfaces.

Parameter:
Alias:
i18nConstantsNames
 
     private String[] i18nConstantsBundles;

    
Shortcut for a single i18nConstantsBundle

Parameter:
 
     private String i18nConstantsBundle;

    
List of resourceBundles that should be used to generate i18n ConstantsWithLookup interfaces.

Parameter:
 
     private String[] i18nConstantsWithLookupBundles;

    
Shortcut for a single i18nConstantsWithLookupBundle

Parameter:
 
 
     public void doExecute( )
     {
         setup();
         boolean generated = false;
 
         // constants with lookup
         if (  != null )
         {
             for ( String target :  )
             {
                 ensureTargetPackageExistsgetGenerateDirectory(), target );
                new JavaCommand"com.google.gwt.i18n.tools.I18NSync" ).withinScope. )
                    .withinClasspathgetGwtUserJar() ).withinClasspathgetGwtDevJar() )
                    .arg"-out"getGenerateDirectory().getAbsolutePath() ).arg"-createConstantsWithLookup" )
                    .argtarget ).execute();
                generated = true;
            }
        }
        // constants
        if (  != null )
        {
            for ( String target :  )
            {
                ensureTargetPackageExistsgetGenerateDirectory(), target );
                new JavaCommand"com.google.gwt.i18n.tools.I18NSync" ).withinScope. )
                    .withinClasspathgetGwtUserJar() ).withinClasspathgetGwtDevJar() )
                    .arg"-out"getGenerateDirectory().getAbsolutePath() ).argtarget ).execute();
                generated = true;
            }
        }
        // messages
        if (  != null )
        {
            for ( String target :  )
            {
                ensureTargetPackageExistsgetGenerateDirectory(), target );
                new JavaCommand"com.google.gwt.i18n.tools.I18NSync" ).withinScope. )
                    .withinClasspathgetGwtUserJar() ).withinClasspathgetGwtDevJar() )
                    .arg"-out"getGenerateDirectory().getAbsolutePath() ).arg"-createMessages" ).argtarget )
                    .execute();
                generated = true;
            }
        }
        if ( generated )
        {
            getLog().debug"add compile source root " + getGenerateDirectory() );
            addCompileSourceRootgetGenerateDirectory() );
        }
    }
    private void setup()
        throws MojoExecutionException
    {
        if (  == null &&  != null )
        {
        }
        if (  == null &&  != null )
        {
             = new String[] {  };
        }
        if (  == null &&  != null )
        {
             = new String[] {  };
        }
        if (  == null &&  == null &&  == null )
        {
            throw new MojoExecutionException(
                "neither i18nConstantsBundles, i18nMessagesBundles nor i18nConstantsWithLookupBundles present. \n"
                + "Cannot execute i18n goal" );
        }
    }
    private void ensureTargetPackageExistsFile generateDirectoryString targetName )
    {
        targetName = targetName.substring( 0, targetName.lastIndexOf'.' ) );
        String targetPackage = targetName.replace'.'. );
        getLog().debug"ensureTargetPackageExists, targetName : " + targetName + ", targetPackage : " + targetPackage );
        File targetPackageDirectory = new FilegenerateDirectorytargetPackage );
        if ( !targetPackageDirectory.exists() )
        {
            targetPackageDirectory.mkdirs();
        }
    }
New to GrepCode? Check out our FAQ X