Class CollectI18nArtifactsMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.nuiton.plugin.AbstractPlugin
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, org.nuiton.plugin.Plugin, org.nuiton.plugin.PluginWithEncoding

@Mojo(name="collect-i18n-artifacts",
      defaultPhase=GENERATE_RESOURCES,
      requiresProject=true,
      requiresDependencyResolution=RUNTIME)
public class CollectI18nArtifactsMojo
extends AbstractI18nBundleMojo
Detects any i18n artifacts in the dependencies of the project and store their references in a file. The generated file will be used by bundle mojo to generate the final aggregated bundle.
Since:
1.0.2
Author:
Tony Chemit - chemit@codelutin.com
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.nuiton.plugin.Plugin

    org.nuiton.plugin.Plugin.InitState, org.nuiton.plugin.Plugin.Packaging
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected org.apache.maven.shared.dependency.graph.DependencyGraphBuilder dependencyTreeBuilder
    Dependency tree builder component.
    protected org.apache.maven.artifact.repository.ArtifactRepository localRepository
    Local Repository.
    protected java.io.File src
    Directory where to find project i18n files.

    Fields inherited from class org.nuiton.i18n.plugin.bundle.AbstractI18nBundleMojo

    collectOutputDir, collectOutputName

    Fields inherited from class org.nuiton.i18n.plugin.AbstractI18nMojo

    bundles, encoding, locales, mavenSession, project, silent, verbose

    Fields inherited from interface org.apache.maven.plugin.Mojo

    ROLE
  • Constructor Summary

    Constructors 
    Constructor Description
    CollectI18nArtifactsMojo()  
  • Method Summary

    Modifier and Type Method Description
    protected void detectBundles​(I18nArtifact i18nArtifact, java.util.List<org.apache.maven.artifact.Artifact> artifacts, java.util.Map<org.apache.maven.artifact.Artifact,​I18nArtifact> dico)  
    protected I18nArtifact[] detectI18nArtifacts()
    Detecte les I18nArtifact et les retourne dans l'ordre de chargement dans le système i18n, i.e l'ordre des dependances entre artifacts.
    protected void doAction()  
    protected java.net.URL[] getCollectI18nResources​(java.util.Locale locale)
    Pour obtenir les urls des fichiers i18n d'un projet (avec recherche dans ses dépendances).
    void init()  
    protected void storeCollectI18nResources​(java.io.File bundleOut, java.net.URL[] urls)  

    Methods inherited from class org.nuiton.i18n.plugin.bundle.AbstractI18nBundleMojo

    getCollectOutputFile

    Methods inherited from class org.nuiton.plugin.AbstractPlugin

    acceptPackaging, addCompileSourceRoots, addDirectoryToUrlsList, addResourceDir, addTestCompileSourceRoots, addTestResourceDir, addUrlToUrlsList, afterExecute, checkEncoding, checkResource, checkRunOnceDone, checkSkip, copyFile, createDirectoryIfNecessary, createNewFile, deleteFile, execute, getFileFromBasedir, getFilesToTreate, getFilesToTreateForRoots, getRootProject, getTemplate, hasClassPath, initClassLoader, isExecutionRoot, isFileNewerThanPomFile, needInvoke, needInvoke, rejectPackaging, removeCompileSourceRoots, removeTestCompileSourceRoots, renameFile, writeFile

    Methods inherited from class org.apache.maven.plugin.AbstractMojo

    getLog, getPluginContext, setLog, setPluginContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.maven.plugin.Mojo

    execute, getLog, setLog
  • Field Details

    • src

      @Parameter(property="i18n.src", defaultValue="${basedir}/src/main/resources/i18n", required=true) protected java.io.File src
      Directory where to find project i18n files.
    • localRepository

      @Parameter(property="localRepository", required=true, readonly=true) protected org.apache.maven.artifact.repository.ArtifactRepository localRepository
      Local Repository.
      Since:
      1.0.2
    • dependencyTreeBuilder

      @Component protected org.apache.maven.shared.dependency.graph.DependencyGraphBuilder dependencyTreeBuilder
      Dependency tree builder component.
      Since:
      1.0.2
  • Constructor Details

  • Method Details

    • init

      public void init() throws java.lang.Exception
      Overrides:
      init in class AbstractI18nMojo
      Throws:
      java.lang.Exception
    • doAction

      protected void doAction() throws java.lang.Exception
      Specified by:
      doAction in class org.nuiton.plugin.AbstractPlugin
      Throws:
      java.lang.Exception
    • getCollectI18nResources

      protected java.net.URL[] getCollectI18nResources​(java.util.Locale locale) throws java.io.IOException
      Description copied from class: AbstractI18nBundleMojo
      Pour obtenir les urls des fichiers i18n d'un projet (avec recherche dans ses dépendances). Note: L'ordre des urls reflète l'ordre des dépendances.
      Specified by:
      getCollectI18nResources in class AbstractI18nBundleMojo
      Parameters:
      locale - la locale a traiter
      Returns:
      les urls des bundles i18n detectees pour le projet.
      Throws:
      java.io.IOException
    • storeCollectI18nResources

      protected void storeCollectI18nResources​(java.io.File bundleOut, java.net.URL[] urls) throws java.io.IOException
      Throws:
      java.io.IOException
    • detectI18nArtifacts

      protected I18nArtifact[] detectI18nArtifacts() throws java.io.IOException, org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException
      Detecte les I18nArtifact et les retourne dans l'ordre de chargement dans le système i18n, i.e l'ordre des dependances entre artifacts.
      Returns:
      les artifacts i18nables triés par leur ordre de chargement dans le système i18n.
      Throws:
      java.io.IOException - while detecting bundles from artifacts
      org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException
    • detectBundles

      protected void detectBundles​(I18nArtifact i18nArtifact, java.util.List<org.apache.maven.artifact.Artifact> artifacts, java.util.Map<org.apache.maven.artifact.Artifact,​I18nArtifact> dico) throws java.io.IOException
      Throws:
      java.io.IOException