Class IdeaModuleMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    public class IdeaModuleMojo
    extends AbstractIdeaMojo
    Creates the module files (*.iml) for IntelliJ IDEA.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Map attemptedDownloads
      A temporary cache of artifacts that's already been downloaded or attempted to be downloaded.
      private boolean dependenciesAsLibraries
      Causes the module libraries to use a short name for all dependencies.
      private java.lang.String deploymentDescriptorFile
      Specify the location of the deployment descriptor file, if one is provided.
      private boolean downloadJavadocs
      Enables/disables the downloading of javadoc attachments.
      private boolean downloadSources
      Enables/disables the downloading of source attachments.
      private java.lang.String exclude
      A comma-separated list of directories that should be excluded.
      private boolean ideaPlugin
      Tell IntelliJ IDEA that this module is an IntelliJ IDEA Plugin.
      private java.lang.String ideaVersion
      Specify the version of IDEA to target.
      private java.lang.String javadocClassifier
      Sets the classifier string attached to an artifact javadoc archive name.
      private Library[] libraries
      An optional set of Library objects that allow you to specify a comma separated list of source dirs, class dirs, or to indicate that the library should be excluded from the module.
      private boolean linkModules
      Whether to link the reactor projects as dependency modules or as libraries.
      private java.util.Set macros  
      private java.util.List reactorProjects
      The reactor projects in a multi-module build.
      private java.lang.String sourceClassifier
      Sets the classifier string attached to an artifact source archive name.
      private boolean useFullNames
      Whether to use full artifact names when referencing libraries.
      private org.apache.maven.artifact.manager.WagonManager wagonManager  
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Constructor Summary

      Constructors 
      Constructor Description
      IdeaModuleMojo()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private org.dom4j.Element addDeploymentDescriptor​(org.dom4j.Element component, java.lang.String name, java.lang.String version, java.lang.String file)  
      private void addEarModule​(org.dom4j.Element module)  
      private void addEjbModule​(org.dom4j.Element module)  
      private void addExcludeFolder​(org.dom4j.Element content, java.lang.String directory)  
      private void addPluginModule​(org.dom4j.Element module)  
      private void addSourceFolder​(org.dom4j.Element content, java.lang.String directory, boolean isTest)
      Adds a sourceFolder element to IDEA (.iml) project file
      private void addWebModule​(org.dom4j.Element module)
      Adds the Web module to the (.iml) project file.
      private org.dom4j.Element createOrGetElement​(org.dom4j.Element lib, java.lang.String name)  
      void execute()
      Create IDEA (.iml) project files.
      private void extractMacro​(java.lang.String path)  
      private Library findLibrary​(org.apache.maven.artifact.Artifact a)  
      private org.dom4j.Element findSetting​(org.dom4j.Element component, java.lang.String name)
      Returns an Xpp3Dom element (setting).
      private java.util.List getExcludedDirectories​(java.io.File target, java.util.List excludeList, java.util.List sourceFolders)  
      private java.lang.String getLibraryUrl​(org.apache.maven.artifact.Artifact artifact)  
      private java.lang.String getModuleFileUrl​(java.io.File basedir, java.lang.String path)
      Translate the relative path of the file into module path
      private java.lang.String getModuleFileUrl​(java.lang.String file)  
      void initParam​(org.apache.maven.project.MavenProject project, org.apache.maven.artifact.factory.ArtifactFactory artifactFactory, org.apache.maven.artifact.repository.ArtifactRepository localRepo, org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver, org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource, org.apache.maven.plugin.logging.Log log, boolean overwrite, org.apache.maven.project.MavenProject executedProject, java.util.List reactorProjects, org.apache.maven.artifact.manager.WagonManager wagonManager, boolean linkModules, boolean useFullNames, boolean downloadSources, java.lang.String sourceClassifier, boolean downloadJavadocs, java.lang.String javadocClassifier, Library[] libraries, java.util.Set macros, java.lang.String exclude, boolean useShortDependencyNames, java.lang.String deploymentDescriptorFile, boolean ideaPlugin, java.lang.String ideaVersion)  
      private boolean isReactorProject​(java.lang.String groupId, java.lang.String artifactId)  
      private java.lang.String resolveClassifiedArtifact​(org.apache.maven.artifact.Artifact artifact, java.lang.String classifier)  
      private void resolveClassifier​(org.dom4j.Element element, org.apache.maven.artifact.Artifact a, java.lang.String classifier)  
      private void rewriteDependencies​(org.dom4j.Element component)  
      void rewriteModule()  
      • Methods inherited from class org.apache.maven.plugin.AbstractMojo

        getPluginContext, setLog, setPluginContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • reactorProjects

        private java.util.List reactorProjects
        The reactor projects in a multi-module build.
      • wagonManager

        private org.apache.maven.artifact.manager.WagonManager wagonManager
      • linkModules

        private boolean linkModules
        Whether to link the reactor projects as dependency modules or as libraries.
      • deploymentDescriptorFile

        private java.lang.String deploymentDescriptorFile
        Specify the location of the deployment descriptor file, if one is provided.
      • useFullNames

        private boolean useFullNames
        Whether to use full artifact names when referencing libraries.
      • downloadSources

        private boolean downloadSources
        Enables/disables the downloading of source attachments.
      • downloadJavadocs

        private boolean downloadJavadocs
        Enables/disables the downloading of javadoc attachments.
      • sourceClassifier

        private java.lang.String sourceClassifier
        Sets the classifier string attached to an artifact source archive name.
      • javadocClassifier

        private java.lang.String javadocClassifier
        Sets the classifier string attached to an artifact javadoc archive name.
      • libraries

        private Library[] libraries
        An optional set of Library objects that allow you to specify a comma separated list of source dirs, class dirs, or to indicate that the library should be excluded from the module. For example:

         <libraries>
          <library>
              <name>webwork</name>
              <sources>file://$webwork$/src/java</sources>
              <!--
              <classes>...</classes>
              <exclude>true</exclude>
              -->
          </library>
         </libraries>
         
      • exclude

        private java.lang.String exclude
        A comma-separated list of directories that should be excluded. These directories are in addition to those already excluded, such as target.
      • dependenciesAsLibraries

        private boolean dependenciesAsLibraries
        Causes the module libraries to use a short name for all dependencies. This is very convenient but has been reported to cause problems with IDEA.
      • attemptedDownloads

        private static java.util.Map attemptedDownloads
        A temporary cache of artifacts that's already been downloaded or attempted to be downloaded. This is to refrain from trying to download a dependency that we have already tried to download.
      • ideaPlugin

        private boolean ideaPlugin
        Tell IntelliJ IDEA that this module is an IntelliJ IDEA Plugin.
      • ideaVersion

        private java.lang.String ideaVersion
        Specify the version of IDEA to target. This is needed to identify the default formatting of project-jdk-name used by IDEA. Currently supports 4.x and 5.x.

        This will only be used when parameter jdkName is not set.

      • macros

        private java.util.Set macros
    • Constructor Detail

      • IdeaModuleMojo

        public IdeaModuleMojo()
    • Method Detail

      • initParam

        public void initParam​(org.apache.maven.project.MavenProject project,
                              org.apache.maven.artifact.factory.ArtifactFactory artifactFactory,
                              org.apache.maven.artifact.repository.ArtifactRepository localRepo,
                              org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver,
                              org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource,
                              org.apache.maven.plugin.logging.Log log,
                              boolean overwrite,
                              org.apache.maven.project.MavenProject executedProject,
                              java.util.List reactorProjects,
                              org.apache.maven.artifact.manager.WagonManager wagonManager,
                              boolean linkModules,
                              boolean useFullNames,
                              boolean downloadSources,
                              java.lang.String sourceClassifier,
                              boolean downloadJavadocs,
                              java.lang.String javadocClassifier,
                              Library[] libraries,
                              java.util.Set macros,
                              java.lang.String exclude,
                              boolean useShortDependencyNames,
                              java.lang.String deploymentDescriptorFile,
                              boolean ideaPlugin,
                              java.lang.String ideaVersion)
      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException
        Create IDEA (.iml) project files.
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • rewriteModule

        public void rewriteModule()
                           throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • rewriteDependencies

        private void rewriteDependencies​(org.dom4j.Element component)
      • createOrGetElement

        private org.dom4j.Element createOrGetElement​(org.dom4j.Element lib,
                                                     java.lang.String name)
      • addEarModule

        private void addEarModule​(org.dom4j.Element module)
      • addEjbModule

        private void addEjbModule​(org.dom4j.Element module)
      • extractMacro

        private void extractMacro​(java.lang.String path)
      • findLibrary

        private Library findLibrary​(org.apache.maven.artifact.Artifact a)
      • getExcludedDirectories

        private java.util.List getExcludedDirectories​(java.io.File target,
                                                      java.util.List excludeList,
                                                      java.util.List sourceFolders)
      • addWebModule

        private void addWebModule​(org.dom4j.Element module)
        Adds the Web module to the (.iml) project file.
        Parameters:
        module - Xpp3Dom element
      • addPluginModule

        private void addPluginModule​(org.dom4j.Element module)
      • getModuleFileUrl

        private java.lang.String getModuleFileUrl​(java.io.File basedir,
                                                  java.lang.String path)
        Translate the relative path of the file into module path
        Parameters:
        basedir - File to use as basedir
        path - Absolute path string to translate to ModuleFileUrl
        Returns:
        moduleFileUrl Translated Module File URL
      • getModuleFileUrl

        private java.lang.String getModuleFileUrl​(java.lang.String file)
      • addSourceFolder

        private void addSourceFolder​(org.dom4j.Element content,
                                     java.lang.String directory,
                                     boolean isTest)
        Adds a sourceFolder element to IDEA (.iml) project file
        Parameters:
        content - Xpp3Dom element
        directory - Directory to set as url.
        isTest - True if directory isTestSource.
      • addExcludeFolder

        private void addExcludeFolder​(org.dom4j.Element content,
                                      java.lang.String directory)
      • isReactorProject

        private boolean isReactorProject​(java.lang.String groupId,
                                         java.lang.String artifactId)
      • resolveClassifier

        private void resolveClassifier​(org.dom4j.Element element,
                                       org.apache.maven.artifact.Artifact a,
                                       java.lang.String classifier)
      • resolveClassifiedArtifact

        private java.lang.String resolveClassifiedArtifact​(org.apache.maven.artifact.Artifact artifact,
                                                           java.lang.String classifier)
      • findSetting

        private org.dom4j.Element findSetting​(org.dom4j.Element component,
                                              java.lang.String name)
        Returns an Xpp3Dom element (setting).
        Parameters:
        component - Xpp3Dom element
        name - Setting attribute to find
        Returns:
        setting Xpp3Dom element
      • getLibraryUrl

        private java.lang.String getLibraryUrl​(org.apache.maven.artifact.Artifact artifact)
      • addDeploymentDescriptor

        private org.dom4j.Element addDeploymentDescriptor​(org.dom4j.Element component,
                                                          java.lang.String name,
                                                          java.lang.String version,
                                                          java.lang.String file)