(Quick Reference)

3.7.9 Desplegando a un repositorio Maven - Reference Documentation

Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith

Version: null

3.7.9 Desplegando a un repositorio Maven

If you use Maven to build your Grails project, you can use the standard Maven targets mvn install and mvn deploy. If not, you can deploy a Grails project or plugin to a Maven repository using the maven-publisher plugin.

The plugin provides the ability to publish Grails projects and plugins to local and remote Maven repositories. There are two key additional targets added by the plugin:

  • maven-install - Installs a Grails project or plugin into your local Maven cache
  • maven-deploy - Deploys a Grails project or plugin to a remote Maven repository

By default this plugin will automatically generate a valid pom.xml for you unless a pom.xml is already present in the root of the project, in which case this pom.xml file will be used.

Si utiliza a Maven para construir su proyecto Grails, puede utilizar el target estándar de Maven mvn install and mvn deploy. Si no es así, puede desplegar un proyecto Grails o un plugin en un repositorio de Maven utilizando el plugin maven-publisher.

El plugin permite publicar proyectos Grails y plugins en repositorios Maven locales y remotos. Hay dos target principales adicionales agregados por el plugin:

  • maven-install - instala un plugin o un proyecto Grails en la caché local de Maven.
  • maven-deploy - despliega un proyecto Grails o plugin para un repositorio Maven remoto.

De forma predeterminada este plugin generará automáticamente un pom.xml válido a menos que un pom.xml ya está presente en la raíz del proyecto, en cuyo caso se utilizará este archivo pom.xml.

maven-install

The maven-install command will install the Grails project or plugin artifact into your local Maven cache:

grails maven-install

In the case of plugins, the plugin zip file will be installed, whilst for application the application WAR file will be installed.

maven-install

El comando maven-install instalará el proyecto o plugin Grails en la caché local de Maven:

grails maven-install

En el caso de plugins, se instalará el archivo zip de plugin, mientras que para la aplicación se instalará el archivo WAR de aplicación.

maven-deploy

The maven-deploy command will deploy a Grails project or plugin into a remote Maven repository:

grails maven-deploy

It is assumed that you have specified the necessary <distributionManagement> configuration within a pom.xml or that you specify the id of the remote repository to deploy to:

maven-deploy

El comando maven-deploy desplegará un proyecto Grails o plugin en un repositorio de Maven remoto:

grails maven-deploy

Se supone que se ha especificado la configuración necesaria <distributionmanagement> dentro de un pom.xml o que especifica el id del repositorio remoto en el que desplegar:

grails maven-deploy --repository=myRepo

The repository argument specifies the 'id' for the repository. Configure the details of the repository specified by this 'id' within your grails-app/conf/BuildConfig.groovy file or in your $USER_HOME/.grails/settings.groovy file:

El argumento repository especifica el 'id' para el repositorio. Configure los detalles del repositorio especificado por este 'id' en el archivo grails-app/conf/BuildConfig.groovy o en el archivo $USER_HOME/.grails/settings.groovy:

grails.project.dependency.distribution = {
    localRepository = "/path/to/my/local"
    remoteRepository(id: "myRepo", url: "http://myserver/path/to/repo")
}

The syntax for configuring remote repositories matches the syntax from the remoteRepository element in the Ant Maven tasks. For example the following XML:

La sintaxis para configurar repositorios remotos coincide con la sintaxis del elemento remoteRepository en las tareas Ant Maven. Por ejemplo, el siguiente XML:

<remoteRepository id="myRepo" url="scp://localhost/www/repository">
    <authentication username="..." privateKey="${user.home}/.ssh/id_dsa"/>
</remoteRepository>

Can be expressed as:

Puede ser expresada como:

remoteRepository(id: "myRepo", url: "scp://localhost/www/repository") {
    authentication username: "...", privateKey: "${userHome}/.ssh/id_dsa"
}

By default the plugin will try to detect the protocol to use from the URL of the repository (ie "http" from "http://.." etc.), however to specify a different protocol you can do:

De forma predeterminada el plugin intentará detectar el protocolo a usar desde la URL del repositorio (es decir "http" desde "http://..." etc.), sin embargo para especificar otro protocolo puede hacer:

grails maven-deploy --repository=myRepo --protocol=webdav

The available protocols are:

  • http
  • scp
  • scpexe
  • ftp
  • webdav

Los protocolos disponibles son:

  • http
  • scp
  • scpexe
  • ftp
  • webdav

Groups, Artifacts and Versions

Maven defines the notion of a 'groupId', 'artifactId' and a 'version'. This plugin pulls this information from the Grails project conventions or plugin descriptor.

Versiones, artefactos y grupos

Maven define la noción de 'IdGrupo', 'artifactId' y 'versión'. Este plugin extrae esta información de los convenciones de proyecto Grails o del descriptor del plugin.

Projects

For applications this plugin will use the Grails application name and version provided by Grails when generating the pom.xml file. To change the version you can run the set-version command:

Proyectos

Para las aplicaciones de este plugin utilizará el nombre de la aplicación de Grails y la versión proporcionada por Grails al generar el archivo pom.xml. Para cambiar la versión puede ejecutar el comando set-version:

grails set-version 0.2

The Maven groupId will be the same as the project name, unless you specify a different one in Config.groovy:

El groupId de Maven será el mismo que el nombre del proyecto, a menos que se especifique otro diferente en Config.groovy:

grails.project.groupId="com.mycompany"

Plugins

With a Grails plugin the groupId and version are taken from the following properties in the GrailsPlugin.groovy descriptor:

Plugins

Con un plugin de Grails el groupId y version proceden de las siguientes propiedades en el descriptor de GrailsPlugin.groovy:

String groupId = 'myOrg'
String version = '0.1'

The 'artifactId' is taken from the plugin name. For example if you have a plugin called FeedsGrailsPlugin the artifactId will be "feeds". If your plugin does not specify a groupId then this defaults to "org.grails.plugins".

El 'artifactId' se toma del nombre del plugin. Por ejemplo, si tienes un plugin llamado FeedsGrailsPlugin el artifactId será "feeds". Si tu plugin no especifica el groupId entonces por defecto utiliza "org.grails.plugins".