MavenPomGenerator (Grails 2.3.8)
Date: 2014-04-24

Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.grails.cli.maven
[Groovy] Class MavenPomGenerator

    java.lang.Object
      org.codehaus.groovy.grails.cli.api.BaseSettingsApi
          org.codehaus.groovy.grails.cli.maven.MavenPomGenerator

    class MavenPomGenerator
    extends BaseSettingsApi

Generates a POM for a Grails application.

Authors:
  Graeme Rocher
  Peter Ledbrook

Since:
  2.1

Field Summary

Fields inherited from class BaseSettingsApi
appClassName, buildEventListener, buildProps, buildSettings, configSlurper, enableProfile, grailsAppName, grailsHome, isInteractive, metadata, metadataFile, pluginSettings, pluginsHome, resolver

Constructor Summary
`MavenPomGenerator(BuildSettings buildSettings)`

Method Summary
`protected java.util.Map` | `createModel(java.lang.String group, java.io.File projDir)` Creates a standard template model based on the target directory containing a Grails project.
`protected java.util.Map` | `createModel(java.lang.String group, Metadata projInfo, GrailsPluginInfo pluginInfo = null)`
`void` | `generate(java.lang.String group)` Creates a `pom.xml` file for the current Grails project, i.e. the one pointed to by the build's base directory.
`DependencyInfo` | `generate(java.lang.String group, java.io.File projDir, java.util.Map addedModel)` Creates a `pom.xml` file for the Grails project in the given directory.
`void` | `generatePom(java.io.File projDir, java.lang.String templatePath, java.util.Map model)` Creates a `pom.xml` file in the target directory using the template located at the given path combined with the given model.
`void` | `generateWithParent(java.lang.String group)` This does the same as generate(java.lang.String), but the generated POM includes a `parent` element containing the details of whatever POM is found in the current project's parent directory.
`protected java.util.List` | `getDependenciesForScope(DependencyManager dependencyManager, java.lang.String scope, java.lang.String type = "", java.lang.String newScope = null)` Returns a list of plugin or application dependencies stored in the given dependency manager.
`protected java.util.Map` | `getParentModel(java.io.File pomFile)`

Methods inherited from class BaseSettingsApi
confirmInput, confirmInput, copyGrailsResource, copyGrailsResource, copyGrailsResources, copyGrailsResources, createXmlSlurper, enableUaa, exit, getAppClassName, getAppGrailsVersion, getBuildEventListener, getBuildProps, getBuildSettings, getConfigSlurper, getGrailsAppName, getGrailsAppVersion, getGrailsHome, getIsInteractive, getMetadata, getMetadataFile, getPluginBuildSettings, getPluginSettings, getPluginsHome, getPropertyValue, getResolver, getServerHost, getServerPort, getServerPortHttps, getServletVersion, grailsResource, isDeclared, isEnableProfile, logError, logErrorAndExit, makeApiAvailableToScripts, makeRelative, makeRelative, profile, readAllPluginXmlMetadata, readPluginXmlMetadata, resolveResources, updateMetadata, updateMetadata

Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Constructor Detail

### MavenPomGenerator

    MavenPomGenerator(BuildSettings buildSettings)

Method Detail

### createModel

    protected java.util.Map createModel(java.lang.String group, java.io.File projDir)

  Creates a standard template model based on the target directory containing a Grails project. The method will pick out the project's name, version, and dependencies from the appropriate files. It works for both application and plugin projects.
  Parameters:
    `group` - This is used to populate the model with the variable used for the POM's `groupId` element.
    `projDir` - The directory containing the Grails project of interest.
  Returns:
    A standard template model.

### createModel

    protected java.util.Map createModel(java.lang.String group, Metadata projInfo, GrailsPluginInfo pluginInfo = null)

### generate

    void generate(java.lang.String group)

  Creates a `pom.xml` file for the current Grails project, i.e. the one pointed to by the build's base directory. The generated POM will include the JAR and plugin dependencies declared in `BuildConfig.groovy`.
  Parameters:
    `group` - The string to use for the POM's `groupId` element.

### generate

    DependencyInfo generate(java.lang.String group, java.io.File projDir, java.util.Map addedModel)

  Creates a `pom.xml` file for the Grails project in the given directory. It not only allows you to provide a value for the `groupId`, but you can also provide additional values for the POM template.
  Parameters:
    `group` - The string to use for the POM's `groupId` element.
    `projDir` - The directory containing the Grails project you want to create a POM for. It must exist!
    `addedModel` - A map of additional values for the template. Supported variables are:
    - parent - with `group`, `name` and `version` sub-keys
    - group - the `groupId` string
    - name - the `artifactId` string
    - packaging - the `packaging` string, e.g. 'zip'
    - version - the `versions` string
    - dependencies - a list of JAR DependencyInfo instances that will be merged with the ones derived from `BuildConfig.groovy`
    - plugins - a list of plugin DependencyInfo instances that will be merged with the ones derived from `BuildConfig.groovy`

### generatePom

    void generatePom(java.io.File projDir, java.lang.String templatePath, java.util.Map model)

  Creates a `pom.xml` file in the target directory using the template located at the given path combined with the given model. The template path is resolved as a Grails resource (which may be in the grails-resources JAR or in `$GRAILS_HOME` on the filesystem).
  Parameters:
    `projDir` - The target directory to put the POM.
    `templatePath` - A relative Grails resource path to the template file to use. The template must conform to Groovy's `SimpleTemplateEngine` syntax.
    `model` - A map of variables and values that will be substituted into the template.

### generateWithParent

    void generateWithParent(java.lang.String group)

  This does the same as generate(java.lang.String), but the generated POM includes a `parent` element containing the details of whatever POM is found in the current project's parent directory. The current project is defined as the one in the build's base directory.
  throws:
    FileNotFoundException if a POM cannot be found in the current project's parent directory.
  Parameters:
    `group` - The string to use for the POM's `groupId` element.

### getDependenciesForScope

    protected java.util.List getDependenciesForScope(DependencyManager dependencyManager, java.lang.String scope, java.lang.String type = "", java.lang.String newScope = null)

  Returns a list of plugin or application dependencies stored in the given dependency manager.
  Parameters:
    `scope` - The dependency scope you're interested in, e.g. 'compile', 'provided', etc.
    `type` - The type of the dependencies you want. This can by `null` or an empty string, both of which imply you want just JAR dependencies. Any other type is assumed to mean you want the plugin dependencies. The returned DependencyInfo instances will use the type you specify here.
    `newScope` - If specified, the returned DependencyInfo instances will use this for the `scope` property. Otherwise, they will use the value from the `scope` argument.
  Returns:
    A list of DependencyInfo instances for either the resolved JAR dependencies or plugin dependencies.

### getParentModel

    protected java.util.Map getParentModel(java.io.File pomFile)

Groovy Documentation